While working with Angular and attempting to build a large library using the command ng build <project>
, we encountered the following issue:
❌ Generating "fesm2015"
Invalid string length
The build for fesm2020 was successful, but the sourcemap size for fesm2015 exceeded expectations, reaching 33MB compared to fesm2020's 32MB (.mjs.map file).
This large size is attributed to approximately 200 components being distributed within a single library.
To Reproduce:
- Create over 200 components and include them in a single library module
- Run
ng build <project>
Error Message:
Invalid string length
occurs after Generating fesm2015
Environment Details:
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 14.2.6
Node: 18.15.0 (Unsupported)
Package Manager: npm 9.5.0
OS: win32 x64
Angular: 14.2.6
... animations, cli, common, compiler, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1402.6
@angular-devkit/build-angular 14.2.6
@angular-devkit/core 14.2.6
@angular-devkit/schematics 14.2.6
@angular/compiler-cli 14.3.0
@schematics/angular 14.2.6
ng-packagr 14.0.1
rxjs 6.5.4
typescript 4.7.3
We are seeking suggestions on how to address this issue and gain more visibility into the error without verbose output. We prefer not to divide the code into separate libraries, even if it appears to be related to source code size or length.