0

I have created an Angular library. I'm using ng-packagr to build the library. When I am building the library with ng-packagr it creates the .metada.json for AOT in the directory where the public_api.ts file exists.

Can we change the .metdata.json generated directory to be inside the 'dist' folder?

ng-package.json

{
  "$schema": "./node_modules/ng-packagr/ng-package.schema.json",
  "lib": {
    "entryFile": "public_api.ts",
    "languageLevel": [
      "dom",
      "es2017"
    ]
  },
  "whitelistedNonPeerDependencies": [
    "@angular/*",
    "core-js",
    "rxjs",
    "zone.js",
    "moment",
    "aws-sdk"
  ]
}

tsconfig.json

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": ".",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "module": "commonjs",
    "moduleResolution": "node",
    "rootDir": ".",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "inlineSources": true,
    "skipLibCheck": true,
    "noImplicitAny": false,
    "declaration": false,
    "target": "es5",
    "lib": [
      "es7",
      "dom"
    ],
    "typeRoots": [
      "node_modules/@types"
    ],
    "types": [
      "node",
      "jasmine"
    ]
  },
  "angularCompilerOptions": {
    "skipTemplateCodegen": true,
    "strictMetadataEmit": true,
    "fullTemplateTypeCheck": true
  },
  "exclude": [
    "node_modules"
  ]
}
nuwan.chamara
  • 467
  • 5
  • 14
  • If you change metadata.json, your changes won't persist when you do npm install next time. It will get overridden. You can move those package inside src folder and import from there. – Suresh Kumar Ariya Oct 10 '18 at 03:52
  • I actually don't want to change the content of the metadata.json file. I want the metadata.json file to be generated inside a folder named 'dist' when the library is built using 'ng-packagr -p ng-package.json' command. Current it is generated along with the source files in 'src' directory. Thanks. – nuwan.chamara Oct 10 '18 at 04:38
  • 1
    can you share the ngPackgr `ng-package.json` configuration? It should create those stuff inside the output folder – Vivek Kumar Oct 10 '18 at 05:47
  • @VivekKumar I updated the question with ng-package.json and ts-config.json – nuwan.chamara Oct 10 '18 at 09:06

1 Answers1

1

If you creating this project from start and using the latest angular version or even angular version 5, Then I would suggest you use Nx Workspace.

It make this angular package creation process very simple,

Vivek Kumar
  • 4,822
  • 8
  • 51
  • 85