@angular/compiler-cli >= 4.2.0 (ngc) not generating metadata.json file
See original GitHub issueI’m submitting a…
[ ] Regression (a behavior that used to work and stopped working in a new release)
[X] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request
Current behavior
We use the Angular Compiler CLI (ngc) in combination with Rollup to generate the correct bundles for our (internal) Angular library, following the Angular Package Format documentation. And @angular/compiler-cli
works as expected when used in version 4.1.3
, meaning that compilation works, sourcemaps are here, type definitions are getting generated correctly, and the metadata.json
file gets generated.
Any newer version of @angular/compiler-cli
, however, does not generate the metadata.json
file (while everything else seems to work properly).
Expected behavior
The @angular/compiler-cli
should generate the metadata.json
file on all versions / newer versions than 4.1.3
.
Minimal reproduction of the problem with instructions
Trying to run ngc -p tsconfig.json
in an Angular library project (e.g. https://github.com/dominique-mueller/angular-notifier) with the latest version of @angular/compiler-cli
results in the problem described above.
Full tsconfig.json for ES5 build:
{
"compileOnSave": false,
"compilerOptions": {
"declaration": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [
"es2016",
"dom"
],
"module": "es2015",
"moduleResolution": "node",
"outDir": "./../../build/library-es5", // Result, without the metadata.json file
"sourceMap": true,
"stripInternal": true,
"target": "es5"
},
"files": [
"./../../build/library-inline/index.ts" // Library source (after inlining HTML templates)
],
"angularCompilerOptions": {
"flatModuleId": "@something/my-lib",
"flatModuleOutFile": "my-lib.js",
"genDir": "./../../build/library-es5-gen-dir",
"skipTemplateCodegen": true,
"strictMetadataEmit": true
}
}
What is the motivation / use case for changing the behavior?
This issue prevents us from from publishing a library using the latest and greatest version of Angular. In addition, because in version 4.1.3
all Angular dependencies must exist in the same version (otherwise the build fails), this prevents us from using newer Angular features (such as the new HTTP client, amongst others).
Environment
Angular version:
- Tested with 4.1.3 -- working as expected
- Tested with 4.2.0, 4.3.0 and the latest (4.3.2) -- broken
For Tooling issues:
- Node version: 7.10.0
- Platform: Windows 7 & Windows 10
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:7
After analyzing https://github.com/dherges/ng-packagr, it seems that using @angular/tsc-wrapped works as expected. So probably an issue within @angular/compiler-cli wrapping around it?
I’ve been looking into this issue, and isolated the issue to be when the
tsconfig.json
file is not in the project root.I have put together a minimal reproduction here: https://github.com/michaelbromley/angular-issue-18478