Skip to content

Commit 094f979

Browse files
committed
Add a workaround for a Yarn v1 bug
We cannot use `process-polyfill` as the package name due to a bug in Yarn v1. The errors results in a dependency conflict with `node-stdlib-browser` which fails to import `process/browser.js`. yarnpkg/yarn#6907
1 parent 127d414 commit 094f979

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
"@rollup/plugin-inject": "^5.0.3",
7474
"buffer-polyfill": "npm:buffer@^6.0.3",
7575
"node-stdlib-browser": "^1.2.0",
76-
"process-polyfill": "npm:process@^0.11.10"
76+
"process": "^0.11.10"
7777
},
7878
"peerDependencies": {
7979
"vite": "^2.0.0 || ^3.0.0 || ^4.0.0"

pnpm-lock.yaml

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

shims/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
const global = globalThis || this || self
22

33
export { Buffer } from 'buffer-polyfill'
4-
export { default as process } from 'process-polyfill'
4+
// We cannot use `process-polyfill` as the package name due to a bug in Yarn v1. The errors results in a dependency
5+
// conflict with `node-stdlib-browser` which fails to import `process/browser.js`.
6+
// https://github.com/yarnpkg/yarn/issues/6907
7+
export { default as process } from 'process'
58
export { global }

src/index.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,6 @@ export const nodePolyfills = (options: PolyfillOptions = {}): Plugin => {
133133
if (isDevEnabled(optionsResolved.globals.Buffer) && /^(?:node:)?buffer$/.test(name)) {
134134
return require.resolve('buffer-polyfill')
135135
}
136-
137-
if (isDevEnabled(optionsResolved.globals.process) && /^(?:node:)?process$/.test(name)) {
138-
return require.resolve('process-polyfill')
139-
}
140136
}
141137

142138
return {

0 commit comments

Comments
 (0)