-
Notifications
You must be signed in to change notification settings - Fork 833
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
Upgrade to babel 7 #1325
Conversation
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.
There was a problem hiding this 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.config.json
Outdated
"@babel/plugin-proposal-export-default-from", | ||
"@babel/plugin-proposal-logical-assignment-operators", | ||
"@babel/plugin-proposal-optional-chaining", | ||
[ |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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"
There was a problem hiding this comment.
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"
]
There was a problem hiding this comment.
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.
"babelrcRoots": [ | ||
".", | ||
"./packages/*" | ||
], |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
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. |
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 |
PR to fix the imports #1326 |
@@ -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", |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
// 'index':path.join(__dirname,'..', 'src', 'index.js'), | ||
// 'theme':path.join(__dirname,'..', 'src', 'theme.js') | ||
} | ||
modules: ['node_modules', path.join(__dirname,'..', 'react-vis', 'src')], |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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.