I've explored various options before seeking help here. I have an angular2 library that has been AOT compiled using ngc. Currently, I am not using webpack and solely relying on plain npm scripts. Below is the tsconfig file being utilized:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false,
"lib": ["dom","es2015"],
"outDir": "tsc-out"
},
"compileOnSave": true,
"exclude": [
"node_modules/*",
"aot/",
"app/boot-aot.ts"
],
"angularCompilerOptions": {
"genDir": "aot/",
"strictMetadataEmit" : true
}
}
When running ngc, it generates a folder named "aot" which includes a "node_modules" subfolder as illustrated below.
Contents within the aot folder:
app
node_modules
@angular
@ngbootstrap
rxjs
As of now, all factories appear to be in order but they are saved as ts files. My plan is to run tsc on this output so I can utilize these factories in a native ES5 environment. Therefore, I attempted to execute tsc on this directory utilizing a different tsconfig file.
However, this method doesn't reproduce the node_modules folder. Consequently, some of the generated factory files contain errors as they still reference the absent node_modules folder. For instance, the app.module.ngfactory.js (located inside app folder) contains references like:
var import59 = require("../node_modules/@ng-bootstrap/ng-
bootstrap/tooltip/tooltip.ngfactory");
var import60 = require("../node_modules/@ng-bootstrap/ng-
bootstrap/typeahead/typeahead-window.ngfactory");
Am I overlooking something crucial here? Despite trying out numerous variations, it seems I'm lacking certain details. Is there a way to expose these aot factories to ES5 given the current behavior of ngc and tsc?