@parcel/packager-webextension
Advanced tools
Comparing version 2.4.2-nightly.2678 to 2.4.2-nightly.2679
@@ -59,8 +59,6 @@ "use strict"; | ||
}); | ||
const manifestAssets = assets.filter(a => a.meta.webextEntry === true); | ||
(0, _assert().default)(assets.length == 2 && manifestAssets.length == 1, 'Web extension bundles must contain exactly one manifest asset and one runtime asset'); | ||
const asset = manifestAssets[0]; | ||
_assert().default.equal(assets.length, 1, 'Web extension manifest bundles must only contain one asset'); | ||
const asset = assets[0]; | ||
(0, _assert().default)(asset.meta.webextEntry === true); | ||
const relPath = b => (0, _utils().relativeBundlePath)(bundle, b, { | ||
@@ -75,9 +73,9 @@ leadingDotSlash: false | ||
for (const contentScript of manifest.content_scripts || []) { | ||
const jsBundles = deps.filter(d => { | ||
var _contentScript$js; | ||
const srcBundles = deps.filter(d => { | ||
var _contentScript$js, _contentScript$css; | ||
return (_contentScript$js = contentScript.js) === null || _contentScript$js === void 0 ? void 0 : _contentScript$js.includes(d.id); | ||
return ((_contentScript$js = contentScript.js) === null || _contentScript$js === void 0 ? void 0 : _contentScript$js.includes(d.id)) || ((_contentScript$css = contentScript.css) === null || _contentScript$css === void 0 ? void 0 : _contentScript$css.includes(d.id)); | ||
}).map(d => (0, _nullthrows().default)(bundleGraph.getReferencedBundle(d, bundle))); | ||
contentScript.css = [...new Set((contentScript.css || []).concat(jsBundles.flatMap(b => bundleGraph.getReferencedBundles(b)).filter(b => b.type == 'css').map(relPath)))]; | ||
const resources = jsBundles.flatMap(b => { | ||
contentScript.css = [...new Set((contentScript.css || []).concat(srcBundles.flatMap(b => bundleGraph.getReferencedBundles(b)).filter(b => b.type == 'css').map(relPath)))]; | ||
const resources = srcBundles.flatMap(b => { | ||
const children = []; | ||
@@ -94,5 +92,13 @@ const siblings = bundleGraph.getReferencedBundles(b); | ||
if (resources.length > 0) { | ||
// In the future, maybe use "matches" as well | ||
war.push({ | ||
extension_ids: [], | ||
matches: contentScript.matches.map(match => { | ||
if (/^(((http|ws)s?)|ftp|\*):\/\//.test(match)) { | ||
let pathIndex = match.indexOf('/', match.indexOf('://') + 3); // Avoids creating additional errors in invalid match URLs | ||
if (pathIndex == -1) pathIndex = match.length; | ||
return match.slice(0, pathIndex) + '/*'; | ||
} | ||
return match; | ||
}), | ||
resources | ||
@@ -99,0 +105,0 @@ }); |
{ | ||
"name": "@parcel/packager-webextension", | ||
"version": "2.4.2-nightly.2678+6851d07fc", | ||
"version": "2.4.2-nightly.2679+7d2568d12", | ||
"license": "MIT", | ||
@@ -20,10 +20,10 @@ "publishConfig": { | ||
"node": ">=12.0.0", | ||
"parcel": "2.0.0-nightly.1053+6851d07fc" | ||
"parcel": "2.0.0-nightly.1054+7d2568d12" | ||
}, | ||
"dependencies": { | ||
"@parcel/plugin": "2.0.0-nightly.1055+6851d07fc", | ||
"@parcel/utils": "2.0.0-nightly.1055+6851d07fc", | ||
"@parcel/plugin": "2.0.0-nightly.1056+7d2568d12", | ||
"@parcel/utils": "2.0.0-nightly.1056+7d2568d12", | ||
"nullthrows": "^1.1.1" | ||
}, | ||
"gitHead": "6851d07fca6a0c97f669462914b5d5cdfbf84a04" | ||
"gitHead": "7d2568d1209859012d49a3d24f04842cbfa187ea" | ||
} |
@@ -14,10 +14,9 @@ // @flow strict-local | ||
}); | ||
const manifestAssets = assets.filter(a => a.meta.webextEntry === true); | ||
assert.equal( | ||
assets.length, | ||
1, | ||
'Web extension manifest bundles must only contain one asset', | ||
assert( | ||
assets.length == 2 && manifestAssets.length == 1, | ||
'Web extension bundles must contain exactly one manifest asset and one runtime asset', | ||
); | ||
const asset = assets[0]; | ||
assert(asset.meta.webextEntry === true); | ||
const asset = manifestAssets[0]; | ||
@@ -31,4 +30,8 @@ const relPath = b => | ||
for (const contentScript of manifest.content_scripts || []) { | ||
const jsBundles = deps | ||
.filter(d => contentScript.js?.includes(d.id)) | ||
const srcBundles = deps | ||
.filter( | ||
d => | ||
contentScript.js?.includes(d.id) || | ||
contentScript.css?.includes(d.id), | ||
) | ||
.map(d => nullthrows(bundleGraph.getReferencedBundle(d, bundle))); | ||
@@ -39,3 +42,3 @@ | ||
(contentScript.css || []).concat( | ||
jsBundles | ||
srcBundles | ||
.flatMap(b => bundleGraph.getReferencedBundles(b)) | ||
@@ -47,4 +50,3 @@ .filter(b => b.type == 'css') | ||
]; | ||
const resources = jsBundles | ||
const resources = srcBundles | ||
.flatMap(b => { | ||
@@ -63,5 +65,12 @@ const children = []; | ||
if (resources.length > 0) { | ||
// In the future, maybe use "matches" as well | ||
war.push({ | ||
extension_ids: [], | ||
matches: contentScript.matches.map(match => { | ||
if (/^(((http|ws)s?)|ftp|\*):\/\//.test(match)) { | ||
let pathIndex = match.indexOf('/', match.indexOf('://') + 3); | ||
// Avoids creating additional errors in invalid match URLs | ||
if (pathIndex == -1) pathIndex = match.length; | ||
return match.slice(0, pathIndex) + '/*'; | ||
} | ||
return match; | ||
}), | ||
resources, | ||
@@ -68,0 +77,0 @@ }); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
8053
177