"Module not found" when building a fresh project that utilises a worker
🍋Fresh
Hey Everyone! Currently, I am facing an issue regarding workers in fresh. I have set up a module-type worker as specified in the documentation at https://docs.deno.com/examples/web_workers/ in the main.ts file of my fresh version 2.3.3 project (deno version 2.7.14). The only difference to the documentation is that I have my worker located in a ./workers sub-directory and not directly at the project root (for example, at ./worker.ts). When I go ahead and build the project via "vite build", I see that the workers directory and the worker itself is not available in the build directory _fresh. This understandably leads to a Module not found error pointing to the missing worker file when starting the project using deno serve. Interestingly, when executing deno task dev/vite by itself, everything works as expected. I also tried to just copy the worker file to the correct directory during the build. While this resolved the module not found error, this seemed to break the worker as messages did not seem to be correctly exchanged between the worker itself and the main thread (messages were just undefined). Although I could be wrong there as I did not go that deep into troubleshooting this.
Therefore, I would like to know why vite does not seem to include the worker during the build. I was and I still am under the impression that vite should be able to handle this automatically.
Thanks in advance for the support! If required, I will gladly provide further information to this issue!
Continue the conversation
Join the Discord to ask follow-up questions and connect with the community
D
Deno
Chat about Deno, a modern runtime for JavaScript and TypeScript.