Skip to content

[ci] Reduce non-deterministic builds for eslint-plugin-react-hooks #33026

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

Merged
merged 1 commit into from
Apr 25, 2025

Conversation

mofeiZ
Copy link
Contributor

@mofeiZ mofeiZ commented Apr 25, 2025

See rollup/plugins#1425

Currently, @babel/helper-string-parser/lib/index.js is either emitted as a wrapped esmodule or inline depending on the ordering of async functions in rollup/commonjs. Specifically, @babel/types/lib/definitions/core.js is cyclic (i.e. transitively depends upon itself), but sometimes @babel/helper-string-parser/lib/index.js is emitted before this is realized.

A relatively straightforward patch is to wrap all modules (see rollup/plugins#1425 (comment)). This only regresses eslint-plugin-react-hooks bundle size by ~1.8% and is safer (see https://github.com/rollup/plugins/blob/master/packages/commonjs/README.md#strictrequires)

The default value of true will wrap all CommonJS files in functions which are executed when they are required for the first time, preserving NodeJS semantics. This is the safest setting and should be used if the generated code does not work correctly with "auto". Note that strictRequires: true can have a small impact on the size and performance of generated code, but less so if the code is minified.

(note that we're on an earlier version of @rollup/commonjs which does not default to strictRequires: true)

See rollup/plugins#1425

Currently, `@babel/helper-string-parser/lib/index.js` is either emitted as a wrapped esmodule or inline depending on the ordering of async functions in `rollup/commonjs`. Specifically, `@babel/types/lib/definitions/core.js` is cyclic (i.e. transitively depends upon itself), but sometimes `@babel/helper-string-parser/lib/index.js` is emitted before this is realized.


A relatively straightforward patch is to wrap all modules (see rollup/plugins#1425 (comment))
@react-sizebot
Copy link

Comparing: 143d3e1...52aeda5

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.js = 6.68 kB 6.68 kB = 1.83 kB 1.83 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 527.72 kB 527.72 kB = 93.07 kB 93.07 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.69 kB 6.69 kB = 1.83 kB 1.83 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js = 633.34 kB 633.34 kB = 111.25 kB 111.25 kB
facebook-www/ReactDOM-prod.classic.js = 671.13 kB 671.13 kB = 117.70 kB 117.70 kB
facebook-www/ReactDOM-prod.modern.js = 661.41 kB 661.41 kB = 116.14 kB 116.14 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable-semver/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.production.js +1.79% 1,966.69 kB 2,001.92 kB +0.90% 297.91 kB 300.58 kB
oss-stable/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.production.js +1.79% 1,966.69 kB 2,001.92 kB +0.90% 297.91 kB 300.58 kB
oss-experimental/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.production.js +1.79% 1,966.87 kB 2,002.10 kB +0.90% 297.94 kB 300.61 kB
oss-stable-semver/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.development.js +1.79% 1,971.27 kB 2,006.51 kB +0.92% 298.81 kB 301.55 kB
oss-stable/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.development.js +1.79% 1,971.27 kB 2,006.51 kB +0.92% 298.81 kB 301.55 kB
oss-experimental/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.development.js +1.79% 1,971.45 kB 2,006.69 kB +0.92% 298.84 kB 301.58 kB
oss-experimental/react-markup/cjs/react-markup.react-server.development.js = 537.01 kB 535.52 kB = 96.21 kB 95.97 kB
oss-experimental/react-markup/cjs/react-markup.development.js = 362.08 kB 360.60 kB = 64.98 kB 64.73 kB
oss-experimental/react-markup/cjs/react-markup.react-server.production.js = 320.33 kB 318.83 kB = 59.73 kB 59.54 kB
oss-experimental/react-markup/cjs/react-markup.production.js = 219.88 kB 218.38 kB = 40.48 kB 40.29 kB
facebook-www/ReactDOMServerStreaming-dev.modern.js = 369.48 kB 366.95 kB = 66.42 kB 65.95 kB
oss-experimental/react-dom/cjs/react-dom-server-legacy.browser.development.js = 392.11 kB 389.33 kB = 69.51 kB 69.04 kB
oss-experimental/react-dom/cjs/react-dom-server-legacy.node.development.js = 392.11 kB 389.33 kB = 69.51 kB 69.04 kB
oss-experimental/react-dom/cjs/react-dom-server.edge.development.js = 418.51 kB 415.50 kB = 72.75 kB 72.18 kB
oss-experimental/react-dom/cjs/react-dom-server.browser.development.js = 417.50 kB 414.49 kB = 72.54 kB 71.97 kB
oss-experimental/react-dom/cjs/react-dom-server.node.development.js = 413.42 kB 410.41 kB = 71.92 kB 71.41 kB
facebook-www/ReactDOMServer-dev.classic.js = 381.64 kB 378.87 kB = 68.29 kB 67.81 kB
facebook-www/ReactDOMServer-dev.modern.js = 378.19 kB 375.41 kB = 67.76 kB 67.28 kB
oss-experimental/react-dom/cjs/react-dom-server.bun.development.js = 350.01 kB 347.41 kB = 66.45 kB 65.97 kB
oss-stable/react-dom/cjs/react-dom-server-legacy.browser.development.js = 365.44 kB 362.37 kB = 66.27 kB 65.77 kB
oss-stable/react-dom/cjs/react-dom-server-legacy.node.development.js = 365.43 kB 362.37 kB = 66.27 kB 65.77 kB
oss-stable-semver/react-dom/cjs/react-dom-server-legacy.browser.development.js = 365.41 kB 362.34 kB = 66.24 kB 65.74 kB
oss-stable-semver/react-dom/cjs/react-dom-server-legacy.node.development.js = 365.41 kB 362.34 kB = 66.24 kB 65.74 kB
oss-stable/react-dom/cjs/react-dom-server.node.development.js = 378.07 kB 374.81 kB = 67.93 kB 67.40 kB
oss-stable-semver/react-dom/cjs/react-dom-server.node.development.js = 377.99 kB 374.73 kB = 67.87 kB 67.35 kB
oss-stable/react-dom/cjs/react-dom-server.bun.development.js = 325.33 kB 322.50 kB = 63.20 kB 62.68 kB
oss-stable-semver/react-dom/cjs/react-dom-server.bun.development.js = 325.25 kB 322.43 kB = 63.17 kB 62.65 kB
oss-stable/react-dom/cjs/react-dom-server.edge.development.js = 382.39 kB 379.03 kB = 68.71 kB 68.17 kB
oss-stable-semver/react-dom/cjs/react-dom-server.edge.development.js = 382.32 kB 378.96 kB = 68.66 kB 68.12 kB
oss-stable/react-dom/cjs/react-dom-server.browser.development.js = 381.61 kB 378.25 kB = 68.57 kB 68.02 kB
oss-stable-semver/react-dom/cjs/react-dom-server.browser.development.js = 381.54 kB 378.18 kB = 68.52 kB 67.97 kB
oss-experimental/react-dom/cjs/react-dom-server.edge.production.js = 266.42 kB 263.89 kB = 47.21 kB 46.73 kB
oss-experimental/react-dom/cjs/react-dom-server.browser.production.js = 260.47 kB 257.94 kB = 45.07 kB 44.60 kB
oss-experimental/react-dom/cjs/react-dom-server.node.production.js = 262.34 kB 259.74 kB = 46.20 kB 45.75 kB
oss-experimental/react-dom/cjs/react-dom-server.bun.production.js = 238.57 kB 235.99 kB = 42.82 kB 42.42 kB
oss-experimental/react-dom/cjs/react-dom-server-legacy.node.production.js = 238.03 kB 235.45 kB = 43.42 kB 43.02 kB
oss-experimental/react-dom/cjs/react-dom-server-legacy.browser.production.js = 232.95 kB 230.37 kB = 41.51 kB 41.11 kB
facebook-www/ReactDOMServer-prod.classic.js = 224.87 kB 222.29 kB = 40.28 kB 39.88 kB
facebook-www/ReactDOMServer-prod.modern.js = 222.18 kB 219.61 kB = 39.96 kB 39.54 kB
oss-stable/react-dom/cjs/react-dom-server.edge.production.js = 238.24 kB 235.47 kB = 43.65 kB 43.15 kB
oss-stable-semver/react-dom/cjs/react-dom-server.edge.production.js = 238.16 kB 235.39 kB = 43.62 kB 43.12 kB
facebook-www/ReactDOMServerStreaming-prod.modern.js = 226.44 kB 223.80 kB = 41.53 kB 41.11 kB
oss-stable/react-dom/cjs/react-dom-server.node.production.js = 234.80 kB 232.01 kB = 42.66 kB 42.17 kB
oss-stable-semver/react-dom/cjs/react-dom-server.node.production.js = 234.72 kB 231.93 kB = 42.63 kB 42.15 kB
oss-stable/react-dom/cjs/react-dom-server.browser.production.js = 233.03 kB 230.26 kB = 41.71 kB 41.19 kB
oss-stable-semver/react-dom/cjs/react-dom-server.browser.production.js = 232.96 kB 230.19 kB = 41.69 kB 41.17 kB
oss-stable/react-dom/cjs/react-dom-server-legacy.node.production.js = 218.49 kB 215.69 kB = 40.65 kB 40.21 kB
oss-stable-semver/react-dom/cjs/react-dom-server-legacy.node.production.js = 218.47 kB 215.67 kB = 40.63 kB 40.19 kB
oss-stable/react-dom/cjs/react-dom-server-legacy.browser.production.js = 213.98 kB 211.18 kB = 38.89 kB 38.46 kB
oss-stable-semver/react-dom/cjs/react-dom-server-legacy.browser.production.js = 213.95 kB 211.15 kB = 38.87 kB 38.43 kB
oss-stable/react-dom/cjs/react-dom-server.bun.production.js = 218.27 kB 215.41 kB = 40.08 kB 39.64 kB
oss-stable-semver/react-dom/cjs/react-dom-server.bun.production.js = 218.19 kB 215.34 kB = 40.05 kB 39.61 kB

Generated by 🚫 dangerJS against 52aeda5

@mofeiZ mofeiZ requested review from Copilot and poteto April 25, 2025 18:05
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR wraps all CommonJS modules with a stricter configuration to mitigate non-deterministic builds for eslint-plugin-react-hooks.

  • Updated the commonjs plugin invocation to include {strictRequires: true} when bundle.tsconfig exists
  • Added an inline comment with a reference to the relevant GitHub issue for context
Comments suppressed due to low confidence (1)

scripts/rollup/build.js:397

  • Ensure that the 'strictRequires: true' configuration is fully supported by the current version of @rollup/commonjs and has been tested under all expected module ordering scenarios, given its impact on bundling behavior.
bundle.tsconfig != null ? commonjs({strictRequires: true}) : false,

Copy link
Member

@poteto poteto left a comment

Choose a reason for hiding this comment

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

Nice find!

@mofeiZ mofeiZ merged commit 0c28a09 into main Apr 25, 2025
245 checks passed
github-actions bot pushed a commit that referenced this pull request Apr 25, 2025
…33026)

See rollup/plugins#1425

Currently, `@babel/helper-string-parser/lib/index.js` is either emitted
as a wrapped esmodule or inline depending on the ordering of async
functions in `rollup/commonjs`. Specifically,
`@babel/types/lib/definitions/core.js` is cyclic (i.e. transitively
depends upon itself), but sometimes
`@babel/helper-string-parser/lib/index.js` is emitted before this is
realized.

A relatively straightforward patch is to wrap all modules (see
rollup/plugins#1425 (comment)).
This only regresses `eslint-plugin-react-hooks` bundle size by ~1.8% and
is safer (see
https://github.com/rollup/plugins/blob/master/packages/commonjs/README.md#strictrequires)

> The default value of true will wrap all CommonJS files in functions
which are executed when they are required for the first time, preserving
NodeJS semantics. This is the safest setting and should be used if the
generated code does not work correctly with "auto". Note that
strictRequires: true can have a small impact on the size and performance
of generated code, but less so if the code is minified.

(note that we're on an earlier version of `@rollup/commonjs` which does
not default to `strictRequires: true`)

DiffTrain build for [0c28a09](0c28a09)
github-actions bot pushed a commit to code/lib-react that referenced this pull request Apr 25, 2025
…acebook#33026)

See rollup/plugins#1425

Currently, `@babel/helper-string-parser/lib/index.js` is either emitted
as a wrapped esmodule or inline depending on the ordering of async
functions in `rollup/commonjs`. Specifically,
`@babel/types/lib/definitions/core.js` is cyclic (i.e. transitively
depends upon itself), but sometimes
`@babel/helper-string-parser/lib/index.js` is emitted before this is
realized.

A relatively straightforward patch is to wrap all modules (see
rollup/plugins#1425 (comment)).
This only regresses `eslint-plugin-react-hooks` bundle size by ~1.8% and
is safer (see
https://github.com/rollup/plugins/blob/master/packages/commonjs/README.md#strictrequires)

> The default value of true will wrap all CommonJS files in functions
which are executed when they are required for the first time, preserving
NodeJS semantics. This is the safest setting and should be used if the
generated code does not work correctly with "auto". Note that
strictRequires: true can have a small impact on the size and performance
of generated code, but less so if the code is minified.

(note that we're on an earlier version of `@rollup/commonjs` which does
not default to `strictRequires: true`)

DiffTrain build for [0c28a09](facebook@0c28a09)
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.

4 participants