@ngtools/webpack 12.1.0 → 12.1.4

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": "12.1.0",
3
+ "version": "12.1.4",
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/plugin.js CHANGED
@@ -362,17 +362,17 @@ class AngularWebpackPlugin {
362
362
  affectedFiles.add(result.affected);
363
363
  }
364
364
  }
365
- // Collect non-semantic diagnostics
365
+ // Collect program level diagnostics
366
366
  const diagnostics = [
367
367
  ...angularCompiler.getOptionDiagnostics(),
368
368
  ...builder.getOptionsDiagnostics(),
369
369
  ...builder.getGlobalDiagnostics(),
370
- ...builder.getSyntacticDiagnostics(),
371
370
  ];
372
371
  diagnosticsReporter(diagnostics);
373
- // Collect semantic diagnostics
372
+ // Collect source file specific diagnostics
374
373
  for (const sourceFile of builder.getSourceFiles()) {
375
374
  if (!ignoreForDiagnostics.has(sourceFile)) {
375
+ diagnosticsReporter(builder.getSyntacticDiagnostics(sourceFile));
376
376
  diagnosticsReporter(builder.getSemanticDiagnostics(sourceFile));
377
377
  }
378
378
  }
@@ -188,13 +188,38 @@ class WebpackResourceLoader {
188
188
  const parent = childCompiler.parentCompilation;
189
189
  if (parent) {
190
190
  parent.children = parent.children.filter((child) => child !== childCompilation);
191
- for (const fileDependency of childCompilation.fileDependencies) {
192
- if (data && containingFile && fileDependency.endsWith(entry)) {
191
+ let fileDependencies;
192
+ for (const dependency of childCompilation.fileDependencies) {
193
+ // Skip paths that do not appear to be files (have no extension).
194
+ // `fileDependencies` can contain directories and not just files which can
195
+ // cause incorrect cache invalidation on rebuilds.
196
+ if (!path.extname(dependency)) {
197
+ continue;
198
+ }
199
+ if (data && containingFile && dependency.endsWith(entry)) {
193
200
  // use containing file if the resource was inline
194
201
  parent.fileDependencies.add(containingFile);
195
202
  }
196
203
  else {
197
- parent.fileDependencies.add(fileDependency);
204
+ parent.fileDependencies.add(dependency);
205
+ }
206
+ // Save the dependencies for this resource.
207
+ if (filePath) {
208
+ const resolvedFile = paths_1.normalizePath(dependency);
209
+ const entry = this._reverseDependencies.get(resolvedFile);
210
+ if (entry) {
211
+ entry.add(filePath);
212
+ }
213
+ else {
214
+ this._reverseDependencies.set(resolvedFile, new Set([filePath]));
215
+ }
216
+ if (fileDependencies) {
217
+ fileDependencies.add(dependency);
218
+ }
219
+ else {
220
+ fileDependencies = new Set([dependency]);
221
+ this._fileDependencies.set(filePath, fileDependencies);
222
+ }
198
223
  }
199
224
  }
200
225
  parent.contextDependencies.addAll(childCompilation.contextDependencies);
@@ -202,30 +227,12 @@ class WebpackResourceLoader {
202
227
  parent.buildDependencies.addAll(childCompilation.buildDependencies);
203
228
  parent.warnings.push(...childCompilation.warnings);
204
229
  parent.errors.push(...childCompilation.errors);
205
- for (const { info, name, source } of childCompilation.getAssets()) {
206
- if (info.sourceFilename === undefined) {
207
- throw new Error(`'${name}' asset info 'sourceFilename' is 'undefined'.`);
208
- }
209
- (_a = this.assetCache) === null || _a === void 0 ? void 0 : _a.set(info.sourceFilename, { info, name, source });
210
- }
211
- }
212
- // Save the dependencies for this resource.
213
- if (filePath) {
214
- this._fileDependencies.set(filePath, new Set(childCompilation.fileDependencies));
215
- for (const file of childCompilation.fileDependencies) {
216
- const resolvedFile = paths_1.normalizePath(file);
217
- // Skip paths that do not appear to be files (have no extension).
218
- // `fileDependencies` can contain directories and not just files which can
219
- // cause incorrect cache invalidation on rebuilds.
220
- if (!path.extname(resolvedFile)) {
221
- continue;
222
- }
223
- const entry = this._reverseDependencies.get(resolvedFile);
224
- if (entry) {
225
- entry.add(filePath);
226
- }
227
- else {
228
- this._reverseDependencies.set(resolvedFile, new Set([filePath]));
230
+ if (this.assetCache) {
231
+ for (const { info, name, source } of childCompilation.getAssets()) {
232
+ // Use the originating file as the cache key if present
233
+ // Otherwise, generate a cache key based on the generated name
234
+ const cacheKey = (_a = info.sourceFilename) !== null && _a !== void 0 ? _a : `!![GENERATED]:${name}`;
235
+ this.assetCache.set(cacheKey, { info, name, source });
229
236
  }
230
237
  }
231
238
  }
@@ -127,7 +127,7 @@ function visitComponentMetadata(nodeFactory, node, styleReplacements, directTemp
127
127
  else if (inlineStyleFileExtension) {
128
128
  const data = Buffer.from(node.text).toString('base64');
129
129
  const containingFile = node.getSourceFile().fileName;
130
- url = `${containingFile}.${inlineStyleFileExtension}!=!${inlineDataLoaderPath}?data=${data}!${containingFile}`;
130
+ url = `${containingFile}.${inlineStyleFileExtension}!=!${inlineDataLoaderPath}?data=${encodeURIComponent(data)}!${containingFile}`;
131
131
  }
132
132
  else {
133
133
  return nodeFactory.createStringLiteral(node.text);