extension-js / extension.js

🧩 Plug-and-play, zero-config, cross-browser extension development tool.
https://extension.js.org
MIT License
3.67k stars 93 forks source link

Can't load "content_scripts/content-0.js" ,Because it's not UTF-8 encoded #94

Closed John-Chan closed 3 months ago

John-Chan commented 3 months ago
image

Create a project via :

 npx extension create my-extension --template=vue-typescript

and run npm run start

cezaraugusto commented 3 months ago

hi @John-Chan thanks for reporting.

Could you try running the React-TypeScript template to see if thee bug happens as well? I'm looking to know if the issue is template-specific.

npx extension create my-extension --template=vue-typescript
John-Chan commented 3 months ago

The React-TypeScript template cannot run due to icon path issues( #87), and it's uncertain whether there is an issue with UTF-8 encoding.

npx extension create my-extension-react --template=react-typescript
image
OSpoon commented 3 months ago

I suspect that the output.cssHeadDataCompression option in webpack@5.91.0 enabled in the production environment caused content-0.js to contain an unrecognizable character. I attempted to disable the output.cssHeadDataCompression option to avoid this issue. I also found a change in webpack@5.92.0, where the latest version will no longer have unrecognizable characters.

webpack@5.92.0 https://github.com/webpack/webpack/blob/34e2561addb0f65a7a6fb0ce7ae1aea4cd1d599f/lib/css/CssLoadingRuntimeModule.js#L227

Run npm run start

webpack@5.91.0

image

webpack@5.92.0

image

@cezaraugusto,I'm not quite sure about the purpose of the output.cssHeadDataCompression option being enabled. I think upgrading the webpack version would be more appropriate. Could you verify that?

cezaraugusto commented 3 months ago

@OSpoon thanks for investigating! Did updating webpack solved the issue? I'm not able to reproduce

OSpoon commented 3 months ago

5 91 0

@cezaraugusto, I reproduced this issue using the code of the main branch. For this inssus, I tried two solutions:

  1. To disable the output.cssHeadDataCompression option. cssHeadDataCompression false

  2. Upgrade webpack to the latest version. 5 92 0

cezaraugusto commented 3 months ago

thanks @OSpoon, PR opened to bump webpack

cezaraugusto commented 3 months ago

@John-Chan could you please try again? I just released v1.8.0 which should fix it.

npx extension@latest start my-extension --template=vue-typescript
Screenshot 2024-06-19 at 16 41 26

Also please note that start will bundle your extension in production mode without live-reload support. For development you want to run the dev command.

Let me know if that works for you so we can close this one. Thanks!

John-Chan commented 3 months ago

Compared to before, vue templates no longer pop up utf8 encoding errors, but the project still can't start successfully because of the icon path problem. Maybe we need to wait for the icon path issue to be resolved and try again.

cezaraugusto commented 3 months ago

@John-Chan @OSpoon happy to share that this bug is finally fixed.

# Ensure you run @latest as npx cache system can trick you are not
npx extension@latest create my-extension --template=vue-typescript

If I'm wrong, let me know!

John-Chan commented 3 months ago

The ICON path issue still exists, manually copying the file to the dist/chrome/icons path works. So the utf8 encoding issue should be fixed.

image
OSpoon commented 3 months ago

hi @cezaraugusto, webpack-run-edge-extension, webpack-run-chrome-extension and webpack-browser-extension-manifest were last updated 12 days ago, Do you need to release the latest version?

cezaraugusto commented 3 months ago

@OSpoon just bumped all three versions but can't repro the bug yet. do you?

Screenshot 2024-07-02 at 22 16 57
OSpoon commented 3 months ago

@cezaraugusto, I don't see the new version of webpack-browser-extension-manifest

cezaraugusto commented 3 months ago

Oops my bad, released now

Screenshot 2024-07-03 at 08 40 41
OSpoon commented 3 months ago

@cezaraugusto Regarding the problem of the path in the win environment, I have verified it, and please @John-chan can try again in his free time, thank you very much ~

John-Chan commented 3 months ago

@cezaraugusto Regarding the problem of the path in the win environment, I have verified it, and please @John-Chan can try again in his free time, thank you very much ~

Great! It's works

cezaraugusto commented 3 months ago

thanks for confirming @John-Chan! feel free to report anything else you find weird.

@OSpoon thanks for digging into it! 💯

Closing as fixed 🎉