Skip to content

Commit

Permalink
fix: dev bgs for mv2 (#259)
Browse files Browse the repository at this point in the history
* fix: adding bgs for for mv2

* update bgsw bundling
  • Loading branch information
louisgv committed Oct 11, 2022
1 parent 9e7a230 commit 250047b
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion cli/create-plasmo/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-plasmo",
"version": "0.56.0",
"version": "0.56.1",
"description": "Create Plasmo Framework Browser Extension",
"main": "dist/index.js",
"bin": "dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion cli/plasmo/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "plasmo",
"version": "0.56.0",
"version": "0.56.1",
"description": "The Plasmo Platform CLI",
"main": "dist/index.js",
"types": "dist/type.d.ts",
Expand Down
3 changes: 1 addition & 2 deletions cli/plasmo/src/features/manifest-factory/mv3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ export class PlasmoExtensionManifestMV3 extends BaseFactory<ExtensionManifestV3>
if (enable) {
const scriptPath = relative(this.commonPath.dotPlasmoDirectory, path)
this.data.background = {
service_worker: scriptPath,
type: "module"
service_worker: scriptPath
}
} else {
delete this.data.background
Expand Down
2 changes: 1 addition & 1 deletion examples
2 changes: 1 addition & 1 deletion packages/parcel-config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@plasmohq/parcel-config",
"version": "0.16.4",
"version": "0.17.0",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/parcel-packager/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@plasmohq/parcel-packager",
"version": "0.3.4",
"version": "0.4.0",
"description": "Plasmo Parcel Packager for Web Extension Manifest",
"files": [
"dist"
Expand Down
1 change: 0 additions & 1 deletion packages/parcel-packager/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ export default new Packager({
appendMv2Wars(manifest, wars, options)
} else {
appendMv3Wars(manifest, wars, options)
delete manifest.background?.type
}

const { contents } = replaceURLReferences({
Expand Down
2 changes: 1 addition & 1 deletion packages/parcel-transformer-manifest/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@plasmohq/parcel-transformer-manifest",
"version": "0.9.1",
"version": "0.10.0",
"description": "Plasmo Parcel Transformer for Web Extension Manifest",
"files": [
"dist",
Expand Down
12 changes: 10 additions & 2 deletions packages/parcel-transformer-manifest/src/handle-background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ function handleMV2Background(program: MV2Data) {
program.content_security_policy
)

if (!program.background) {
program.background = {}
}

if (!program.background?.scripts) {
program.background.scripts = []
}
Expand All @@ -70,11 +74,15 @@ function handleMV3Background(program: MV3Data) {
...getJSONSourceLocation(ptrs["/background/service_worker"], "value")
},
env: {
context: "service-worker",
sourceType: program.background.type === "module" ? "module" : "script"
context: "service-worker"
}
}
)

// Since we bundle everything, and sw import is static (not async), we can ignore type module.
if (!!program.background.type) {
delete program.background.type
}
}

if (hot) {
Expand Down

0 comments on commit 250047b

Please sign in to comment.