Bug 1828563 - Convert FeatureManifest.js to ESM. r=barret

Differential Revision: https://phabricator.services.mozilla.com/D175724
This commit is contained in:
Mathew Hodson
2023-04-24 09:54:19 +00:00
parent 8ba3c187c7
commit 2d5ee0a583
3 changed files with 6 additions and 12 deletions

View File

@@ -21,17 +21,11 @@ NIMBUS_FALLBACK_PREFS = (
"NIMBUS_FALLBACK_PREFS[]{{{}}};"
)
EXPORTED_SYMBOLS = 'const EXPORTED_SYMBOLS = ["{}"];'
def write_fm_cpp_headers(fd):
def write_fm_headers(fd):
fd.write(HEADER_LINE)
def write_fm_js_headers(fd):
fd.write("\n".join([HEADER_LINE, EXPORTED_SYMBOLS.format("FeatureManifest")]))
def validate_feature_manifest(schema_path, manifest_path, manifest):
with open(schema_path, "r") as f:
schema = json.load(f)
@@ -97,7 +91,7 @@ def validate_feature_manifest(schema_path, manifest_path, manifest):
def generate_feature_manifest(fd, input_file):
write_fm_js_headers(fd)
write_fm_headers(fd)
try:
with open(input_file, "r", encoding="utf-8") as f:
@@ -107,7 +101,7 @@ def generate_feature_manifest(fd, input_file):
Path(input_file).parent / FEATURE_MANIFEST_SCHEMA, input_file, manifest
)
fd.write(f"const FeatureManifest = {json.dumps(manifest)};")
fd.write(f"export const FeatureManifest = {json.dumps(manifest)};")
except (IOError) as e:
print(f"{input_file}: error:\n {e}\n")
sys.exit(1)
@@ -131,7 +125,7 @@ def platform_feature_manifest_array(features):
def generate_platform_feature_manifest(fd, input_file):
write_fm_cpp_headers(fd)
write_fm_headers(fd)
def file_structure(data):
return "\n".join(

View File

@@ -6,6 +6,6 @@ toolkit.jar:
% resource nimbus %res/nimbus/
res/nimbus/lib/ (./lib/*.sys.mjs)
res/nimbus/ExperimentAPI.sys.mjs (./ExperimentAPI.sys.mjs)
res/nimbus/FeatureManifest.js (FeatureManifest.js)
res/nimbus/FeatureManifest.sys.mjs (FeatureManifest.sys.mjs)
res/nimbus/schemas/NimbusEnrollment.schema.json (./schemas/NimbusEnrollment.schema.json)
res/nimbus/schemas/NimbusExperiment.schema.json (./schemas/NimbusExperiment.schema.json)

View File

@@ -33,7 +33,7 @@ TESTING_JS_MODULES += [
]
GeneratedFile(
"FeatureManifest.js",
"FeatureManifest.sys.mjs",
script="generate/generate_feature_manifest.py",
entry_point="generate_feature_manifest",
inputs=["./FeatureManifest.yaml"],