-
Notifications
You must be signed in to change notification settings - Fork 190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: CRXJS does not work with content script in "MAIN" world, link is… #851
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
Is it fully solve #695 ? |
I realize that this form of code I'm submitting is up for consideration, and I look forward to your better solutions! |
@mLiGuangYuan is it work with hot reload? Do you have workable solution with additional content script in |
Yes, It's does support hot reloading, just remove the [hash].filename from vite rollup config, like ...others
build: {
/** Can slowDown build speed. */
// sourcemap: isDev,
outDir,
minify: isProduction,
reportCompressedSize: isProduction,
rollupOptions: {
output: {
format: 'esm',
entryFileNames: 'entry/[name].js',
chunkFileNames: 'chunks/[name].js',
assetFileNames: 'src/[name].[ext]',
},
},
}, |
you can try it, in your project, but u need be careful with the variable I set in |
@mLiGuangYuan when i am trying to use your zip, all looks fine, but on dev or build process i have that error: ahwe@user:~/mst-extension$ pnpm run build
> inside-me@ build /home/ahwe/mst-extension
> tsc && vite build
failed to load config from /home/ahwe/mst-extension/vite.config.ts
error during build:
TypeError: (0 , import_cxtjs_vite_plugin2.crx) is not a function
at config (file:///home/ahwe/mst-extension/vite.config.ts.timestamp-1704474950853-286e3dfc02da4.mjs:110:39)
at loadConfigFromFile (file:///home/ahwe/mst-extension/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/chunks/dep-68d1a114.js:66181:15)
at async resolveConfig (file:///home/ahwe/mst-extension/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/chunks/dep-68d1a114.js:65774:28)
at async build (file:///home/ahwe/mst-extension/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/chunks/dep-68d1a114.js:47926:20)
at async CAC.<anonymous> (file:///home/ahwe/mst-extension/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/cli.js:842:9)
ELIFECYCLE Command failed with exit code 1.
ahwe@user:~/mst-extension$ UPD: Same problem after build from source |
this is a package, need import 2 package..
|
if u don't konw how to work, u can use this npm https://www.npmjs.com/package/@belloai/cxtjs-vite-plugin |
多个插件在同一个页面上 storage key 相同,会被覆盖吧 |
I realize that this form of code I'm submitting is up for consideration, and I look forward to your better solutions! can u help to fix it? |
@@ -1,4 +1,6 @@ | |||
declare const __SCRIPT__: string | |||
|
|||
localStorage.setItem('__CRX_EXTEND_ID__', chrome.runtime.id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did you try to obtain it using the method described here by the chromium team? It would be cool to not rely on localStorage
// your injected.js. Only works as a first line in the injected script
extensionID = document.currentScript.id;
If not then lets try that
for (const { | ||
js = [], | ||
matches = [], | ||
world = 'ISOLATED', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dont we need to pass the world argument into the first if leg? if (config.command === 'serve') {
.
I guess it now works in the vite build
mode, but does not work in vite
(dev) mode
fileName: string | ||
world?: 'ISOLATED' | 'MAIN' | ||
}): string { | ||
const { fileName, world = 'ISOLATED' } = params || {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i dont get it - this function will never get parameter { world: 'MAIN'}
. The only usage this code does not include world
parameter
source: createProLoader({ fileName }), |
I would love to test it + help but im not sure how to setup the pnpm workspace (never worked with pnpm and workspaces) |
…sues: #695