Skip to content

Commit

Permalink
Fix web extension issues (#8000)
Browse files Browse the repository at this point in the history
  • Loading branch information
101arrowz committed May 23, 2022
1 parent 03fb352 commit 2c18016
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 18 deletions.
13 changes: 12 additions & 1 deletion packages/core/core/src/Dependency.js
Expand Up @@ -50,6 +50,7 @@ export function createDependency(
(opts.target ? JSON.stringify(opts.target) : '') +
(opts.pipeline ?? '') +
opts.specifierType +
(opts.bundleBehavior ?? '') +
(opts.priority ?? 'sync'),
);

Expand Down Expand Up @@ -85,12 +86,22 @@ export function createDependency(
}

export function mergeDependencies(a: Dependency, b: Dependency): void {
let {meta, symbols, ...other} = b;
let {
meta,
symbols,
needsStableName,
isEntry,
isOptional,
...other
} = b;
Object.assign(a, other);
Object.assign(a.meta, meta);
if (a.symbols && symbols) {
for (let [k, v] of symbols) {
a.symbols.set(k, v);
}
}
if (needsStableName) a.needsStableName = true;
if (isEntry) a.isEntry = true;
if (!isOptional) a.isOptional = false;
}
3 changes: 2 additions & 1 deletion packages/core/core/src/requests/WriteBundleRequest.js
Expand Up @@ -66,11 +66,12 @@ export type WriteBundleRequest = {|
export default function createWriteBundleRequest(
input: WriteBundleRequestInput,
): WriteBundleRequest {
let name = nullthrows(input.bundle.name);
let nameHash = nullthrows(
input.hashRefToNameHash.get(input.bundle.hashReference),
);
return {
id: `${input.bundle.id}:${input.info.hash}:${nameHash}`,
id: `${input.bundle.id}:${input.info.hash}:${nameHash}:${name}`,
type: 'write_bundle_request',
run,
input,
Expand Down
1 change: 0 additions & 1 deletion packages/core/core/src/requests/WriteBundlesRequest.js
Expand Up @@ -147,7 +147,6 @@ function assignComplexNameHashes(
if (hashRefToNameHash.get(bundle.hashReference) != null) {
continue;
}

hashRefToNameHash.set(
bundle.hashReference,
options.shouldContentHash
Expand Down
9 changes: 6 additions & 3 deletions packages/packagers/webextension/src/WebExtensionPackager.js
Expand Up @@ -72,13 +72,16 @@ export default (new Packager({
});
}
}
manifest.web_accessible_resources = (
manifest.web_accessible_resources || []
).concat(

const warResult = (manifest.web_accessible_resources || []).concat(
manifest.manifest_version == 2
? [...new Set(war.flatMap(entry => entry.resources))]
: war,
);
if (warResult.length > 0) {
manifest.web_accessible_resources = warResult;
}

let {contents} = replaceURLReferences({
bundle,
bundleGraph,
Expand Down
23 changes: 11 additions & 12 deletions packages/transformers/webextension/src/schema.js
Expand Up @@ -94,8 +94,6 @@ const commonProps = {
properties: {},
},
},
key: string,
update_url: string,
chrome_settings_overrides: {
type: 'object',
properties: {
Expand Down Expand Up @@ -231,17 +229,27 @@ const commonProps = {
type: 'string',
enum: ['spanning', 'split', 'not_allowed'],
},
key: string,
minimum_chrome_version: {
type: 'string',
__validate: validateVersion,
},
// No NaCl modules because deprecated
oauth2: {
type: 'object',
properties: {
client_id: string,
scopes: arrStr,
},
additionalProperties: false,
},
offline_enabled: boolean,
omnibox: ({
type: 'object',
properties: {},
additionalProperties: string,
}: SchemaEntity),
optional_host_permissions: arrStr,
optional_permissions: arrStr,
// options_page is deprecated
options_ui: {
Expand Down Expand Up @@ -400,6 +408,7 @@ const commonProps = {
},
additionalProperties: false,
},
update_url: string,
user_scripts: {
type: 'object',
properties: {
Expand All @@ -408,14 +417,6 @@ const commonProps = {
additionalProperties: false,
},
version_name: string,
oauth2: {
type: 'object',
properties: {
client_id: string,
scopes: arrStr,
},
additionalProperties: false,
},
};

export const MV3Schema = ({
Expand Down Expand Up @@ -465,7 +466,6 @@ export const MV3Schema = ({
},
},
required: ['manifest_version', 'name', 'version'],
additionalProperties: false,
}: SchemaEntity);

export const MV2Schema = ({
Expand Down Expand Up @@ -501,7 +501,6 @@ export const MV2Schema = ({
web_accessible_resources: arrStr,
},
required: ['manifest_version', 'name', 'version'],
additionalProperties: false,
}: SchemaEntity);

export const VersionSchema = ({
Expand Down

0 comments on commit 2c18016

Please sign in to comment.