Closed IrvingArmenta closed 2 months ago
This can be easily corrected by adding a check to the options
param in the integration.js
file.
// patch for globalThis.Worker
if (options && options.ssr) {
source.appendLeft(0, `import "@astropub/worker/polyfill";`)
}
Even with this error fixed, the plugin doesn't move the worker files to the dist
directory, so the files are not available for the client to utilize.
It does appear that Astro will pick up the files required for the Worker and compile them, however, they don't seem to respect the build.assets
configuration and will be output to the dist/assets
directory regardless of configuration. I'll open an issue with Astro for this bug.
If all you want is to use workers on the client side, you don't need this integration, just add the worker to your code.
const worker = new Worker(
new URL('../workers/myWorker.ts', import.meta.url)
)
Can you publish this fix on npm?
Yes! Expect an update today.
Published as 0.2.0
I am getting an error when running
astro build
+astro preview
and it seems is related to this package.my astro config file:
Error message:
shortened some paths for privacy
Any other information I might be able to provide:
packages:
platform: Windows 11 node version:
v20.10.0