Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,7 @@ jobs:
run: npm ci
- name: Build
run: npm run build
- name: Lint
run: npm run lint
- name: Check formatting
run: npm run lint:format
- name: Validate manifests
run: npm run lint:manifests
5 changes: 5 additions & 0 deletions manifests/native.json
Original file line number Diff line number Diff line change
Expand Up @@ -2402,6 +2402,11 @@
"moduleName": "repeat-string",
"replacements": ["String.prototype.repeat"]
},
"safe-buffer": {
"type": "module",
"moduleName": "safe-buffer",
"replacements": ["safe-buffer"]
},
"setprototypeof": {
"type": "module",
"moduleName": "setprototypeof",
Expand Down
11 changes: 11 additions & 0 deletions scripts/validate-manifests.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ export async function validateManifests() {
}
}

const usedReplacementIds = new Set();

for (const [key, mapping] of Object.entries(manifest.mappings)) {
if (mapping.type === 'module' && mapping.moduleName !== key) {
throw new Error(
Expand All @@ -68,6 +70,15 @@ export async function validateManifests() {
`${manifestPath}: mapping "${key}" references unknown replacement "${replacementId}"`
);
}
usedReplacementIds.add(replacementId);
}
}

for (const id of Object.keys(manifest.replacements)) {
if (!usedReplacementIds.has(id)) {
throw new Error(
`${manifestPath}: replacement "${id}" is defined but not used by any mapping.`
);
}
}
}
Expand Down