Skip to content

Commit aaa057d

Browse files
Fix tool issue merging tsconfig paths not detecting same state
1 parent 5aa9e21 commit aaa057d

2 files changed

Lines changed: 29 additions & 29 deletions

File tree

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
"generate-tests": "npm-run-all build-test-maker make-tests lint-tests format-tests",
3434
"test-libs": "nx run-many --target=test --runInBand --projects=\"tests*\" --parallel=5 && nx run-many --target=test --runInBand --projects=parsing-tokenizer --parallel=5",
3535
"ng": "nx",
36-
"package": "npm i && npm-run-all build-extension pre-package && vsce package",
37-
"package-and-test": "npm i && npm-run-all build-extension pre-package test-parsing build-test integration-test && vsce package",
36+
"package": "npm i && npm-run-all build-extension pre-package && vsce package --allow-star-activation",
37+
"package-and-test": "npm i && npm-run-all build-extension pre-package test-parsing build-test integration-test && vsce package --allow-star-activation",
3838
"parse-docs": "nx build idl-docs-parser --prod-false && node dist/apps/idl-docs-parser/main.js",
3939
"pre-package": "rimraf ./node_modules/__ngcc_entry_points__.json",
4040
"pre-dev": "npm-run-all build-package-json build-webview",

tools/merge-client-web-paths.js

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,41 @@ const base = baseConfig.compilerOptions.paths;
2020
/** Get existing paths in our second config file */
2121
const toExtend = extendedConfig.compilerOptions.paths;
2222

23+
/**
24+
* Extract any keys that aren't from our lib (i.e. will have polyfills)
25+
*/
26+
const saveThese = {};
27+
28+
/** Get all paths in the file to merge */
29+
const existingPaths = Object.keys(toExtend);
30+
31+
// delete any changed libraries
32+
for (let i = 0; i < existingPaths.length; i++) {
33+
// check for polyfill and not local library
34+
if (!existingPaths[i].startsWith('@idl')) {
35+
saveThese[existingPaths[i]] = toExtend[existingPaths[i]];
36+
delete toExtend[existingPaths[i]];
37+
continue;
38+
}
39+
40+
// remove if lib is not in existing source
41+
if (!(existingPaths[i] in base) && existingPaths[i] in toExtend) {
42+
delete toExtend[existingPaths[i]];
43+
changes = true;
44+
}
45+
}
46+
2347
/** Get all paths that should be shared */
2448
const sharedPaths = Object.keys(base);
2549

2650
/** Track if there are changes */
2751
let changes = false;
2852

29-
// check for changes - so we dont always break formatting
53+
// add any missing libraries
3054
for (let i = 0; i < sharedPaths.length; i++) {
3155
if (!(sharedPaths[i] in toExtend)) {
56+
toExtend[sharedPaths[i]] = base[sharedPaths[i]];
3257
changes = true;
33-
break;
34-
}
35-
}
36-
37-
/** Get all paths in the file to merge */
38-
const existingPaths = Object.keys(toExtend);
39-
40-
// check for changes - so we dont always break formatting
41-
for (let i = 0; i < existingPaths.length; i++) {
42-
if (!(existingPaths[i] in base)) {
43-
changes = true;
44-
break;
4558
}
4659
}
4760

@@ -50,21 +63,8 @@ if (!changes) {
5063
process.exit();
5164
}
5265

53-
// check for changes - so we dont always break formatting
54-
for (let i = 0; i < existingPaths.length; i++) {
55-
if (existingPaths[i].startsWith('@idl')) {
56-
delete toExtend[existingPaths[i]];
57-
}
58-
}
59-
60-
// Merge paths
61-
const mergedPaths = {
62-
...baseConfig.compilerOptions.paths,
63-
...extendedConfig.compilerOptions.paths,
64-
};
65-
6666
// Update extended config
67-
extendedConfig.compilerOptions.paths = mergedPaths;
67+
extendedConfig.compilerOptions.paths = { ...toExtend, ...saveThese };
6868

6969
// Write updated config
7070
fs.writeFileSync(extendedConfigPath, JSON.stringify(extendedConfig, null, 2));

0 commit comments

Comments
 (0)