Open keyding opened 2 years ago
No problem in vite 2.x
This is an issue with react on vite 3.x, probably a compatibility issue with vite 3.
@jacksteamdev +1 I've also got this issue which is a bit of a show stopper. Everything works on build, but crashes on dev:
Error: Could not load /id-__x00__plugin-vue:export-helper-bvtig.js (imported by ../../../../src-App.vue-8aRva.js): Unable to load "__x00__plugin-vue:export-helper" from server.
at Object.load (/Users/saxoncameron/Sites/crxjs-vite-plugin-watch-mode-load-vue-bug/node_modules/@crxjs/vite-plugin/dist/index.cjs:284:17)
at async /Users/saxoncameron/Sites/crxjs-vite-plugin-watch-mode-load-vue-bug/node_modules/@crxjs/vite-plugin/node_modules/rollup/dist/shared/rollup.js:22244:98
at async Queue.work (/Users/saxoncameron/Sites/crxjs-vite-plugin-watch-mode-load-vue-bug/node_modules/@crxjs/vite-plugin/node_modules/rollup/dist/shared/rollup.js:22951:32)
I made a minimal reproduction repo with npx create-vue
, it's just the Vue starter app injected into the top of every page via content script (the built extension works, yarn dev
doesnt). I came here to report it but found this issue. In case it is helpful, here it is:
https://github.com/saxoncameron/crxjs-vite-plugin-watch-mode-load-vue-bug
I tried for a long time to patch it locally with patch-package
and riffling through index.cjs
in node_modules
following the stack trace... but no luck, the furthest I got was some circular dependency errors. AFAICT it has something to do with the plugin plugin-vue:export-helper
having an id of /id-__x00__plugin-vue:export-helper-bvtig.js
when it maybe ought to be /@id/__x00__plugin-vue:export-helper
? Seems like it's something in the async load(id)
function around L274.
FYI @keyding @jacksteamdev this is not a problem if downgrading to:
"vite": "2.9.15"
"@vitejs/plugin-vue": "2.3.2"
The latest versions of each are what seems to be breaking this:
"vite": "^3.0.2"
"@vitejs/plugin-vue": "^3.0.1"
For now, I suggest downgrading as @saxoncameron describes.
CRXJS support for Vite 3 will land in or directly after #427. The file writer rewrite will fix this resolution problem at the root and simplify things immensely.
Vite made some big internal changes that affect not only path resolution, but also CRXJS test architecture. I already spent a full day figuring out what was wrong, but it will be sometime in September before I can finish both the new File Writer and full Vite 3 support.
@jacksteamdev Thank you for your dedication to this.
@jacksteamdev @crxjs/vite-plugin@2.0.0-beta.1
seems to resolve this issue, but curiously I get this warning in the terminal:
[plugin:crx:manifest-loader] context method emitFile() is not supported in serve mode. This plugin is likely not vite-compatible.
Doesn't seem to affect my ability to run dev mode, or the build though...?
@jacksteamdev
@crxjs/vite-plugin@2.0.0-beta.1
seems to resolve this issue, but curiously I get this warning in the terminal:[plugin:crx:manifest-loader] context method emitFile() is not supported in serve mode. This plugin is likely not vite-compatible.
Doesn't seem to affect my ability to run dev mode, or the build though...?
@jacksteamdev any idea why this warning would be popping up now, but not in the past? Did you add some plugin compatibility warnings in the beta or something? Just wondering if this ought to concern me or not
I confirm that on the latest 2.0.0-beta.4
I don't see the warning reported by @saxoncameron, and dev mode works without problems (for now at least, I only deployed the simplest scaffold).
@stefanozanella so you have solve this problem loading vue component by using 2.0.0-beta.4
?
@stefanozanella I have use 2.0.0-beta.4 solved dev mode Error problem ,but the content scrip doesn't work anymore
@jacksteamdev I want to know that do you have solved this problem now.I still have this problem in @crxjs/vite-plugin@1.0.14
.Is this my problem in my project or the plugin problem?
I have a similar problem.
EDIT: Nevermind, I managed to fix it by switching to the newest beta version of crxjs.
Hi, I'm having the exact same problem. package.json:
{ ... "scripts": { "dev": "vite", "build": "vite build", "preview": "vite preview" }, "dependencies": { "vue": "^3.2.47" }, "devDependencies": { "@crxjs/vite-plugin": "^1.0.14", "@vitejs/plugin-vue": "^4.1.0", "autoprefixer": "^10.4.14", "postcss": "^8.4.23", "postcss-import": "^15.1.0", "tailwindcss": "^3.3.2", "vite": "^4.3.2" } }
content script:
console.log('Hello World!');
import { createApp } from 'vue' import App from '../App.vue'
Error:
Error: Could not load /id-__x00__plugin-vue:export-helper-bvtig.js (imported by ../../../../../../../src-App.vue-8aRva.js): Failed to load url __x00__plugin-vue:export-helper (resolved id: __x00__plugin-vue:export-helper). Does the file exist? at loadAndTransform (file:///C:/Users/hrist/0%20-%20Things/0%20-%20Programming/Web/read-out-loud/node_modules/.pnpm/vite@4.3.2/node_modules/vite/dist/node/chunks/dep-7efa13d7.js:53333:21)
I've confirmed that the cause is l4 in the content script
I suffered for 30 mins and figured out the fix. it now compiles and works in dev
const EXPORT_HELPER_RE = /plugin-vue:export-helper/
const INTERNAL_VUE_HELPER_ID = 'INTERNAL_VUE_HELPER_ID'
const helperCode = `
export default (sfc, props) => {
const target = sfc.__vccOpts || sfc;
for (const [key, val] of props) {
target[key] = val;
}
return target;
}
`
function ExportHelperPlugin(): Plugin {
return {
name: 'vue-export-helper',
resolveId(id) {
if (EXPORT_HELPER_RE.test(id))
return INTERNAL_VUE_HELPER_ID
},
load(id) {
if (id === INTERNAL_VUE_HELPER_ID)
return helperCode
},
}
}
ref:
Build tool
Vite
Where do you see the problem?
Describe the bug
Error message after running
pnpm dev
Import
HelloWorld.vue
component incontent-scripts.ts
Reproduction
https://github.com/keyding/vite3-crx
Logs
No response
System Info
Severity
blocking an upgrade