With Vite 5, browserField is removed, requiring "browser" to be included in the config resolve.mainFields to ensure correct resolving of browser exports.
The default value for this field includes "browser", but this plugin incorrectly overrides the default with a value which does not include it.
The result is that upgrading to Vite 5 and v3 of this plugin causes node build conditions to be imported, and errors when those builds contain imports to node builtins.
error during build:
RollupError: "TextEncoder" is not exported by "__vite-browser-external", imported by "node_modules/axios/lib/helpers/formDataToStream.js".
at error (/home/projects/vitejs-vite-tvsiq8/node_modules/rollup/dist/es/shared/parseAst.js:469:30)
at error (/home/projects/vitejs-vite-tvsiq8/node_modules/rollup/dist/es/shared/node-entry.js:12753:29)
at traceVariable (/home/projects/vitejs-vite-tvsiq8/node_modules/rollup/dist/es/shared/node-entry.js:13194:29)
at findVariable (/home/projects/vitejs-vite-tvsiq8/node_modules/rollup/dist/es/shared/node-entry.js:11607:39)
at bind (/home/projects/vitejs-vite-tvsiq8/node_modules/rollup/dist/es/shared/node-entry.js:7209:40)
at bind (/home/projects/vitejs-vite-tvsiq8/node_modules/rollup/dist/es/shared/node-entry.js:4650:23)
at bind (/home/projects/vitejs-vite-tvsiq8/node_modules/rollup/dist/es/shared/node-entry.js:4650:23)
at bind (/home/projects/vitejs-vite-tvsiq8/node_modules/rollup/dist/es/shared/node-entry.js:4646:32)
at bind (/home/projects/vitejs-vite-tvsiq8/node_modules/rollup/dist/es/shared/node-entry.js:4646:32)
at bindReferences (/home/projects/vitejs-vite-tvsiq8/node_modules/rollup/dist/es/shared/node-entry.js:12749:18)
at sortModules (/home/projects/vitejs-vite-tvsiq8/node_modules/rollup/dist/es/shared/node-entry.js:18910:20)
at build (/home/projects/vitejs-vite-tvsiq8/node_modules/rollup/dist/es/shared/node-entry.js:18815:14)
Describe the bug
With Vite 5,
browserField
is removed, requiring"browser"
to be included in the configresolve.mainFields
to ensure correct resolving of browser exports.The default value for this field includes
"browser"
, but this plugin incorrectly overrides the default with a value which does not include it.The result is that upgrading to Vite 5 and v3 of this plugin causes node build conditions to be imported, and errors when those builds contain imports to node builtins.
Reproduction URL
https://stackblitz.com/edit/vitejs-vite-tvsiq8?file=.vscode%2Fextensions.json
Reproduction
npm run build
Logs
System Info