If I manually patch for #8, I still hit a number of issues that prevent this plugin from working with vite's dev server. I'm not sure where the underlying causes sit, so I'm outlining the issues here to start.
In the examples below, I'm working with a tiny test ("tt") module that contains just a single js file that references global.
(2) There is no actual node_modules/polyfill-nodeglobal.js file on my disk, but without this exclude, I get a circular reference in the global polyfill. That is, "http://localhost:3000/@id/__x00__polyfill-node:global.js" has content like:
import { default as global } from '/@id/__x00__polyfill-node:global.js';
export default (typeof global !== "undefined" ? global :
typeof self !== "undefined" ? self :
typeof window !== "undefined" ? window : {});
(3) In the transformed content generated by this plugin, map.sources is populated with a value like sources: [ '../tt/index.js', 'dep:tt' ]. I'm not sure what the dep: array entry indicates, but the vite dev server crashes on this when it tries to find a filesystem entry named dep:tt.
If I manually patch for #8, I still hit a number of issues that prevent this plugin from working with vite's dev server. I'm not sure where the underlying causes sit, so I'm outlining the issues here to start.
In the examples below, I'm working with a tiny test ("tt") module that contains just a single js file that references
global
.(1) In the dev server, requests come for files like "http://localhost:3000/node_modules/.vite/tt.js?v=75d8e834" -- and the
?v=
parameter prevents the standardnode_modules/**/*.js
from matching these requests.(2) There is no actual
node_modules/polyfill-nodeglobal.js
file on my disk, but without thisexclude
, I get a circular reference in the global polyfill. That is, "http://localhost:3000/@id/__x00__polyfill-node:global.js" has content like:(3) In the transformed content generated by this plugin,
map.sources
is populated with a value likesources: [ '../tt/index.js', 'dep:tt' ]
. I'm not sure what thedep:
array entry indicates, but the vite dev server crashes on this when it tries to find a filesystem entry nameddep:tt
.