AngularM
AngularM

Reputation: 16618

Using ng-packagr it doesnt recognise my tsconfig paths

Using ng-packagr for my Angular 6 and AngularCLI app and it doesn't recognise my tsconfig paths with I do the build. A normal ng build --aot --prod works fine though.

These are my paths:

 "paths": {
    "@app/*": ["src/app/*"],
    "@env/*": ["src/environments/*"]
 }

My tsconfig.json:

{
  "compileOnSave": true,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "noImplicitAny": false,
    "noImplicitReturns": true,
    "noUnusedLocals": true,
    "experimentalDecorators": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2017",
      "dom"
    ],
    "paths": {
      "@app/*": ["src/app/*"],
      "@env/*": ["src/environments/*"]
    }
  }
}

Errors I get tend to be Cannot find module .... be cause it doesnt know what @app is for example.

The app also works fine when serving e.g. npm start.

Upvotes: 4

Views: 2750

Answers (1)

Ramy El-Basyouni
Ramy El-Basyouni

Reputation: 194

It is already a reported issue in ng-packagr repo, you can copy your tsconfig configuration to ng-packagr configuration file as ng-packagr is not reading from your tsconfig but it has its specific configuration while tgzing (building).

You can check the issue in their repo thread here:

https://github.com/dherges/ng-packagr/issues/519

Upvotes: 3

Related Questions