Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Babel 7 #1511

Merged
merged 13 commits into from Jun 27, 2019
Merged

Upgrade to Babel 7 #1511

merged 13 commits into from Jun 27, 2019

Conversation

shaundon
Copy link
Contributor

@shaundon shaundon commented Jun 19, 2019

As well as Babel, this also upgrades Jest and Danger to the latest versions.

Getting npm run build to work

Babel 7 doesn't work the same way for monorepos as Babel 6 did.

  • In v6, Babel would traverse upwards through directories until it found a config file.
  • In v7, it stops traversing upwards once it find a package.json.

As every folder in packages/ has a package.json this means Babel no longer works. Babel 7.1+ provides an option here, named rootMode: 'upward' which reinstates the previous behaviour. To get this to work, I've added a new gulpfile.js to every Gulp-using package that registers Babel with this mode enabled and then requires the ES6 gulpfile.

For bpk-stylesheets that uses Webpack, I had to do a similar thing except with another option specified. This is detailed in the build.js file in bpk-stylesheets.

Getting npm run storybook to work

Removed /storybook/.babelrc. Now inherits from the root config.

Getting npm test to work

Done. Some snapshots have updated as I also updated to the latest Jest and babel-jest.

Checking base.js is ok

bpk-stylesheets/base.js was updated. To check this won't break things, I checked:

✅ The bpk-no-touch-support class is added to non-touch browsers (tested in desktop Chrome)
✅ The bpk-touch-support class is added to touch browsers (tested in mobile Safari)

Helpful links

@@ -4,7 +4,7 @@
"description": "Backpack's stylesheets.",
"main": "index.js",
"scripts": {
"build": "webpack"
"build": "node build.js"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have to manually call webpack from build.js to avoid this error:

Screen Shot 2019-06-26 at 16 37 12

"jest": "TZ=Europe/London jest --coverage",
"jest:update": "TZ=Etc/UTC jest --updateSnapshot",
"jest:watch": "TZ=Etc/UTC jest --watch",
"jest": "TZ=Etc/UTC jest --coverage",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One of the snapshots changed to use BST. I expect this is because something internally changed in Jest, so I set the timezone to UTC here.

this.listeners.forEach(cb => cb(...args));
}
};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function stopped working without this, so I made it use arrow syntax.

@@ -24,7 +24,7 @@ exports[`BpkMapMarker should render correctly with a "arrowClassName" attribute
<div
className="bpk-map-marker__arrow custom-class-1 custom-class-2"
>
<Component />
<_default />
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm struggling to find documentation for why this would change. It seems ok though so I'm not concerned. My gut feeling is that this is happening for components that don't have a name. In this case it's an imported icon.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I would read that as "The default import from the package"

@backpackbot

This comment has been minimized.

@backpackbot
Copy link

backpackbot commented Jun 27, 2019

Warnings
⚠️

One or more packages have changed, but UNRELEASED.md wasn't updated.

⚠️

package-lock.json was updated. Ensure that this was intentional.

Messages
📖

Browser support

Please complete this list of browsers that you've checked this works in.

  • IE11
  • Edge
  • Safari (iOS)
  • Chrome (Android)
  • Chrome (Desktop)
  • Firefox (Desktop)

Generated by 🚫 dangerJS against af2a26c

@shaundon shaundon changed the title WIP: Upgrade to babel 7 Upgrade to babel 7 Jun 27, 2019
@shaundon shaundon changed the title Upgrade to babel 7 Upgrade to Babel 7 Jun 27, 2019
@olliecurtis olliecurtis self-requested a review June 27, 2019 10:28
@olliecurtis olliecurtis self-assigned this Jun 27, 2019
Copy link
Member

@olliecurtis olliecurtis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks perfect! All seems to still work with this so happy to approve 👍 🎉

@shaundon shaundon merged commit ff82608 into master Jun 27, 2019
@shaundon shaundon deleted the no-jira-babel-7 branch June 27, 2019 11:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants