davidmyersdev / vite-plugin-node-polyfills

A Vite plugin to polyfill Node's Core Modules for browser environments.
MIT License
263 stars 17 forks source link

Fix globals are always defined #91

Closed Ilyat1337 closed 1 month ago

Ilyat1337 commented 2 months ago

Fixes #86

Ilyat1337 commented 1 month ago

@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.

davidmyersdev commented 1 month ago

@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.