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 #1325

Merged
merged 13 commits into from
May 25, 2020
Merged

Upgrade to babel 7 #1325

merged 13 commits into from
May 25, 2020

Conversation

Xiot
Copy link
Contributor

@Xiot Xiot commented May 24, 2020

Upgrade all packages to use babel 7.
Moved the plugins into the root babel.config.json file.
Use --root-mode upward to enable lookups into the root config file.

Upgrade all packages to use babel 7.
Moved the plugins into the root babel.config.json file.
Use --root-mode upward to enable lookups into the root config file.
Copy link
Contributor

@chrisirhc chrisirhc left a comment

Choose a reason for hiding this comment

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

Seems like we're adding a lot more configuration and also peer dependency here. I'm not sure this is the best path forward.

We went from minimal presets to a ton of configuration.

"@babel/plugin-proposal-export-default-from",
"@babel/plugin-proposal-logical-assignment-operators",
"@babel/plugin-proposal-optional-chaining",
[
Copy link
Contributor

Choose a reason for hiding this comment

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

This is great, but also, could we keep the plugins minimal and add them only as we need them?

How about we use the newest presets available?

Adding them all at once encourages usage of the features, which adds complexity to configuration. Some configs like don't work well with Flow. Not sure if it'll be an issue when using typescript.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed, we could add only the features we currently use

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These will probably be mostly redundant when using typescript.
babel deprecated the yearly presents, and these plugins were added using the babel-upgrade script. These are the latest versions of the plugins that we already had.

Copy link
Contributor

Choose a reason for hiding this comment

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

If we look at baseweb, looks like there's minimal configuration by using the react preset. Perhaps we can try what's there first?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My approach for tasks like this is to migrate first, and optimize later as it keeps diffs smaller and it more apparent on what the optimizations are.

Either way, this won't work until we fix the tests since the tests are referencing 'showcase' and it isn't being "compiled"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

trimmed to

 "presets": [
        "@babel/preset-env",
        "@babel/preset-react"
      ],
      "plugins": [
        "@babel/plugin-syntax-dynamic-import",
        "@babel/plugin-proposal-class-properties",
        "@babel/plugin-proposal-export-default-from",
        "@babel/plugin-proposal-optional-chaining",
        "@babel/plugin-proposal-nullish-coalescing-operator"
      ]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

actually just removed dynamic-import as well.

packages/react-vis/package.json Outdated Show resolved Hide resolved
"babelrcRoots": [
".",
"./packages/*"
],
Copy link
Contributor

Choose a reason for hiding this comment

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

With this, do we still need the rootMode option? Reading the Babel docs it seems to indicate that it would search from the roots upwards.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ya.. we still need the rootMode otherwise babel wont look up the tree for the babel.config.js file.

Here are the docs for configuring babel in a mono-repo
https://babeljs.io/docs/en/config-files#monorepos

@Xiot
Copy link
Contributor Author

Xiot commented May 24, 2020

The tests are currently failing because showcase directly references react-vis and it isn't being "compiled". This will probably be fixed when we address the imports.

I was hoping to fix this after converting to babel-7, but it looks like I'll have to fix it first.

@Xiot
Copy link
Contributor Author

Xiot commented May 24, 2020

My approach for tasks like this is to migrate first, and optimize later as it keeps diffs smaller and it more apparent on what the optimaztions are

@Xiot
Copy link
Contributor Author

Xiot commented May 24, 2020

PR to fix the imports #1326

@Xiot Xiot mentioned this pull request May 24, 2020
3 tasks
@@ -80,6 +97,7 @@
"react-addons-test-utils": ">=15.4.2",
"react-dom": "^16.0.0",
"react-test-renderer": "^16.13.1",
"react-vis-showcase": "^0.1.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

Hm why is this necessary? Won't it become a circular depedency?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it is a ciruclar dependency. But that dependency already existed since the tests directly reference the components in showcase.

We can fix this when we refactor the tests.
#1328

packages/showcase/app.css Outdated Show resolved Hide resolved
// 'index':path.join(__dirname,'..', 'src', 'index.js'),
// 'theme':path.join(__dirname,'..', 'src', 'theme.js')
}
modules: ['node_modules', path.join(__dirname,'..', 'react-vis', 'src')],
Copy link
Contributor

@chrisirhc chrisirhc May 24, 2020

Choose a reason for hiding this comment

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

urgh, we should avoid custom node_modules resolutions, it's bound to cause headaches later (having this config along with babel config).
I thought yarn workspaces would allow us to avoid this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Completely agree.
yarn workspaces will definately help us with this, however there is a bunch of cleanup that has to be done first.

Next step (separate PR) is to clean up the imports in the react-vis, then we should be able to remove this module resolution.

@Xiot Xiot merged commit f6132ca into uber:yarn-workspaces May 25, 2020
@Xiot Xiot deleted the babel-upgrade branch May 25, 2020 01:41
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

3 participants