Skip to content

Commit 86266a3

Browse files
alan-agius4Keen Yee Liau
authored and
Keen Yee Liau
committed
fix(@ngtools/webpack): resources path normalizations
Compiler host `readResource` is always called with POSIX seperators. However the `denormalizePath` method doesn't convert forward slashes to back slashes which causes `getModifiedResourceFiles` to return an empty `Set`. We were also assuming that `_changedFiles` is an FS path which was not the case as it's original type is `Path` Fix #15012
1 parent 4cbf59b commit 86266a3

File tree

2 files changed

+8
-16
lines changed

2 files changed

+8
-16
lines changed

packages/angular_devkit/build_angular/test/browser/rebuild_spec_large.ts

-8
Original file line numberDiff line numberDiff line change
@@ -349,14 +349,6 @@ describe('Browser Builder rebuilds', () => {
349349
});
350350

351351
it('rebuilds AOT factories', async () => {
352-
// DISABLED_FOR_IVY - These should pass but require fixes for resource rebuilds
353-
// https://github.com/angular/angular/pull/30954
354-
if (ivyEnabled) {
355-
pending('Broken in Ivy.');
356-
357-
return;
358-
}
359-
360352
host.writeMultipleFiles({
361353
'src/app/app.component.css': `
362354
@import './imported-styles.css';

packages/ngtools/webpack/src/compiler_host.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export class WebpackCompilerHost implements ts.CompilerHost {
9191
try {
9292
exists = this._syncHost.isFile(fullPath);
9393
if (exists) {
94-
this._changedFiles.add(fullPath);
94+
this._changedFiles.add(workaroundResolve(fullPath));
9595
}
9696
} catch {}
9797

@@ -339,16 +339,15 @@ export class WebpackCompilerHost implements ts.CompilerHost {
339339
}
340340

341341
readResource(fileName: string) {
342-
this._readResourceFiles.add(fileName);
342+
// These paths are meant to be used by the loader so we must denormalize them
343+
const denormalizedFileName = workaroundResolve(fileName);
344+
this._readResourceFiles.add(denormalizedFileName);
343345

344346
if (this.directTemplateLoading && (fileName.endsWith('.html') || fileName.endsWith('.svg'))) {
345347
return this.readFile(fileName);
346348
}
347349

348350
if (this._resourceLoader) {
349-
// These paths are meant to be used by the loader so we must denormalize them.
350-
const denormalizedFileName = this.denormalizePath(normalize(fileName));
351-
352351
return this._resourceLoader.get(denormalizedFileName);
353352
} else {
354353
return this.readFile(fileName);
@@ -359,14 +358,15 @@ export class WebpackCompilerHost implements ts.CompilerHost {
359358
const modifiedFiles = new Set<string>();
360359

361360
for (const changedFile of this._changedFiles) {
362-
if (this._readResourceFiles.has(changedFile)) {
363-
modifiedFiles.add(changedFile);
361+
const denormalizedFileName = workaroundResolve(changedFile);
362+
if (this._readResourceFiles.has(denormalizedFileName)) {
363+
modifiedFiles.add(denormalizedFileName);
364364
}
365365

366366
if (!this._resourceLoader) {
367367
continue;
368368
}
369-
for (const resourcePath of this._resourceLoader.getAffectedResources(changedFile)) {
369+
for (const resourcePath of this._resourceLoader.getAffectedResources(denormalizedFileName)) {
370370
modifiedFiles.add(resourcePath);
371371
}
372372
}

0 commit comments

Comments
 (0)