PlasmoHQ / plasmo

🧩 The Browser Extension Framework
https://www.plasmo.com
MIT License
10.59k stars 369 forks source link

[BUG] "TypeError: Failed to fetch" when package tries loading file via fetch(url) #1059

Open andithemudkip opened 2 months ago

andithemudkip commented 2 months ago

What happened?

plasmo isn't bundling some files used by third party packages when calling the init function of tlsn-js, it tries to load a .wasm file by doing

// ./node_modules/tlsn-js/wasm/pkg/tlsn-wasm.js
input = new URL('tlsn_wasm_bg.wasm', import.meta.url);
// ...
input = fetch(input);

but it seems that this wasm file isn't being bundled by plasmo so that fetch fails image image

I've set up a minimal example in this repo

Version

Latest

What OS are you seeing the problem on?

Windows, Linux

What browsers are you seeing the problem on?

Chrome

Relevant log output

No response

(OPTIONAL) Contribution

Code of Conduct

sleekslush commented 2 months ago

Put the paths to the files you need embedded in your extension into the web_accessible_resources key of your package.json (see the mv3 manifest definition for more details). If you include them here, plasmo will bundle the assets and you can then access them from your code.