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

Fix web extension issues #8000

Merged
merged 7 commits into from May 23, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
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
19 changes: 18 additions & 1 deletion packages/core/core/src/Dependency.js
Expand Up @@ -85,12 +85,29 @@ export function createDependency(
}

export function mergeDependencies(a: Dependency, b: Dependency): void {
let {meta, symbols, ...other} = b;
let {
meta,
symbols,
needsStableName,
isEntry,
isOptional,
bundleBehavior,
...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;
if (
bundleBehavior == BundleBehavior['isolated'] ||
101arrowz marked this conversation as resolved.
Show resolved Hide resolved
a.bundleBehavior == null
) {
a.bundleBehavior = bundleBehavior;
101arrowz marked this conversation as resolved.
Show resolved Hide resolved
}
}
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}`,
101arrowz marked this conversation as resolved.
Show resolved Hide resolved
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