vite-plugin-node-polyfills icon indicating copy to clipboard operation
vite-plugin-node-polyfills copied to clipboard

Fix globals are always defined

Open Ilyat1337 opened this issue 1 year ago • 1 comments

Fixes #86

Ilyat1337 avatar Apr 28 '24 17:04 Ilyat1337

@davidmyersdev I've fixed linter errors. The only remaining error is in e2e test (examples/vanilla). I'm not sure how to fix it correctly. In this test you've configured the plugin to define process only in build mode, but test expects it to be defined in both modes (lines 51 for process and 52 for process.env).

https://github.com/davidmyersdev/vite-plugin-node-polyfills/blob/29e3c8256011e02434283919374d0f0beab9c05b/examples/vanilla/vite.config.ts#L12-L14

https://github.com/davidmyersdev/vite-plugin-node-polyfills/blob/29e3c8256011e02434283919374d0f0beab9c05b/examples/vanilla/test/e2e/main.spec.ts#L43-L60

Currently, test:e2e:build runs without errors, while test:e2e:dev fails with process is not defined error, which is the expected behaviour in my opinion.

Ilyat1337 avatar May 14 '24 17:05 Ilyat1337

@Ilyat1337 It looks like that error is actually being raised by the fs module due to its reliance on process. I'll have to split those tests up.

davidmyersdev avatar May 19 '24 16:05 davidmyersdev