@atlaspack/packager-webextension 2.12.1-dev.3443 → 2.12.1-dev.3478
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -5
- package/src/WebExtensionPackager.js +13 -13
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/packager-webextension",
|
|
3
|
-
"version": "2.12.1-dev.
|
|
3
|
+
"version": "2.12.1-dev.3478+5fd2da535",
|
|
4
4
|
"license": "(MIT OR Apache-2.0)",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -13,12 +13,12 @@
|
|
|
13
13
|
"source": "src/WebExtensionPackager.js",
|
|
14
14
|
"engines": {
|
|
15
15
|
"node": ">=16.0.0",
|
|
16
|
-
"parcel": "^2.12.1-dev.
|
|
16
|
+
"parcel": "^2.12.1-dev.3478+5fd2da535"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@atlaspack/plugin": "2.12.1-dev.
|
|
20
|
-
"@atlaspack/utils": "2.12.1-dev.
|
|
19
|
+
"@atlaspack/plugin": "2.12.1-dev.3478+5fd2da535",
|
|
20
|
+
"@atlaspack/utils": "2.12.1-dev.3478+5fd2da535",
|
|
21
21
|
"nullthrows": "^1.1.1"
|
|
22
22
|
},
|
|
23
|
-
"gitHead": "
|
|
23
|
+
"gitHead": "5fd2da535ecbe096d57e03aec15e80bb1d7601f7"
|
|
24
24
|
}
|
|
@@ -8,10 +8,10 @@ import {replaceURLReferences, relativeBundlePath} from '@atlaspack/utils';
|
|
|
8
8
|
export default (new Packager({
|
|
9
9
|
async package({bundle, bundleGraph}) {
|
|
10
10
|
let assets = [];
|
|
11
|
-
bundle.traverseAssets(asset => {
|
|
11
|
+
bundle.traverseAssets((asset) => {
|
|
12
12
|
assets.push(asset);
|
|
13
13
|
});
|
|
14
|
-
const manifestAssets = assets.filter(a => a.meta.webextEntry === true);
|
|
14
|
+
const manifestAssets = assets.filter((a) => a.meta.webextEntry === true);
|
|
15
15
|
|
|
16
16
|
assert(
|
|
17
17
|
assets.length == 2 && manifestAssets.length == 1,
|
|
@@ -19,7 +19,7 @@ export default (new Packager({
|
|
|
19
19
|
);
|
|
20
20
|
const asset = manifestAssets[0];
|
|
21
21
|
|
|
22
|
-
const relPath = b =>
|
|
22
|
+
const relPath = (b) =>
|
|
23
23
|
relativeBundlePath(bundle, b, {leadingDotSlash: false});
|
|
24
24
|
|
|
25
25
|
const manifest = JSON.parse(await asset.getCode());
|
|
@@ -35,17 +35,17 @@ export default (new Packager({
|
|
|
35
35
|
for (const contentScript of manifest.content_scripts || []) {
|
|
36
36
|
const srcBundles = deps
|
|
37
37
|
.filter(
|
|
38
|
-
d =>
|
|
38
|
+
(d) =>
|
|
39
39
|
contentScript.js?.includes(d.id) ||
|
|
40
40
|
contentScript.css?.includes(d.id),
|
|
41
41
|
)
|
|
42
|
-
.map(d => nullthrows(bundleGraph.getReferencedBundle(d, bundle)));
|
|
42
|
+
.map((d) => nullthrows(bundleGraph.getReferencedBundle(d, bundle)));
|
|
43
43
|
|
|
44
44
|
contentScript.css = [
|
|
45
45
|
...new Set(
|
|
46
46
|
srcBundles
|
|
47
|
-
.flatMap(b => bundleGraph.getReferencedBundles(b))
|
|
48
|
-
.filter(b => b.type == 'css')
|
|
47
|
+
.flatMap((b) => bundleGraph.getReferencedBundles(b))
|
|
48
|
+
.filter((b) => b.type == 'css')
|
|
49
49
|
.map(relPath)
|
|
50
50
|
.concat(contentScript.css || []),
|
|
51
51
|
),
|
|
@@ -54,18 +54,18 @@ export default (new Packager({
|
|
|
54
54
|
contentScript.js = [
|
|
55
55
|
...new Set(
|
|
56
56
|
srcBundles
|
|
57
|
-
.flatMap(b => bundleGraph.getReferencedBundles(b))
|
|
58
|
-
.filter(b => b.type == 'js')
|
|
57
|
+
.flatMap((b) => bundleGraph.getReferencedBundles(b))
|
|
58
|
+
.filter((b) => b.type == 'js')
|
|
59
59
|
.map(relPath)
|
|
60
60
|
.concat(contentScript.js || []),
|
|
61
61
|
),
|
|
62
62
|
];
|
|
63
63
|
|
|
64
64
|
const resources = srcBundles
|
|
65
|
-
.flatMap(b => {
|
|
65
|
+
.flatMap((b) => {
|
|
66
66
|
const children = [];
|
|
67
67
|
const siblings = bundleGraph.getReferencedBundles(b);
|
|
68
|
-
bundleGraph.traverseBundles(child => {
|
|
68
|
+
bundleGraph.traverseBundles((child) => {
|
|
69
69
|
if (b !== child && !siblings.includes(child)) {
|
|
70
70
|
children.push(child);
|
|
71
71
|
}
|
|
@@ -76,7 +76,7 @@ export default (new Packager({
|
|
|
76
76
|
|
|
77
77
|
if (resources.length > 0) {
|
|
78
78
|
war.push({
|
|
79
|
-
matches: contentScript.matches.map(match => {
|
|
79
|
+
matches: contentScript.matches.map((match) => {
|
|
80
80
|
if (/^(((http|ws)s?)|ftp|\*):\/\//.test(match)) {
|
|
81
81
|
let pathIndex = match.indexOf('/', match.indexOf('://') + 3);
|
|
82
82
|
// Avoids creating additional errors in invalid match URLs
|
|
@@ -92,7 +92,7 @@ export default (new Packager({
|
|
|
92
92
|
|
|
93
93
|
const warResult = (manifest.web_accessible_resources || []).concat(
|
|
94
94
|
manifest.manifest_version == 2
|
|
95
|
-
? [...new Set(war.flatMap(entry => entry.resources))]
|
|
95
|
+
? [...new Set(war.flatMap((entry) => entry.resources))]
|
|
96
96
|
: war,
|
|
97
97
|
);
|
|
98
98
|
|