You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When extracting the base name of a module from its module ID, @rollup/plugin-commonjs does not correctly normalize paths with separators that are not path.sep. This happens with some custom resolvers (e.g. Vite.js) which generate module IDs with forward slashes on Windows.
For example, if the module ID is C:/Users/Phil/Documents/GitHub/test-vite-app/node_modules/react/index.js, the plugin generates code like this on Windows:
This is undesireable because (1) it leaks the absolute path of the development machine into the bundle, and (2) it generates bundles with different hashes on different machines, hurting reproducible builds.
This is caused by getName(), which is used to extract the base name of a module:
Vite currently has a bug that causes it to generate different bundles on
Windows and Linux. This is caused by a fault in @rollup/plugin-commonjs
which is bundled into Vite.
We directly fix the fault in our `node_modules/` using patch-package.
Let's hope the Rollup devs accept my PR and the fix is integrated into
Vite.
More links:
- Bug reports:
- vitejs/vite#2623
- rollup/plugins#923
- Related pull requests:
- rollup/plugins#924
Vite currently has a bug that causes it to generate different bundles on
Windows and Linux. This is caused by a fault in @rollup/plugin-commonjs
which is bundled into Vite.
We directly fix the fault in our `node_modules/` using patch-package.
Let's hope the Rollup devs accept my PR and the fix is integrated into
Vite.
More links:
- Bug reports:
- vitejs/vite#2623
- rollup/plugins#923
- Related pull requests:
- rollup/plugins#924
When extracting the base name of a module from its module ID, @rollup/plugin-commonjs does not correctly normalize paths with separators that are not
path.sep
. This happens with some custom resolvers (e.g. Vite.js) which generate module IDs with forward slashes on Windows.For example, if the module ID is
C:/Users/Phil/Documents/GitHub/test-vite-app/node_modules/react/index.js
, the plugin generates code like this on Windows:This is undesireable because (1) it leaks the absolute path of the development machine into the bundle, and (2) it generates bundles with different hashes on different machines, hurting reproducible builds.
This is caused by
getName()
, which is used to extract the base name of a module:plugins/packages/commonjs/src/utils.js
Lines 25 to 32 in 6867290
Here, it uses
path.sep
to split the module ID. Sincesep
is\
on Windows, it fails to split paths that use/
.Since
basename()
anddirname()
can handle both forward and backward slashes, I suggest that we replace lines 30-31 with:See related investigation at vitejs/vite#2623 (comment)
The text was updated successfully, but these errors were encountered: