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

Update Rollup and related plugins to their most recent versions #24916

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

0xdevalias
Copy link

@0xdevalias 0xdevalias commented Jul 13, 2022

Summary

Update Rollup and related plugins to their most recent versions + resolve any breaking changes/deprecations/etc along the way. I made each change piece by piece, so the commit history tells a pretty good story of what was changed where/how/why.

fixes #24894

For the full deepdive/context, see:

The inspiration for this came from @jasonwilliams 's PR for attempting to add sourcemap output support to React's builds:

But I figured that it would be useful to minimise the scope of changes in that PR, and to modernise the build tooling along the way.

If any of these updates rely on a node version later than 10.x, then the following PR may have to land first, otherwise things might break on AppVeyor:

How did you test this change?

See some of my testing notes RE: figuring compatible package versions + their associated changes in #24894 (comment) Of particular note is the difference in the react.development.js output between Rollup 1.x and rollup 2.x:

I'm not currently sure if these changes are significant/change the semantics of the output, or are just a different way of the bundler working, but I did notice that it increases the output file sizes a bit (most dramatically in react.development.js):

I ran the tests with yarn test --prod, and opened a separate issue for the few tests that seem to fail on Node 16.x:

⇒  yarn test --prod

..snip..

Test Suites: 3 failed, 2 skipped, 283 passed, 286 of 288 total
Tests:       3 failed, 89 skipped, 7553 passed, 7645 total
Snapshots:   125 passed, 125 total
Time:        245.388 s
Ran all test suites.

I'm not 100% certain if this is the most thorough/complete way to test things, so I am definitely open to suggestions on how to improve confidence in these changes.

@0xdevalias 0xdevalias changed the title npx yarn-deduplicate Update Rollup and related plugins to their most recent versions Jul 13, 2022
Copy link
Author

@0xdevalias 0xdevalias left a comment

Added a few comments/pointers to help explain some of the changes made + point to relevent docs/changelog/etc.

It's definitely also worth looking at the commits, as I tried to keep all of the changes neatly isolated, so it may help tell the story of the changes better:

@@ -156,6 +156,7 @@ function getBabelConfig(
configFile: false,
presets: [],
plugins: [...babelPlugins],
babelHelpers: 'bundled',
Copy link
Author

@0xdevalias 0xdevalias Jul 13, 2022

Choose a reason for hiding this comment

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

Added as per advice in https://github.com/rollup/plugins/blob/master/packages/babel/CHANGELOG.md#500

Removed externalHelpers & runtimeHelpers options. There is now a single babelHelpers option which can take one of 'bundled', 'inline', 'runtime' and 'external' as a value. The default is 'bundled' which matches 4.x behavior, but it is recommended to configure this option explicitly.

skip: externals,
// skip: externals, // TODO: options.skip was removed in @rollup/plugin-node-resolve 3.0.0
Copy link
Author

@0xdevalias 0xdevalias Jul 13, 2022

Choose a reason for hiding this comment

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

TODO: options.skip was removed in @rollup/plugin-node-resolve 3.0.0

Is there a different value we should be using here now in it's place? (external?)

__DEV__: isProduction ? 'false' : 'true',
__PROFILE__: isProfiling || !isProduction ? 'true' : 'false',
__UMD__: isUMDBundle ? 'true' : 'false',
'process.env.NODE_ENV': isProduction ? "'production'" : "'development'",
__EXPERIMENTAL__,
// Enable forked reconciler.
// NOTE: I did not put much thought into how to configure this.
__VARIANT__: bundle.enableNewReconciler === true,
preventAssignment: true,
values: {
__DEV__: isProduction ? 'false' : 'true',
__PROFILE__: isProfiling || !isProduction ? 'true' : 'false',
__UMD__: isUMDBundle ? 'true' : 'false',
'process.env.NODE_ENV': isProduction ? "'production'" : "'development'",
__EXPERIMENTAL__,
// Enable forked reconciler.
// NOTE: I did not put much thought into how to configure this.
__VARIANT__: bundle.enableNewReconciler === true,
}
Copy link
Author

@0xdevalias 0xdevalias Jul 13, 2022

Choose a reason for hiding this comment

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

@@ -540,7 +544,7 @@ async function createBundle(bundle, bundleType) {
const rollupConfig = {
input: resolvedEntry,
treeshake: {
pureExternalModules,
moduleSideEffects: pureExternalModules,
Copy link
Author

@0xdevalias 0xdevalias Jul 13, 2022

Choose a reason for hiding this comment

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

@@ -323,7 +323,11 @@ async function bundle() {
plugins: [
rollupResolve(),
commonjs(),
babel({presets: ['@babel/preset-react'], sourceMap: true}),
babel({
babelHelpers: 'bundled',
Copy link
Author

@0xdevalias 0xdevalias Jul 13, 2022

Choose a reason for hiding this comment

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

@0xdevalias
Copy link
Author

@0xdevalias 0xdevalias commented Jul 13, 2022

The build is currently failing due to the following error:

 BUILDING  react-server-dom-webpack-writer.browser.production.min.server.js (umd_prod)

Could not resolve import "react-server-dom-webpack/src/ReactFlightServerWebpackBundlerConfig" in /home/circleci/project/packages/react-server/src/forks/ReactFlightServerConfig.dom-browser.js using exports defined in /home/circleci/project/packages/react-server-dom-webpack/package.json.

internal/fs/utils.js:314
    throw err;
    ^

Error: ENOENT: no such file or directory, stat 'build/node_modules/react/package.json'
    at Object.statSync (fs.js:1127:3)
    at updatePackageVersions (/home/circleci/project/scripts/rollup/build-all-release-channels.js:261:22)
    at processStable (/home/circleci/project/scripts/rollup/build-all-release-channels.js:127:5)
    at Object.<anonymous> (/home/circleci/project/scripts/rollup/build-all-release-channels.js:66:5)
    at Module._compile (internal/modules/cjs/loader.js:1072:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
    at Module.load (internal/modules/cjs/loader.js:937:32)
    at Function.Module._load (internal/modules/cjs/loader.js:778:12)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
    at internal/main/run_main_module.js:17:47 {
  errno: -2,
  syscall: 'stat',
  code: 'ENOENT',
  path: 'build/node_modules/react/package.json'
}

I wonder if there could be some node_modules cache weirdness happening maybe?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants