You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
@ngtools/webpack: Using pug causes templates not to reload without skipping code generation #8509
Generate new project and in node_modules/@angular/cli/models/webpack-configs/common.js
add { test: /.pug$/, use: ["apply-loader", "pug-loader"] }, to line 163 as the first rule. Then change your app.component.html to app.component.pug and start the server with --aot. Make a change to the pug file and look at the browser.
The log given by the failure.
none
Desired functionality.
Would like pug templates to recompile, currently it's impossible to develop properly with pug without this as I have to restart the build anytime I make changes!
Mention any other details that might be useful.
I would love to help out if I can just point me in the right direction. I've found that inside node_modules/@angular/cli/models/webpack-configs/typescript.js in the getAotConfig function, adding {skipCodeGeneration: true} to the plugin options passed to _createAotPlugin causes the templates to get recompiled properly when changed.
I'm thrilled to see this getting attention, I used Pug/Jade heavily in the AngularJS 1.x era and benefited greatly from it. This issue talks about reaching in and editing "node_modules/@angular/cli/models/webpack-configs/common.js" (!) but from it being assigned a highish priority, do we have reason to hope the setting to enable Pug will be emerging to user space soon?
@kylecordes I think this issue may exist just purely using the plugin itself, so people with ejected webpack configs running in AoT mode might possible suffer from this
@MikaAK I'm running a manually constructed webpack config and I'm seeing this issue as well. I was able to determine that while it does correctly detect a change as long as the rule specifying the @ngtools/webpack loader uses the test pattern /(?:\.ngfactory\.js|\.ngstyle\.js|\.ts)$/ (changes do not get detected at all if you just use /\.ts$/), the pug rule doesn't even get invoked when a change is detected (verified by adding a simple debugging loader before and after the pug loader). This is odd since obviously it works fine when a plain html file is used. I'm wondering if there's something missing in the tooling (possibly the pug loader?) that allows webpack to map the change detected in the pug file back to the originating component/.ts file? Or, maybe it is mapped to the .ts file, but needs to be mapped to the .ngfactory file?
By the way, adding { skipCodeGeneration: true } completely breaks it for me - I get an error: Could not resolve module src/app.module. I don't understand how that would work anyhow, isn't that what controls whether it generates the .ngfactory stuff?
(also, you aren't escaping the . in your pug rule test pattern)
Ha what an easy fix, nice find @DanielSchaffer
Hopefully we see this as a configurable option because I'm assuming my graphql queries wouldn't be reloaded either without manually going to this file and adding |graphql|gql
Activity
kylecordes commentedon Nov 26, 2017
I'm thrilled to see this getting attention, I used Pug/Jade heavily in the AngularJS 1.x era and benefited greatly from it. This issue talks about reaching in and editing "node_modules/@angular/cli/models/webpack-configs/common.js" (!) but from it being assigned a highish priority, do we have reason to hope the setting to enable Pug will be emerging to user space soon?
MikaAK commentedon Nov 27, 2017
@kylecordes I think this issue may exist just purely using the plugin itself, so people with ejected webpack configs running in AoT mode might possible suffer from this
DanielSchaffer commentedon Jan 26, 2018
@MikaAK I'm running a manually constructed webpack config and I'm seeing this issue as well. I was able to determine that while it does correctly detect a change as long as the rule specifying the
@ngtools/webpackloader uses the test pattern/(?:\.ngfactory\.js|\.ngstyle\.js|\.ts)$/(changes do not get detected at all if you just use/\.ts$/), the pug rule doesn't even get invoked when a change is detected (verified by adding a simple debugging loader before and after the pug loader). This is odd since obviously it works fine when a plain html file is used. I'm wondering if there's something missing in the tooling (possibly the pug loader?) that allows webpack to map the change detected in the pug file back to the originating component/.tsfile? Or, maybe it is mapped to the.tsfile, but needs to be mapped to the.ngfactoryfile?By the way, adding
{ skipCodeGeneration: true }completely breaks it for me - I get an error:Could not resolve module src/app.module. I don't understand how that would work anyhow, isn't that what controls whether it generates the.ngfactorystuff?(also, you aren't escaping the
.in your pug rule test pattern)DanielSchaffer commentedon Jan 26, 2018
I think I just found the fix, and it's literally just adding 4 characters (
|pug) toangular_compiler_plugin.ts:Though, it seems like something like this should be configurable rather than hardcoded...
fix(@angular/cli): include .pug files in output of `_getChangedCompil…
fix(@angular/cli): fix templates not being updated when using pug
MikaAK commentedon Jan 26, 2018
Ha what an easy fix, nice find @DanielSchaffer
Hopefully we see this as a configurable option because I'm assuming my graphql queries wouldn't be reloaded either without manually going to this file and adding
|graphql|gqlangular-automatic-lock-bot commentedon Sep 7, 2019
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.