ng build fails in esbuild optimization with `ERROR: Expected identifier but found "="`
See original GitHub issueCommand
build
Description
ng build
fails on esbuild optimization with an error
Minimal Reproduction
Reproduction: https://github.com/hirosystems/stacks.js-starters/tree/reproduce/angular-esbuild-fails-to-optimize/templates/template-angular
npm install
npm run build
Exception or Error
Error: Optimization error [main.108cfaa997006c95.js]: Error: Transform failed with 1 error:
main.108cfaa997006c95.js:51652:5: ERROR: Expected identifier but found "="
Your Environment
Angular CLI: 14.1.0
Node: 16.17.0
Package Manager: npm 8.15.0
OS: darwin arm64
Angular: 14.1.0
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1401.0
@angular-devkit/build-angular 14.1.0
@angular-devkit/core 14.1.0
@angular-devkit/schematics 14.1.0
@schematics/angular 14.1.0
rxjs 7.5.6
typescript 4.7.4
Anything else relevant?
Adding this commit https://github.com/hirosystems/stacks.js-starters/commit/a0937f3ae690c8a3d730c10003b03fd5c492c445 breaks the build
It seems to be a part of the esbuild optimization (disabling optimization for prod
fixes the build).
Issue Analytics
- State:
- Created a year ago
- Comments:8
Top Results From Across the Web
Webpack external module gives an error on optimization
If I run ng build --configuration production --base-href --optimization false it builds and I can see the line causing the error (main.
Read more >expected identifier but found * - You.com | The AI Search Engine ...
Scala Error: identifier expected but '}' found ... tl;dr the esbuild optimization fails with the following error in the @angular/cli:.
Read more >dfinity/agent 0.9.3 not working with Angular default settings
Hi! I'm trying to setup a simple call to https://identity.ic0.app. Building the default plain vanilla Angular app with @dfinity/agent fails ...
Read more >Angular package format
This document describes the Angular Package Format (APF). APF is an Angular specific specification for the structure and format of npm packages that...
Read more >How to build angular cli application with esbuild
Are you curious if it's possible to build ng-cli generate application with esbuild - js bundling tool... Tagged with esbuild, angular.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks for finding that line — helped a bunch! ✅ Issue resolved
Esbuild is doing the right thing here as indeed the bundle contains invalid syntax.
Webpack is generating wrong code and it a result of the large number of errors in the compilation.
Closing as this is not actionable and the error is expected since the inputted JavaScript has errors.