Parcel: Web worker inside npm package built with parcel

Created on 4 Jan 2020  路  3Comments  路  Source: parcel-bundler/parcel

Hey how I can embed web workers inside a npm package. The problem Im facing is when I import my npm package for a demo it is trying to dowload the web worker from the public path of the dev server which does not exists

Question

Most helpful comment

This is the place in my npm library I'm using worker and it gets bundled in the dist

Screenshot 2020-01-05 at 4 57 19 PM

but when I use it in another parcel project by installing my library(with worker) it says it cannot find __worker.js__ in my new project
Screenshot 2020-01-05 at 4 57 47 PM

All 3 comments

Parcel will automatically parse new Worker("./myworker.js") calls, both inside and outside of node_modules.
Please provide a concrete code example if you need more help.

This is the place in my npm library I'm using worker and it gets bundled in the dist

Screenshot 2020-01-05 at 4 57 19 PM

but when I use it in another parcel project by installing my library(with worker) it says it cannot find __worker.js__ in my new project
Screenshot 2020-01-05 at 4 57 47 PM

Same

Was this page helpful?
0 / 5 - 0 ratings