Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR: No loader is configured for ".wasm" files #3114

Closed
yhmjSky opened this issue May 10, 2023 · 2 comments
Closed

ERROR: No loader is configured for ".wasm" files #3114

yhmjSky opened this issue May 10, 2023 · 2 comments

Comments

@yhmjSky
Copy link

yhmjSky commented May 10, 2023

When I build a cloudflare page's demo (sveltekit), throw error following:

node_modules/.pnpm/@dqbd+tiktoken@1.0.7/node_modules/@dqbd/tiktoken/tiktoken.js:1:22: ERROR: No loader is configured for ".wasm" files: node_modules/.pnpm/@dqbd+tiktoken@1.0.7/node_modules/@dqbd/tiktoken/tiktoken_bg.wasm
    at failureErrorWithLog (D:\WebStormProjects\somedemo2\my-app\node_modules\.pnpm\esbuild@0.17.18\node_modules\esbuild\lib\main.js:1636:15)
    at D:\WebStormProjects\somedemo2\my-app\node_modules\.pnpm\esbuild@0.17.18\node_modules\esbuild\lib\main.js:1048:25
    at D:\WebStormProjects\somedemo2\my-app\node_modules\.pnpm\esbuild@0.17.18\node_modules\esbuild\lib\main.js:993:52
    at buildResponseToResult (D:\WebStormProjects\somedemo2\my-app\node_modules\.pnpm\esbuild@0.17.18\node_modules\esbuild\lib\main.js:1046:7)
    at D:\WebStormProjects\somedemo2\my-app\node_modules\.pnpm\esbuild@0.17.18\node_modules\esbuild\lib\main.js:1075:16
    at responseCallbacks.<computed> (D:\WebStormProjects\somedemo2\my-app\node_modules\.pnpm\esbuild@0.17.18\node_modules\esbuild\lib\main.js:697:9)
    at handleIncomingPacket (D:\WebStormProjects\somedemo2\my-app\node_modules\.pnpm\esbuild@0.17.18\node_modules\esbuild\lib\main.js:752:9)
    at Socket.readFromStdout (D:\WebStormProjects\somedemo2\my-app\node_modules\.pnpm\esbuild@0.17.18\node_modules\esbuild\lib\main.js:673:7)
    at Socket.emit (node:events:513:28)
    at addChunk (node:internal/streams/readable:324:12)

If the wasm is inside my source file, I can build done. But, it It doesn't seem to can load from node_modules.
Do you have any ideas?

@hyrious
Copy link

hyrious commented May 10, 2023

If you're importing the wasm file through import binary from 'path/to/lib.wasm', then you can use the example WebAssembly plugin to load that.

If it was referenced via new URL('./lib.wasm', import.meta.url) or something like that, it is tracked in #795.

Note that even if the wasm file is not imported directly, you still have the ability to change that to direct import through plugins API. Here's a solution for another issue but it may also be helpful to you #3039 (comment)

@evanw
Copy link
Owner

evanw commented May 10, 2023

This intentionally isn't something that esbuild automatically does for you. Loading WebAssembly code involves external assets, and how to do that is case-dependent. You need to configure esbuild to tell it how you want it to do that (e.g. by using a plugin) depending on your use case.

I'm closing this issue because the fact that esbuild's default configuration generates the error No loader is configured for ".wasm" files when you import a .wasm file is not a bug with esbuild.

@evanw evanw closed this as not planned Won't fix, can't repro, duplicate, stale May 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants