Skip to content

Commit e269221

Browse files
committed
refactor(@angular-devkit/build-angular): remove babel core runtime imports from pure-toplevel-functions build optimizer pass
The `pure-toplevel-functions` build optimization pass have been cleaned up and restructured to remove the need for a direct runtime dependency on `@babel/core`.
1 parent 8216b11 commit e269221

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

packages/angular_devkit/build_angular/src/tools/babel/plugins/pure-toplevel-functions.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import { NodePath, PluginObj, types } from '@babel/core';
9+
import type { PluginObj } from '@babel/core';
1010
import annotateAsPure from '@babel/helper-annotate-as-pure';
1111
import * as tslib from 'tslib';
1212

@@ -40,28 +40,28 @@ function isTslibHelperName(name: string): boolean {
4040
export default function (): PluginObj {
4141
return {
4242
visitor: {
43-
CallExpression(path: NodePath<types.CallExpression>) {
43+
CallExpression(path) {
4444
// If the expression has a function parent, it is not top-level
4545
if (path.getFunctionParent()) {
4646
return;
4747
}
4848

49-
const callee = path.node.callee;
49+
const callee = path.get('callee');
5050
if (
51-
(types.isFunctionExpression(callee) || types.isArrowFunctionExpression(callee)) &&
51+
(callee.isFunctionExpression() || callee.isArrowFunctionExpression()) &&
5252
path.node.arguments.length !== 0
5353
) {
5454
return;
5555
}
5656
// Do not annotate TypeScript helpers emitted by the TypeScript compiler.
5757
// TypeScript helpers are intended to cause side effects.
58-
if (types.isIdentifier(callee) && isTslibHelperName(callee.name)) {
58+
if (callee.isIdentifier() && isTslibHelperName(callee.node.name)) {
5959
return;
6060
}
6161

6262
annotateAsPure(path);
6363
},
64-
NewExpression(path: NodePath<types.NewExpression>) {
64+
NewExpression(path) {
6565
// If the expression has a function parent, it is not top-level
6666
if (!path.getFunctionParent()) {
6767
annotateAsPure(path);

0 commit comments

Comments
 (0)