@ngtools/webpack 19.0.0-next.8 → 19.0.0-rc.0

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License
2
2
 
3
- Copyright (c) 2017 Google, Inc.
3
+ Copyright (c) 2010-2024 Google LLC. https://angular.dev/license
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -9,13 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
9
  copies of the Software, and to permit persons to whom the Software is
10
10
  furnished to do so, subject to the following conditions:
11
11
 
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
14
 
15
15
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
16
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
17
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
18
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
19
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ngtools/webpack",
3
- "version": "19.0.0-next.8",
3
+ "version": "19.0.0-rc.0",
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",
package/src/ivy/host.d.ts CHANGED
@@ -28,6 +28,5 @@ export declare function augmentHostWithResources(host: ts.CompilerHost, resource
28
28
  export declare function augmentHostWithDependencyCollection(host: ts.CompilerHost, dependencies: Map<string, Set<string>>, moduleResolutionCache?: ts.ModuleResolutionCache): void;
29
29
  export declare function augmentHostWithReplacements(host: ts.CompilerHost, replacements: Record<string, string>, moduleResolutionCache?: ts.ModuleResolutionCache): void;
30
30
  export declare function augmentHostWithSubstitutions(host: ts.CompilerHost, substitutions: Record<string, string>): void;
31
- export declare function augmentHostWithVersioning(host: ts.CompilerHost): void;
32
31
  export declare function augmentProgramWithVersioning(program: ts.Program): void;
33
32
  export declare function augmentHostWithCaching(host: ts.CompilerHost, cache: Map<string, ts.SourceFile>): void;
package/src/ivy/host.js CHANGED
@@ -34,7 +34,6 @@ exports.augmentHostWithResources = augmentHostWithResources;
34
34
  exports.augmentHostWithDependencyCollection = augmentHostWithDependencyCollection;
35
35
  exports.augmentHostWithReplacements = augmentHostWithReplacements;
36
36
  exports.augmentHostWithSubstitutions = augmentHostWithSubstitutions;
37
- exports.augmentHostWithVersioning = augmentHostWithVersioning;
38
37
  exports.augmentProgramWithVersioning = augmentProgramWithVersioning;
39
38
  exports.augmentHostWithCaching = augmentHostWithCaching;
40
39
  const crypto_1 = require("crypto");
@@ -189,16 +188,6 @@ function augmentHostWithSubstitutions(host, substitutions) {
189
188
  return file;
190
189
  };
191
190
  }
192
- function augmentHostWithVersioning(host) {
193
- const baseGetSourceFile = host.getSourceFile;
194
- host.getSourceFile = function (...parameters) {
195
- const file = baseGetSourceFile.call(host, ...parameters);
196
- if (file && file.version === undefined) {
197
- file.version = (0, crypto_1.createHash)('sha256').update(file.text).digest('hex');
198
- }
199
- return file;
200
- };
201
- }
202
191
  function augmentProgramWithVersioning(program) {
203
192
  const baseGetSourceFiles = program.getSourceFiles;
204
193
  program.getSourceFiles = function (...parameters) {
package/src/ivy/plugin.js CHANGED
@@ -95,7 +95,7 @@ class AngularWebpackPlugin {
95
95
  return this.pluginOptions;
96
96
  }
97
97
  apply(compiler) {
98
- const { NormalModuleReplacementPlugin, WebpackError, util } = compiler.webpack;
98
+ const { NormalModuleReplacementPlugin, util } = compiler.webpack;
99
99
  this.webpackCreateHash = util.createHash;
100
100
  // Setup file replacements with webpack
101
101
  for (const [key, value] of Object.entries(this.pluginOptions.fileReplacements)) {
@@ -468,7 +468,7 @@ class AngularWebpackPlugin {
468
468
  ...builder.getSemanticDiagnostics(),
469
469
  ];
470
470
  diagnosticsReporter(diagnostics);
471
- const transformers = (0, transformation_1.createJitTransformers)(builder, this.compilerCli, this.pluginOptions);
471
+ const transformers = (0, transformation_1.createJitTransformers)(builder, this.compilerCliTooling, this.pluginOptions);
472
472
  return {
473
473
  fileEmitter: this.createFileEmitter(builder, transformers, () => []),
474
474
  builder,
@@ -5,5 +5,5 @@
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://angular.dev/license
7
7
  */
8
- import * as ts from 'typescript';
8
+ import ts from 'typescript';
9
9
  export declare function findImageDomains(imageDomains: Set<string>): ts.TransformerFactory<ts.SourceFile>;
@@ -6,33 +6,12 @@
6
6
  * Use of this source code is governed by an MIT-style license that can be
7
7
  * found in the LICENSE file at https://angular.dev/license
8
8
  */
9
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- var desc = Object.getOwnPropertyDescriptor(m, k);
12
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
- desc = { enumerable: true, get: function() { return m[k]; } };
14
- }
15
- Object.defineProperty(o, k2, desc);
16
- }) : (function(o, m, k, k2) {
17
- if (k2 === undefined) k2 = k;
18
- o[k2] = m[k];
19
- }));
20
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
21
- Object.defineProperty(o, "default", { enumerable: true, value: v });
22
- }) : function(o, v) {
23
- o["default"] = v;
24
- });
25
- var __importStar = (this && this.__importStar) || function (mod) {
26
- if (mod && mod.__esModule) return mod;
27
- var result = {};
28
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
29
- __setModuleDefault(result, mod);
30
- return result;
9
+ var __importDefault = (this && this.__importDefault) || function (mod) {
10
+ return (mod && mod.__esModule) ? mod : { "default": mod };
31
11
  };
32
12
  Object.defineProperty(exports, "__esModule", { value: true });
33
13
  exports.findImageDomains = findImageDomains;
34
- const ts = __importStar(require("typescript"));
35
- const TARGET_TEXT = '@NgModule';
14
+ const typescript_1 = __importDefault(require("typescript"));
36
15
  const BUILTIN_LOADERS = new Set([
37
16
  'provideCloudflareLoader',
38
17
  'provideCloudinaryLoader',
@@ -47,105 +26,105 @@ function findImageDomains(imageDomains) {
47
26
  return BUILTIN_LOADERS.has(node.expression.getText());
48
27
  };
49
28
  const findDomainString = (node) => {
50
- if (ts.isStringLiteral(node) ||
51
- ts.isTemplateHead(node) ||
52
- ts.isTemplateMiddle(node) ||
53
- ts.isTemplateTail(node)) {
29
+ if (typescript_1.default.isStringLiteral(node) ||
30
+ typescript_1.default.isTemplateHead(node) ||
31
+ typescript_1.default.isTemplateMiddle(node) ||
32
+ typescript_1.default.isTemplateTail(node)) {
54
33
  const domain = node.text.match(URL_REGEX);
55
34
  if (domain && domain[0]) {
56
35
  imageDomains.add(domain[0]);
57
36
  return node;
58
37
  }
59
38
  }
60
- ts.visitEachChild(node, findDomainString, context);
39
+ typescript_1.default.visitEachChild(node, findDomainString, context);
61
40
  return node;
62
41
  };
63
42
  function isImageProviderKey(property) {
64
- return (ts.isPropertyAssignment(property) &&
43
+ return (typescript_1.default.isPropertyAssignment(property) &&
65
44
  property.name.getText() === 'provide' &&
66
45
  property.initializer.getText() === 'IMAGE_LOADER');
67
46
  }
68
47
  function isImageProviderValue(property) {
69
- return ts.isPropertyAssignment(property) && property.name.getText() === 'useValue';
48
+ return typescript_1.default.isPropertyAssignment(property) && property.name.getText() === 'useValue';
70
49
  }
71
50
  function checkForDomain(node) {
72
51
  if (node.properties.find(isImageProviderKey)) {
73
52
  const value = node.properties.find(isImageProviderValue);
74
- if (value && ts.isPropertyAssignment(value)) {
75
- if (ts.isArrowFunction(value.initializer) ||
76
- ts.isFunctionExpression(value.initializer)) {
77
- ts.visitEachChild(node, findDomainString, context);
53
+ if (value && typescript_1.default.isPropertyAssignment(value)) {
54
+ if (typescript_1.default.isArrowFunction(value.initializer) ||
55
+ typescript_1.default.isFunctionExpression(value.initializer)) {
56
+ typescript_1.default.visitEachChild(node, findDomainString, context);
78
57
  }
79
58
  }
80
59
  }
81
60
  }
82
61
  function findImageLoaders(node) {
83
- if (ts.isCallExpression(node)) {
62
+ if (typescript_1.default.isCallExpression(node)) {
84
63
  if (isBuiltinImageLoader(node)) {
85
64
  const firstArg = node.arguments[0];
86
- if (ts.isStringLiteralLike(firstArg)) {
65
+ if (typescript_1.default.isStringLiteralLike(firstArg)) {
87
66
  imageDomains.add(firstArg.text);
88
67
  }
89
68
  }
90
69
  }
91
- else if (ts.isObjectLiteralExpression(node)) {
70
+ else if (typescript_1.default.isObjectLiteralExpression(node)) {
92
71
  checkForDomain(node);
93
72
  }
94
73
  return node;
95
74
  }
96
75
  function findProvidersAssignment(node) {
97
- if (ts.isPropertyAssignment(node)) {
98
- if (ts.isIdentifier(node.name) && node.name.escapedText === 'providers') {
99
- ts.visitEachChild(node.initializer, findImageLoaders, context);
76
+ if (typescript_1.default.isPropertyAssignment(node)) {
77
+ if (typescript_1.default.isIdentifier(node.name) && node.name.escapedText === 'providers') {
78
+ typescript_1.default.visitEachChild(node.initializer, findImageLoaders, context);
100
79
  }
101
80
  }
102
81
  return node;
103
82
  }
104
83
  function findFeaturesAssignment(node) {
105
- if (ts.isPropertyAssignment(node)) {
106
- if (ts.isIdentifier(node.name) &&
84
+ if (typescript_1.default.isPropertyAssignment(node)) {
85
+ if (typescript_1.default.isIdentifier(node.name) &&
107
86
  node.name.escapedText === 'features' &&
108
- ts.isArrayLiteralExpression(node.initializer)) {
87
+ typescript_1.default.isArrayLiteralExpression(node.initializer)) {
109
88
  const providerElement = node.initializer.elements.find(isProvidersFeatureElement);
110
89
  if (providerElement &&
111
- ts.isCallExpression(providerElement) &&
90
+ typescript_1.default.isCallExpression(providerElement) &&
112
91
  providerElement.arguments[0]) {
113
- ts.visitEachChild(providerElement.arguments[0], findImageLoaders, context);
92
+ typescript_1.default.visitEachChild(providerElement.arguments[0], findImageLoaders, context);
114
93
  }
115
94
  }
116
95
  }
117
96
  return node;
118
97
  }
119
98
  function isProvidersFeatureElement(node) {
120
- return (ts.isCallExpression(node) &&
121
- ts.isPropertyAccessExpression(node.expression) &&
122
- ts.isIdentifier(node.expression.expression) &&
99
+ return (typescript_1.default.isCallExpression(node) &&
100
+ typescript_1.default.isPropertyAccessExpression(node.expression) &&
101
+ typescript_1.default.isIdentifier(node.expression.expression) &&
123
102
  node.expression.expression.escapedText === 'i0' &&
124
- ts.isIdentifier(node.expression.name) &&
103
+ typescript_1.default.isIdentifier(node.expression.name) &&
125
104
  node.expression.name.escapedText === 'ɵɵProvidersFeature');
126
105
  }
127
106
  function findPropertyDeclaration(node) {
128
- if (ts.isPropertyDeclaration(node) &&
129
- ts.isIdentifier(node.name) &&
107
+ if (typescript_1.default.isPropertyDeclaration(node) &&
108
+ typescript_1.default.isIdentifier(node.name) &&
130
109
  node.initializer &&
131
- ts.isCallExpression(node.initializer) &&
110
+ typescript_1.default.isCallExpression(node.initializer) &&
132
111
  node.initializer.arguments[0]) {
133
112
  if (node.name.escapedText === 'ɵinj') {
134
- ts.visitEachChild(node.initializer.arguments[0], findProvidersAssignment, context);
113
+ typescript_1.default.visitEachChild(node.initializer.arguments[0], findProvidersAssignment, context);
135
114
  }
136
115
  else if (node.name.escapedText === 'ɵcmp') {
137
- ts.visitEachChild(node.initializer.arguments[0], findFeaturesAssignment, context);
116
+ typescript_1.default.visitEachChild(node.initializer.arguments[0], findFeaturesAssignment, context);
138
117
  }
139
118
  }
140
119
  return node;
141
120
  }
142
121
  function findClassDeclaration(node) {
143
- if (ts.isClassDeclaration(node)) {
144
- ts.visitEachChild(node, findPropertyDeclaration, context);
122
+ if (typescript_1.default.isClassDeclaration(node)) {
123
+ typescript_1.default.visitEachChild(node, findPropertyDeclaration, context);
145
124
  }
146
125
  return node;
147
126
  }
148
- ts.visitEachChild(sourceFile, findClassDeclaration, context);
127
+ typescript_1.default.visitEachChild(sourceFile, findClassDeclaration, context);
149
128
  return sourceFile;
150
129
  };
151
130
  };