Skip to content

Commit 7df7e34

Browse files
IgorMinarkara
authored andcommitted
build: delete rxjs d.ts files referencing rxjs-compat (angular#33786)
In order to speed up bazel build performance delete all rxjs d.ts files that reference rxjs-compat. For all ts_library and ng_module rules Bazel generates tsconfig.json file that explicitly lists all d.ts files found in required npm package. In case of rxjs, this means that tsconfig contains all d.ts files that reference rxjs-compat package, which is an interop/backwards compatibility package not installed in angular/angular repo. But because tsconfig contains these d.ts files, tsc will try to resolve them and silently fail. All these lookups are quite expensive and not cached. This causes significant slowdown of the build under bazel. This change removes all of these problematic rxjs d.ts files via an npm postinstall hook. This is not ideal because it solves the problem only for our repo, but it's a good start. Build perf improvements per target: //packages/core/src/reflect:reflect 5sec => 3 sec //packages/core:core 17sec => 12 sec //packages/router:router 30sec => 8 sec PR Close angular#33786
1 parent 0fecea1 commit 7df7e34

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

tools/postinstall-patches.js

+34-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ try {
2020
process.exit(0);
2121
}
2222

23-
const {set, cd, sed, echo, ls} = require('shelljs');
23+
const {set, cd, sed, echo, ls, rm} = require('shelljs');
2424
const {readFileSync} = require('fs');
2525
const path = require('path');
2626
const log = console.log;
@@ -68,4 +68,37 @@ ls('node_modules/@types').filter(f => f.startsWith('babel__')).forEach(pkg => {
6868
}
6969
});
7070

71+
log('\n# patch: delete d.ts files refering to rxjs-compat');
72+
// more info in https://github.com/angular/angular/pull/33786
73+
rm('-rf', [
74+
'node_modules/rxjs/add/',
75+
'node_modules/rxjs/observable/',
76+
'node_modules/rxjs/operator/',
77+
// rxjs/operators is a public entry point that also contains files to support legacy deep import
78+
// paths, so we need to preserve index.* and package.json files that are required for module
79+
// resolution.
80+
'node_modules/rxjs/operators/!(index.*|package.json)',
81+
'node_modules/rxjs/scheduler/',
82+
'node_modules/rxjs/symbol/',
83+
'node_modules/rxjs/util/',
84+
'node_modules/rxjs/internal/Rx.d.ts',
85+
'node_modules/rxjs/AsyncSubject.*',
86+
'node_modules/rxjs/BehaviorSubject.*',
87+
'node_modules/rxjs/InnerSubscriber.*',
88+
'node_modules/rxjs/interfaces.*',
89+
'node_modules/rxjs/Notification.*',
90+
'node_modules/rxjs/Observable.*',
91+
'node_modules/rxjs/Observer.*',
92+
'node_modules/rxjs/Operator.*',
93+
'node_modules/rxjs/OuterSubscriber.*',
94+
'node_modules/rxjs/ReplaySubject.*',
95+
'node_modules/rxjs/Rx.*',
96+
'node_modules/rxjs/Scheduler.*',
97+
'node_modules/rxjs/Subject.*',
98+
'node_modules/rxjs/SubjectSubscription.*',
99+
'node_modules/rxjs/Subscriber.*',
100+
'node_modules/rxjs/Subscription.*',
101+
]);
102+
103+
71104
log('===== finished running the postinstall-patches.js script =====');

0 commit comments

Comments
 (0)