Skip to content
This repository has been archived by the owner on Jan 22, 2024. It is now read-only.

Use location.pathname in workerHelper.js instead of URL bundler logic #36

Closed
codeart1st opened this issue Jan 15, 2023 · 3 comments
Closed

Comments

@codeart1st
Copy link

Vite bundler not work with wasm-bindgen-rayon. It fails to build.

transforming (337) node_modules/@petamoriken/float16/src/_util/spec.mjsUnexpected early exit. This happens when Promises returned by plugins cannot resolve. Unfinished hook action(s) on exit:
(vite:worker-import-meta-url) transform "/home/foobar/wgpu-layers/demo/src/OffscreenTileLayer.js"
error during build:
Error: Unexpected early exit. This happens when Promises returned by plugins cannot resolve. Unfinished hook action(s) on exit:
(vite:worker-import-meta-url) transform "/home/foobar/wgpu-layers/demo/src/OffscreenTileLayer.js"
    at EventEmitter.handleEmptyEventLoop (file:///home/foobar/wgpu-layers/demo/node_modules/rollup/dist/es/shared/rollup.js:24061:20)
    at Object.onceWrapper (node:events:627:28)
    at EventEmitter.emit (node:events:525:35)
    at process.<anonymous> (file:///home/foobar/wgpu-layers/demo/node_modules/rollup/dist/es/shared/rollup.js:24055:55)
    at process.emit (node:events:513:28)

Probably it's a bug in vite, but I try to find a workaround for it. The problem seems to be the workerHelper.js

const worker = new Worker(new URL('./workerHelpers.js', import.meta.url), {
type: 'module'
});

It seems to be that vite don't like the recursive bundling part.

My workaround for now is the following:

const worker = new Worker(location.pathname);

This works pretty well. And should work for all environments instead of inlining worker code in the main bundle. This use case should not work anymore with this approach.

@codeart1st
Copy link
Author

Seems to be not a good solution. It breaks vite's dev mode and maybe webpack's too.

@RReverser
Copy link
Collaborator

RReverser commented Jan 15, 2023

Vite uses esbuild, right? If so, unfortunately that's a long-standing feature request on which I commented at some time but obviously couldn't affect its implementation progress otherwise. evanw/esbuild#312, progress here evanw/esbuild#2508

@codeart1st
Copy link
Author

Yeah, @esbuild is part of my node_modules folder. I will look into your linked esbuild issues. Ty 👍

p-rivero added a commit to p-rivero/protochess-engine that referenced this issue Feb 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants