Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when using with Vite #13

Open
secondl1ght opened this issue Jul 28, 2023 · 9 comments
Open

Error when using with Vite #13

secondl1ght opened this issue Jul 28, 2023 · 9 comments
Labels
bug Something isn't working

Comments

@secondl1ght
Copy link

When using with Vite I am getting the following error: The injected path "/node_modules/esbuild-plugin-polyfill-node/polyfills/__dirname.js" cannot be marked as external. Is there some extra config I need to do here?

@cyco130
Copy link
Owner

cyco130 commented Jul 30, 2023

It’s an ESBuild plugin. In what way are you using it with Vite?

@robertsLando
Copy link

Got the same error... I switched to this as suggested here: https://github.com/remorses/esbuild-plugins#plugins

@cyco130
Copy link
Owner

cyco130 commented Aug 1, 2023

Can I get a reproduction?

@robertsLando
Copy link

robertsLando commented Aug 1, 2023

Here: https://github.com/mqttjs/MQTT.js/blob/main/examples/vite-example/vite.config.js

Just replace @esbuild-plugins/node-globals-polyfill with esbuild-plugin-polyfill-node

@secondl1ght
Copy link
Author

Vite uses ESBuild (and Rollup) so you are able to use ESBuild plugins like this one. https://vitejs.dev/config/shared-options.html#esbuild

@cyco130
Copy link
Owner

cyco130 commented Aug 1, 2023

Got it. This is not a usage I have considered before. I'll have a look.

@cyco130 cyco130 added the bug Something isn't working label Aug 5, 2023
@okular
Copy link

okular commented Aug 12, 2023

@robertsLando how did you resolve this issue, i have been dealing with a very annoying issue that is similar to the one you had

@robertsLando
Copy link

I used the other package

mofojed added a commit to mofojed/vite-project that referenced this issue Aug 15, 2023
- Getting an error, same as cyco130/esbuild-plugin-polyfill-node#13:
```
Error:   Failed to scan for dependencies from entries:
  /home/bender/dev/deephaven/tmp/react-hook-explore/vite-project/index.html

  ✘ [ERROR] The injected path "/home/bender/dev/deephaven/tmp/react-hook-explore/vite-project/node_modules/esbuild-plugin-polyfill-node/polyfills/buffer.js" cannot be marked as external

✘ [ERROR] The injected path "/home/bender/dev/deephaven/tmp/react-hook-explore/vite-project/node_modules/esbuild-plugin-polyfill-node/polyfills/process.js" cannot be marked as external

✘ [ERROR] The injected path "/home/bender/dev/deephaven/tmp/react-hook-explore/vite-project/node_modules/esbuild-plugin-polyfill-node/polyfills/__dirname.js" cannot be marked as external
```
mofojed added a commit to mofojed/web-client-ui that referenced this issue Aug 22, 2023
- Error is `[ERROR] The injected path "/home/bender/dev/deephaven/iris-oss/web-client-ui/main/node_modules/esbuild-plugin-polyfill-node/polyfills/buffer.js" cannot be marked as external`
- Same as another issue described here: cyco130/esbuild-plugin-polyfill-node#13
- Will try the other package once again: https://github.com/remorses/esbuild-plugins
@mdiflorio
Copy link

For anyone in the same situation as I was. There seems to be an issue with the way Vite loads esbuild plugins and isn't related to this package.

An alternative is to use vite-plugin-node-polyfills and in my case I had to installed next-tick as well.

Loading it into my main.tsx file like so:

// Polyfill for @azure/service-bus as vite-plugin-node-polyfills doesn't include it
import nextTick from 'next-tick';
process.nextTick = nextTick;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants