extension.js icon indicating copy to clipboard operation
extension.js copied to clipboard

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

Open John-Chan opened this issue 1 year ago • 11 comments

image

Create a project via :

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

and run npm run start

John-Chan avatar Jun 13 '24 15:06 John-Chan

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

cezaraugusto avatar Jun 14 '24 00:06 cezaraugusto

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

John-Chan avatar Jun 14 '24 03:06 John-Chan

I suspect that the output.cssHeadDataCompression option in [email protected] 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 [email protected], where the latest version will no longer have unrecognizable characters.

[email protected] https://github.com/webpack/webpack/blob/34e2561addb0f65a7a6fb0ce7ae1aea4cd1d599f/lib/css/CssLoadingRuntimeModule.js#L227

Run npm run start

[email protected] image

[email protected] 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?

OSpoon avatar Jun 14 '24 08:06 OSpoon

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

cezaraugusto avatar Jun 14 '24 16:06 cezaraugusto

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

OSpoon avatar Jun 15 '24 13:06 OSpoon

thanks @OSpoon, PR opened to bump webpack

cezaraugusto avatar Jun 16 '24 12:06 cezaraugusto

@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!

cezaraugusto avatar Jun 19 '24 19:06 cezaraugusto

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.

John-Chan avatar Jun 20 '24 02:06 John-Chan

@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!

cezaraugusto avatar Jun 30 '24 13:06 cezaraugusto

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

John-Chan avatar Jun 30 '24 14:06 John-Chan

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?

OSpoon avatar Jul 02 '24 01:07 OSpoon

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

Screenshot 2024-07-02 at 22 16 57

cezaraugusto avatar Jul 03 '24 01:07 cezaraugusto

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

OSpoon avatar Jul 03 '24 02:07 OSpoon

Oops my bad, released now

Screenshot 2024-07-03 at 08 40 41

cezaraugusto avatar Jul 03 '24 11:07 cezaraugusto

@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 ~

OSpoon avatar Jul 03 '24 12:07 OSpoon

@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

John-Chan avatar Jul 03 '24 14:07 John-Chan

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

@OSpoon thanks for digging into it! 💯

Closing as fixed 🎉

cezaraugusto avatar Jul 03 '24 16:07 cezaraugusto