Repository navigation
Closed
Labels
area: @angular-devkit/build-angularneeds: investigationRequires some digging to determine if action is needed
Description
Command
build
Is this a regression?
- Yes, this behavior used to work in the previous version
The previous version in which this bug was not present was
16.0.0
Description
Upon updating @angular-devkit/build-angular to Version 16.1.0, an error occurs during index HTML generation. The specific error message is "document.documentElement.setAttribute is not a function."
Upon investigation, I have identified the root cause of the issue. It appears that enabling the optimization option, specifically setting inlineCritical to True under styles, triggers the error. However, if this option is disabled, the build process completes successfully.
Minimal Reproduction
Command used:
npx nx run project:build:production
Package use:
@angular-devkit/build-angular 16.1.0
Exception or Error
√ Browser application bundle generation complete.
√ Copying assets complete.
× Index html generation failed.
document.documentElement.setAttribute is not a function
——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
> NX Ran target build for project *projectname* (58s)
× 1/1 failed
√ 0/1 succeeded [0 read from cache]
Your Environment
Angular CLI: 16.1.0
Node: 18.10.0
Package Manager: npm 8.19.2
OS: win32 x64
Angular: 16.1.1
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1601.0
@angular-devkit/build-angular 16.1.0
@angular-devkit/core 16.1.0
@angular-devkit/schematics 16.1.0
@angular/cli 16.1.0
@schematics/angular 16.1.0
rxjs 7.8.1
typescript 5.1.3
Anything else relevant?
No response
Reacted by Nischi, Vlad Ioffe, Matija Pevec, Markus Falk, Georgi Serev, Marcin Ciesielski, LousyJohnny, Bastien, digitalhurricane-io, amadeusjposchmann and 3 more
Reacted by Paul Stelzer
Metadata
Metadata
Assignees
Labels
area: @angular-devkit/build-angularneeds: investigationRequires some digging to determine if action is needed
Activity
klerick commentedon Jun 22, 2023
heikofritz commentedon Jun 22, 2023
alan-agius4 commentedon Jun 23, 2023
I suspect that this is caused because the
index.htmldoes not have HTML tags.Can you confirm that your
index.htmlis a valid HTML document?PascalSwissDev commentedon Jun 23, 2023
I can indeed verify that the index.html is valid. The only modification required is downgrading the version number to 16.0.0, after which it will function properly with the unchanged index.html.
paulstelzer commentedon Jun 23, 2023
I can canfirm what @PascalSwissDev says. index.html is valid and if I reduce the index.html to only what it really needs the same error occurs. If i set inlinecritital to false or move back to 16.0.* everything is working again. But I have other projects with Angular 16.1 who are working without problems. So it seems to be a third-party-package that impacts the issue.
alan-agius4 commentedon Jun 23, 2023
Can you setup a minimal repro please?
You can read here why this is needed. A good way to make a minimal repro is to create a new app via
ng new repro-appand adding the minimum possible code to show the problem. Then you can push this repository to github and link it here.13 remaining items
Akxe commentedon Jun 27, 2023
It may be caused because of NPM vs YARN. I use NPM.
Use reactions to show what you use:
Deleting the
node_modulesfolder &package-lock.jsonand reinstalling did solve the issue too. I do really thing it might be an NPM issue when updating. I did update from16.0.x=>16.1.xJanST123 commentedon Jun 29, 2023
Same issue here - the cause was also that domhandler 4.x was an additional dependency to domhandler 5.x. In my case this dependency was caused by @capacitor/* which I was using in version 4.x. Upgrading to 5.x fixed the problem
niekhoogmanedap commentedon Jul 2, 2023
Same problem here.
It seems to be gone when
inlineCritical: falseinangular.json.Full path:
projects.app.architect.build.configurations.development.optimization.styles.inlineCritical
blueiceprj commentedon Jul 13, 2023
This worked for me. Thanks.
Moustingle commentedon Jul 20, 2023
I had the same problems, and changing the angular.json did not help in my case.
As mentionned earlier by several people, I manually installed
domhandlerwith npm and everything went back to normal, with no modifications needed inside the angular.json.marksulls commentedon Jul 21, 2023
This worked for me. Thank you.
alan-agius4 commentedon Jul 26, 2023
Repo from #25575:
https://github.com/majoer/angular-csp-link-bug
fix(@angular-devkit/build-angular): error during critical CSS inlinin…
fix(@angular-devkit/build-angular): error during critical CSS inlinin…
fix(@angular-devkit/build-angular): error during critical CSS inlinin…
angular-automatic-lock-bot commentedon Aug 26, 2023
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.