-
Notifications
You must be signed in to change notification settings - Fork 6
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: add workaround for chrome bug 816121 #42
Conversation
Thank you for the week fix! I'll try it tomorrow or early this week |
yes, you need to specify a background entry (background page in mv2 or service worker in mv3) in the config to use the classic loader @fregante |
I tried: pixiebrix/pixiebrix-extension#7374 MV2 manifest found at https://github.com/pixiebrix/pixiebrix-extension/blob/bb55e53ec263d4d501341775364d4d0291f14927/src/manifest.json The error disappeared, but the original chunk error returned However I saw this error in the background, I think you're just missing |
hello, I cannot reproduce. It works on my side. Here is my setup.
const WebExtension = require('webpack-target-webextension')
const webpack = require('webpack')
const { join } = require('path')
/** @returns {webpack.Configuration} */
const config = (a, env) => ({
module: {
rules: [],
},
entry: {
bg: join(__dirname, './bg-src.js'),
cs: join(__dirname, './cs-src.js'),
},
output: {
path: join(__dirname, './dist'),
publicPath: '/dist/',
environment: {
dynamicImport: true,
},
},
plugins: [
new WebExtension({
background: { serviceWorkerEntry: 'bg' },
}),
].filter(Boolean),
devServer: {},
optimization: {
minimize: false,
},
})
module.exports = config
setTimeout(() => {
import('./secondary.js')
}, 200)
if (location.href.startsWith('about')) {
console.log(location.href)
import('./secondary.js')
import('./secondary-2.js')
}
{
"name": "sandbox iframe",
"version": "1.0.7",
"manifest_version": 3,
"description": "Demo extension",
"permissions": ["scripting", "activeTab"],
"host_permissions": ["http://127.0.0.1:8080/*"],
"background": {
"service_worker": "dist/bg.js"
},
"web_accessible_resources": [
{
"resources": ["*.js"],
"matches": ["<all_urls>"]
}
],
"content_scripts": [
{
"matches": ["*://*/*"],
"js": ["dist/cs.js"],
"all_frames": true,
"match_about_blank": true
}
]
}
console.log('secondary')
console.log('secondary 2')
<html>
<body>
<!-- srcdoc or src, same issue-->
<iframe srcdoc="Hello world!" sandbox>
</body>
</html> |
Could it be because it's a nested import()? i.e. a import()'d module imports another module. I'll try again today |
Ok I think I found the issue: new WebExtensionTarget({
weakRuntimeCheck: true,
background: {
pageEntry: "background",
serviceWorkerEntry: "background",
},
}), My build can generate either MV2 or MV3, depending on the This fixed the background page error already: new WebExtensionTarget({
weakRuntimeCheck: true,
background: {
pageEntry: "background",
},
}), |
Ok I think that issue already existed with I'll look into the to that |
BTW, if you want to test frames, srcdoc and sandbox, here you'll find plenty of composable links: https://github.com/fregante/ephiframe In this specific case, this link loads both a sandboxed and a non-sandboxed |
I didn't expect |
Sounds good, it could be done separately since it's unrelated to frames/loading. But this is working well for us already. ✅ |
a dirty hack to workaround Chrome bug https://bugs.chromium.org/p/chromium/issues/detail?id=816121
this dirty hack tries to detect this bug and fix it by calling the classic loader, therefore you must have the correct permissions (like "scripting" in mv3) and host_permissions of the target origin.
you can see the document of classic loader in the readme of this project.