fix: Support registration: "runtime" for MV2 (#1431)

Co-authored-by: harmonyharmo <>
This commit is contained in:
Thomas
2025-03-06 07:09:33 -08:00
committed by GitHub
parent 47040277a2
commit c0867e3374
2 changed files with 0 additions and 32 deletions
@@ -836,30 +836,6 @@ describe('Manifest Utils', () => {
});
describe('registration', () => {
it('should throw an error when registration=runtime for MV2', async () => {
const cs: ContentScriptEntrypoint = fakeContentScriptEntrypoint({
options: {
registration: 'runtime',
},
skipped: false,
});
const entrypoints = [cs];
const buildOutput: Omit<BuildOutput, 'manifest'> = {
publicAssets: [],
steps: [{ entrypoints: cs, chunks: [] }],
};
setFakeWxt({
config: {
manifestVersion: 2,
},
});
await expect(
generateManifest(entrypoints, buildOutput),
).rejects.toThrowError();
});
it('should add host_permissions instead of content_scripts when registration=runtime', async () => {
const cs: ContentScriptEntrypoint = {
type: 'content-script',
-8
View File
@@ -412,14 +412,6 @@ function addEntrypoints(
const runtimeContentScripts = contentScripts.filter(
(cs) => cs.options.registration === 'runtime',
);
if (
runtimeContentScripts.length > 0 &&
wxt.config.manifestVersion === 2
) {
throw Error(
'Cannot use `registration: "runtime"` with MV2 content scripts, it is a MV3-only feature.',
);
}
runtimeContentScripts.forEach((script) => {
script.options.matches?.forEach((matchPattern) => {
addHostPermission(manifest, matchPattern);