From 7e51e63fdc0b384f578a72cfcc475fc498d14b42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=E2=9D=A4=EF=B8=8F=20=E2=98=AE=EF=B8=8F=20=E2=9C=8B?= <6723574+louisgv@users.noreply.github.com> Date: Wed, 28 Jun 2023 20:22:05 -0700 Subject: [PATCH] fix: mv2 host_permission merging --- .../src/features/manifest-factory/base.ts | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/cli/plasmo/src/features/manifest-factory/base.ts b/cli/plasmo/src/features/manifest-factory/base.ts index f4c167818..442b51bcf 100644 --- a/cli/plasmo/src/features/manifest-factory/base.ts +++ b/cli/plasmo/src/features/manifest-factory/base.ts @@ -488,16 +488,6 @@ export abstract class PlasmoManifest { ...overide } = this.overideManifest as T - if (this.bundleConfig.manifestVersion === "mv2") { - base.background = { - ...base.background, - ...overrideBackground - } - if (Object.keys(base.background).length === 0) { - delete base.background - } - } - if (base.options_ui?.page) { base.options_ui = { ...base.options_ui, @@ -513,6 +503,23 @@ export abstract class PlasmoManifest { delete base.permissions } + if (this.bundleConfig.manifestVersion === "mv2") { + base.background = { + ...base.background, + ...overrideBackground + } + if (Object.keys(base.background).length === 0) { + delete base.background + } + // Host permission is coupled with permission in mv2 + if (overide["host_permissions"]?.length > 0) { + base.permissions = [ + ...(base.permissions || []), + ...overide["host_permissions"] + ] + } + } + // Populate content_scripts base.content_scripts = [ ...Array.from(this.contentScriptMap.values()).filter(