Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webextension fixes #7958

Merged
merged 2 commits into from Apr 17, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 20 additions & 16 deletions packages/packagers/webextension/src/WebExtensionPackager.js
Expand Up @@ -42,22 +42,26 @@ export default (new Packager({
),
];

war.push({
matches: contentScript.matches,
extension_ids: [],
resources: jsBundles
.flatMap(b => {
const children = [];
const siblings = bundleGraph.getReferencedBundles(b);
bundleGraph.traverseBundles(child => {
if (b !== child && !siblings.includes(child)) {
children.push(child);
}
}, b);
return children;
})
.map(relPath),
});
const resources = jsBundles
.flatMap(b => {
const children = [];
const siblings = bundleGraph.getReferencedBundles(b);
bundleGraph.traverseBundles(child => {
if (b !== child && !siblings.includes(child)) {
children.push(child);
}
}, b);
return children;
})
.map(relPath);

if (resources.length > 0) {
// In the future, maybe use "matches" as well
war.push({
extension_ids: [],
resources,
});
}
}
manifest.web_accessible_resources = (
manifest.web_accessible_resources || []
Expand Down
11 changes: 11 additions & 0 deletions packages/transformers/webextension/src/WebExtensionTransformer.js
Expand Up @@ -99,6 +99,7 @@ async function collectDependencies(
assets[j] = asset.addURLDependency(assets[j], {
// This causes the packager to re-run when these assets update
priority: 'parallel',
bundleBehavior: 'isolated',
loc: {
filePath,
...getJSONSourceLocation(
Expand Down Expand Up @@ -190,6 +191,8 @@ async function collectDependencies(
await glob(path.join(assetDir, files[j]), fs, {})
).map(fp =>
asset.addURLDependency(path.relative(assetDir, fp), {
priority: 'parallel',
bundleBehavior: 'isolated',
needsStableName: true,
loc: {
filePath,
Expand Down Expand Up @@ -224,6 +227,8 @@ async function collectDependencies(
const obj = parent[lastLoc];
if (typeof obj == 'string')
parent[lastLoc] = asset.addURLDependency(obj, {
priority: 'parallel',
bundleBehavior: 'isolated',
loc: {
filePath,
...getJSONSourceLocation(ptrs[location], 'value'),
Expand All @@ -233,6 +238,8 @@ async function collectDependencies(
else {
for (const k of Object.keys(obj)) {
obj[k] = asset.addURLDependency(obj[k], {
priority: 'parallel',
bundleBehavior: 'isolated',
loc: {
filePath,
...getJSONSourceLocation(ptrs[location + '/' + k], 'value'),
Expand All @@ -247,6 +254,8 @@ async function collectDependencies(
program.background.page = asset.addURLDependency(
program.background.page,
{
priority: 'parallel',
bundleBehavior: 'isolated',
loc: {
filePath,
...getJSONSourceLocation(ptrs['/background/page'], 'value'),
Expand Down Expand Up @@ -285,6 +294,8 @@ async function collectDependencies(
program.background.service_worker = asset.addURLDependency(
program.background.service_worker,
{
priority: 'parallel',
bundleBehavior: 'isolated',
loc: {
filePath,
...getJSONSourceLocation(
Expand Down
8 changes: 8 additions & 0 deletions packages/transformers/webextension/src/schema.js
Expand Up @@ -85,6 +85,14 @@ const commonProps = {
description: string,
icons,
author: string,
browser_specific_settings: {
type: 'object',
properties: {},
additionalProperties: {
type: 'object',
properties: {},
}
},
chrome_settings_overrides: {
type: 'object',
properties: {
Expand Down