@ngtools/webpack 14.2.1 → 14.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ngtools/webpack",
3
- "version": "14.2.1",
3
+ "version": "14.2.3",
4
4
  "description": "Webpack plugin that AoT compiles your Angular components and modules.",
5
5
  "main": "./src/index.js",
6
6
  "typings": "src/index.d.ts",
@@ -77,6 +77,11 @@ function mergeTransformers(first, second) {
77
77
  return result;
78
78
  }
79
79
  exports.mergeTransformers = mergeTransformers;
80
+ /**
81
+ * The name of the Angular platform that should be replaced within
82
+ * bootstrap call expressions to support AOT.
83
+ */
84
+ const PLATFORM_BROWSER_DYNAMIC_NAME = 'platformBrowserDynamic';
80
85
  function replaceBootstrap(getTypeChecker) {
81
86
  return (context) => {
82
87
  let bootstrapImport;
@@ -86,7 +91,7 @@ function replaceBootstrap(getTypeChecker) {
86
91
  const visitNode = (node) => {
87
92
  if (ts.isCallExpression(node) && ts.isIdentifier(node.expression)) {
88
93
  const target = node.expression;
89
- if (target.text === 'platformBrowserDynamic') {
94
+ if (target.text === PLATFORM_BROWSER_DYNAMIC_NAME) {
90
95
  if (!bootstrapNamespace) {
91
96
  bootstrapNamespace = nodeFactory.createUniqueName('__NgCli_bootstrap_');
92
97
  bootstrapImport = nodeFactory.createImportDeclaration(undefined, undefined, nodeFactory.createImportClause(false, undefined, nodeFactory.createNamespaceImport(bootstrapNamespace)), nodeFactory.createStringLiteral('@angular/platform-browser'));
@@ -98,6 +103,9 @@ function replaceBootstrap(getTypeChecker) {
98
103
  return ts.visitEachChild(node, visitNode, context);
99
104
  };
100
105
  return (sourceFile) => {
106
+ if (!sourceFile.text.includes(PLATFORM_BROWSER_DYNAMIC_NAME)) {
107
+ return sourceFile;
108
+ }
101
109
  let updatedSourceFile = ts.visitEachChild(sourceFile, visitNode, context);
102
110
  if (bootstrapImport) {
103
111
  // Remove any unused platform browser dynamic imports