Skip to content
New issue

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

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

Already on GitHub? # to your account

Bundling Atrament with vite shows warning: #103

Closed
ak37165 opened this issue Jun 26, 2024 · 5 comments
Closed

Bundling Atrament with vite shows warning: #103

ak37165 opened this issue Jun 26, 2024 · 5 comments
Labels

Comments

@ak37165
Copy link

ak37165 commented Jun 26, 2024

I am using atrament in a client side project bundled using vite. It shows warning
Module "worker_threads" has been externalized for browser compatibility. Cannot access "worker_threads.Worker" in client code

VITE documentation for the warning is here: https://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility

I am not sure I understand fully but looks like some Node.js module expected to be used only on the server side is being used?

@jakubfiala
Copy link
Owner

@ak37165 thanks for the report! I suspect it's to do with the Rollup plugin for Web Workers: https://github.com/darionco/rollup-plugin-web-worker-loader/blob/master/src/helper/node/WorkerClass.js

it's technically not importing worker_threads but the code to import it does exist in the bundle, which is probably why Vite is complaining.

I'll try to find a way to eliminate the warning, it would actually be pretty nice if this code never entered the bundle. Does fill mode work in your application?

@jakubfiala
Copy link
Owner

I'm seriously considering splitting out Fill Mode into a separate package and letting the developer create their own Worker with it. Firstly, there's probably lots of apps that don't require it, and secondly, bundling it has been causing issues all the time 😬

@ak37165
Copy link
Author

ak37165 commented Jun 27, 2024

I am not using fill mode (and have not tried it yet). Using atrament for the smooth drawing and that works great!

Separating out seems like a good design choice. Many apps already use a worker and can integrate with that if they need to use fill mode.

@jakubfiala
Copy link
Owner

@ak37165 this should now be fixed in v4.4.1. I'm going to close the issue as the culprit code clearly isn't present in the dist bundles but please do reopen if the issue persists in the new version.

@ak37165
Copy link
Author

ak37165 commented Jun 27, 2024

Thanks for the fast fix! The warning does not show up anymore.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants