-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Build: move dependency transpilation config to calypso-build #38531
Conversation
This PR does not affect the size of JS and CSS bundles shipped to the user's browser. Generated by performance advisor bot at iscalypsofastyet.com. |
@@ -112,6 +112,12 @@ function getWebpackConfig( | |||
presets, | |||
workerCount, | |||
} ), | |||
TranspileConfig.loader( { | |||
cacheDirectory: true, | |||
include: shouldTranspileDependency, |
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.
We'll want to expose this to the user of calypso-build, as they may have dependencies that require transpilation that calypso does not.
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.
Do users need to only expand the whitelist with new entries, or to also exclude some existing ones?
// general form is <package-name>/. | ||
// The trailing slash makes sure we're not matching these as prefixes | ||
// In some cases we do want prefix style matching (lodash. for lodash.assign) | ||
'@github/webauthn-json/', |
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.
Would now be a good time to extend this to support semver?
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.
The idea is to have semver specifiers like debug@^3
in the whitelist and be able to read the package.json
for a tested package and match the semver version?
That seems a big enough topic to warrant its own PR. We probably want to keep some cache of "file-path -> package-version" mappings, so that we don't do the look up for every file (every package can include a large number of contained files and webpack sees each sub-path separately).
'react-spring/', | ||
'regenerate-unicode-properties/', | ||
'regexpu-core/', | ||
'striptags', |
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.
oop, this one should have a trailing /
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 go the semver route, and start exposing API for expanding the whitelist, then we should get rid of the trailing slashes and patch the matching algorithm instead.
c73ab27
to
96e5df3
Compare
96e5df3
to
136aa8a
Compare
I rebased this PR onto the latest master and it's still ready for review. One open question is to whether to allow to customize the whitelist of transpiled dependencies and how. We can also take the CRA route and start transpiling all @blowery @ockham @sgomes let me know if you have any concerns. |
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.
No concerns from my end. This makes sense to live in calypso-build
, and I don't see an immediate need to make the transpilation list configurable, as all projects making use of calypso-build
presumably need (or can benefit from) the same configuration there.
I'd expect the es6 fallback build linter to catch issues. |
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.
I haven't tested, but I looked it over and this makes sense. Thanks!
Will you add a changelog entry to calypso-build? |
Alternative to #33492 which still uses the special Babel config for transpiling dependencies, but moves it to the `calypso-build` package. This PR, unlike #33492, doesn't attempt to transpile both app and `node_modules` code with the same Babel config. It keeps the separation and shouldn't cause any changes in output -- just moves code to a different location. Also, this approach is in line with what Create React App does. After merging this, `calypso-build` should start transpiling dependencies out of the box, without any configuration. Jetpack can just upgrade to the new version and be done.
136aa8a
to
d90f1ee
Compare
Thanks all! |
Alternative to #33492 which still uses the special Babel config for transpiling dependencies, but moves it to the
calypso-build
package.This PR, unlike #33492, doesn't attempt to transpile both app and
node_modules
code with the same Babel config. It keeps the separation and shouldn't cause any changes in output -- just moves code to a different location. That involves less risk in my opinion.Also, this approach is in line with what Create React App does.
After merging this,
calypso-build
should start transpiling dependencies out of the box, without any configuration. Jetpack can just upgrade to the new version and be done.How to test:
I'm not sure what's the right way to test if dependencies are still transpiled correctly. Load the calypso.live build in IE11?