visgl / loaders.gl

Loaders for big data visualization. Website:
https://loaders.gl
Other
704 stars 192 forks source link

[Bug] Warning during vite build: "spawn" is not exported by "__vite-browser-external" #3110

Open oscar-b opened 1 week ago

oscar-b commented 1 week ago

Loader

"@loaders.gl/core": "^4.2.5",

Description

vite v5.4.8 building for production...
node_modules/@loaders.gl/core/node_modules/@loaders.gl/worker-utils/dist/lib/process-utils/child-process-proxy.js (56:50): "spawn" is not exported by "__vite-browser-external", imported by "node_modules/@loaders.gl/core/node_modules/@loaders.gl/worker-utils/dist/lib/process-utils/child-process-proxy.js".
node_modules/@loaders.gl/worker-utils/dist/lib/process-utils/child-process-proxy.js (56:50): "spawn" is not exported by "__vite-browser-external", imported by "node_modules/@loaders.gl/worker-utils/dist/lib/process-utils/child-process-proxy.js".

Expected Behavior

No response

Steps to Reproduce

Compile project with Vite

Environment

Logs

No response

ibgreen commented 1 week ago

@oscar-b Thanks for reporting.

However without a repro this isn't really actionable (other than doing a speculative refactor of the worker-utils)

ibgreen commented 1 week ago

Also, does this actually break the build, or is it just a warning?

oscar-b commented 1 week ago

Also, does this actually break the build, or is it just a warning?

As far as I can see, it's only a warning. I don't know how I'd trigger the use of it though, or why it'd need spawn in the browser?

I will see if I can setup a minimal repo with test, but it being just a warning might also be part of the issue I guess :)

ibgreen commented 1 week ago

why it'd need spawn in the browser?

  • It doesn't.
  • A design goal of loaders.gl is to create a library that works seamlessly in both Node.js and browsers.
  • In some situation (workers in this case) that requires using different code paths.
  • Getting various bundlers and Node to handle that gracefully in all cases is quite tricky, requires iteration and testing.
  • Would cretainly love to remove this warning, but lots of higher priority work.
oscar-b commented 1 week ago

@ibgreen I see! Well it doesn't immediately seem to be causing issues, so this is most likely a quite harmless warning. I guess something like this could be used to filter out the warning if one would want to: https://vitejs.dev/config/shared-options.html#customlogger

prusswan commented 1 week ago

I have a related problem: trying to build a Custom Layer in iife format so it can be used in/with pydeck results in:

https://rollupjs.org/troubleshooting/#error-name-is-not-exported-by-module

Probably related: #2000

My branch if anyone is interested: https://github.com/prusswan/deck.gl-pmtiles/tree/overture