Skip to content

Commit 4cdd515

Browse files
clydinalxhub
authored andcommitted
build: remove unneeded babel types postinstall patching (angular#53374)
These patches are no longer necessary with the current state of the type packages and the code within the repository. The types are now included in the already required babel.d.ts file for the relevant babel packages (currently: `@babel/core` and `@babel/generator`). PR Close angular#53374
1 parent 3b12c59 commit 4cdd515

File tree

3 files changed

+6
-19
lines changed

3 files changed

+6
-19
lines changed

goldens/public-api/localize/tools/index.md

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
```ts
66

77
/// <reference types="@angular/compiler-cli/private/babel" />
8-
/// <reference types="@types/babel__core" />
98

109
import { AbsoluteFsPath } from '@angular/compiler-cli/private/localize';
1110
import { Element as Element_2 } from '@angular/compiler';

packages/compiler-cli/private/babel.d.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,9 @@
2020
// that is not governed by Bazel, and therefore not expected by the `strict_deps` rule.
2121
// Declaring the modules here allows `strict_deps` to always find a declaration of the modules
2222
// in an input file to the compilation, therefore accepting the module import.
23-
declare module '@babel/core' {}
24-
declare module '@babel/generator' {}
23+
declare module '@babel/core' {
24+
export * from '@types/babel__core';
25+
}
26+
declare module '@babel/generator' {
27+
export { default } from '@types/babel__generator';
28+
}

tools/postinstall-patches.js

-16
Original file line numberDiff line numberDiff line change
@@ -45,22 +45,6 @@ sed('-i', '(\'response\' in xhr)', '(\'response\' in (xhr as any))',
4545
'node_modules/rxjs/src/observable/dom/AjaxObservable.ts');
4646
*/
4747

48-
// Workaround https://github.com/bazelbuild/rules_nodejs/issues/1033
49-
// TypeScript doesn't understand typings without "declare module" unless
50-
// they are actually resolved by the @types default mechanism
51-
log('\n# patch: @types/babel__* adding declare module wrappers');
52-
ls('node_modules/@types').filter(f => f.startsWith('babel__')).forEach(pkg => {
53-
const modName = '@' + pkg.replace('__', '/');
54-
const typingsFile = `node_modules/@types/${pkg}/index.d.ts`;
55-
// Only add the patch if it is not already there.
56-
if (readFileSync(typingsFile, 'utf8').indexOf('/*added by tools/postinstall_patches.js*/') ===
57-
-1) {
58-
const insertPrefix = `/*added by tools/postinstall_patches.js*/ declare module "${modName}" { `;
59-
sed('-i', `(// Type definitions for ${modName})`, insertPrefix + '$1', typingsFile);
60-
echo('}').toEnd(typingsFile);
61-
}
62-
});
63-
6448
log('\n# patch: delete d.ts files referring to rxjs-compat');
6549
// more info in https://github.com/angular/angular/pull/33786
6650
rm('-rf', [

0 commit comments

Comments
 (0)