Skip to content

Commit 8439547

Browse files
filipesilvaZhicheng Wang
authored and
Zhicheng Wang
committed
fix(@ngtools/webpack): fix dependency for inline templates
1 parent 00c34d8 commit 8439547

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

packages/@ngtools/webpack/src/loader.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -594,18 +594,20 @@ export function ngcLoader(this: LoaderContext & { _compilation: any }, source: s
594594

595595
// NgFactory files depend on the component template, but we can't know what that file
596596
// is (if any). So we add all the dependencies that the original component file has
597-
// to the factory as well, which includes html and css templates.
597+
// to the factory as well, which includes html and css templates, and the component
598+
// itself (for inline html/templates templates).
598599
const ngFactoryRe = /\.ngfactory.js$/;
599600
if (ngFactoryRe.test(sourceFileName)) {
600601
const originalFile = sourceFileName.replace(ngFactoryRe, '.ts');
602+
this.addDependency(originalFile);
601603
const origDependencies = plugin.getDependencies(originalFile);
602604
origDependencies.forEach(dep => this.addDependency(dep));
603605
}
604606

605607
// NgStyle files depend on the style file they represent.
606608
// E.g. `some-style.less.shim.ngstyle.js` depends on `some-style.less`.
607609
// Those files can in turn depend on others, so we have to add them all.
608-
const ngStyleRe = /\.shim\.ngstyle\.js$/;
610+
const ngStyleRe = /(?:\.shim)?\.ngstyle\.js$/;
609611
if (ngStyleRe.test(sourceFileName)) {
610612
const styleFile = sourceFileName.replace(ngStyleRe, '');
611613
const styleDependencies = plugin.getResourceDependencies(styleFile);

0 commit comments

Comments
 (0)