Closed benjamine closed 1 month ago
uploading a zipped version of example project to help reproduce (used bun
as package manager, use bun i
and bun run dev
to test).
Hi @benjamine
Set up the exclude
option of the dev server.
devServer({
exclude: [/^\/src\/worker.ts/, ...defaultOptions.exclude], // <===
entry: 'src/index.tsx'
})
@yusukebe you're my hero! π that worked.
you probably already figured this out, but I'm guessing an official patch would be adding something like \/\?worker/
(catch both ?worker
and ?worker_file
), or just allow any querystring after .ts/.tsx files.
at https://github.com/honojs/vite-plugins/blob/ae8938828d3d37ca37cd790dd87bb34752f0294b/packages/dev-server/src/dev-server.ts#L50-L59
I'll keep it in my vite config for now π
εΏγγζθ¬γγ¦γγΎγγ
@benjamine
Good! Can we close this issue?
I'd suggest patching that regex list for any others trying to use web workers too, vite has a couple query strings like those.
(happy to make a separate PR for that if you think it makes sense)
Otherwise this can be closed π
I'd suggest patching that regex list for any others trying to use web workers too, vite has a couple query strings like those.
I think it's not necessary to modify vite-plugins/packages/dev-server/src/dev-server.ts
because users can change the value themselves. I made it an option for the purpose.
closed π,
ps: I'd still suggest maybe a mention in docs at least? or throw a more explicit error?
as this behavior would also confuse anyone else trying to use a web worker the way vite recommends.
PS: I'd still suggest maybe a mention in the docs at least or throwing a more explicit error.
There is a description of the exclude
option here currently:
https://github.com/honojs/vite-plugins/tree/main/packages/dev-server#exclude
But, as you did not realize, it is not friendly. Is it good to add this page? https://hono.dev/docs/getting-started/cloudflare-pages
I don't want to make it an error, but adding docs is good!
Steps to Reproduce:
/src/client.ts
add code loading aWorker
(according to vite docs) as:/src/worker.ts
:The worker never loads, as the server responds with a 404 when trying to load the worker module:
Note:
http://localhost:5173/src/worker.ts?worker_file&type=module
fails with 404http://localhost:5173/src/worker.ts
serves the source code successfullyimport
with?worker
also fails with a 404 in the same wayWorker
works fine in a vite react starter example.Dependencies: