Closed qiweiii closed 9 months ago
Did some googling, I found a few other references to this UTF8 issue.
There's probably some non-encoded UTF characters being output that makes Chrome think your file isn't valid. The file was too big to look through myself, so I switched to trying to find the code/modules causing the problem.
After a binary search of commenting things out, I found this has something to do with the @uiw/react-codemirror
module. I was able to get it building by commenting it out in the editor component. Then I had to make a few other changes to actually get a working build:
Obviously removing the editor isn't a solution lol. Instead, I'd recommend you load the editor inside an iframe, and just have the content script insert the iframe. That way you don't have to include @uiw/react-codemirror
inside a content script. Maybe that would work-around the error with your dependency.
See WXT's createIframeUi
helper: https://wxt.dev/guide/content-script-ui.html#iframe
@aklinker1 much appreciated, I will give it a try
@aklinker1
Depending on the wxt.config.ts and vite build options (terser used as minifier or not), I also get these errors.
Would something as simple as this in a vite plugin that can be activated or not solve the issue?
If one of you could try this function out, that'd be helpful. I'm a little concerned about iterating over every character of the bundle to fix a rare case that doesn't happen for everyone.
You can test this out by adding a custom vite plugin, and calling the function @lionelhorn mentioned on the bundle during the generateBundle
hook.
On my phone right now, will add a full example if that's not enough to get you started
I will try this solution when I get home!
我也遇到了这个问题,首先我尝试关闭vite minify, 编译后chrome能正常加载扩展。 I also encountered this problem. First, I tried to turn off Vite Minify, and after compiling, Chrome was able to load the extension normally.
于是我使用了 terser So I used Terser
vite() {
return {
build: {
minify: "terser",
terserOptions: {
compress: {
drop_console: true,
drop_debugger: true,
},
},
}
}
}
可以通过这个设置尝试是否能够解决上述问题
You can try this setting to see if it can solve the above problem
Describe the bug
after
pnpm dev
, I got this error from chrome:To Reproduce
branch: https://github.com/qiweiii/markdown-sticky-notes/tree/migrate-wxt Steps to reproduce the bug using the reproduction:
pnpm i
pnpm dev
Expected behavior
Expected to open in chrome
Screenshots
Environment
Additional context
I am trying to migrate this old extension to
wxt
, the branch is wip so may have many problems, any help would be appreciated!