1

I'm trying to build an Angular 6 library for CI integration without integrate it into an Angular App. (for numerous reasons)

What i have done so far is:

  • create a package.json in order to install all the lib's dependencies
  • create an angular.json like regular angular6 app refering to ci files (see below)
  • duplicate all ng-packages.\*.json to ng-package.ci.\*.json and update their paths to refer to the right files and directories (node_modules, entryfiles, etc..)
  • duplicate all ts-config.\*.json to tsconfig.ci.\*.json and update their paths to refer to the right files and directories (src, dist, etc..)

I was expected by running ng build to be able able to build the library but instead i have this message:

Versions of @angular/compiler-cli and typescript could not be determined.

( But all packages are installed; i check it twice)

Does anyone has ever tried to build its Angular 6 library without using the library inside an app?

Thx

sebastian
  • 11
  • 1

2 Answers2

0

It currently isn't possible, but there is an open issue for it here:

https://github.com/angular/angular-cli/issues/10751

Snackdex
  • 674
  • 8
  • 18
0

I reply to your answer because i was able to solve all my problems.

  • I'am now able to build (test, lint) an angular Library in a CI pipeline
  • I can integrate this library into an angular project.

Here is the way i done it. I generated a library in an almost empty directory. To do ng generate library my-lib --skip-package-json --skip-ts-config you need to have a package.json file, and an angular.json file in this directory. I picked the these files from a fresh new app ng new app and remove the app reference from the workspace into the angular.json (in the projects section)

Once the library was generated i created a folder ci at the root where i copied the files tsconfig.*.json, karma.json, ng-package.json and package.json. I keepted the original files at root in order to be able to use the library in integrated mode into an app. (just need to add the lib reference into the angular.json of your app, like if it was generated + path in stconfig of your app)

I updated the paths in all files in the ci folder in order to be able to run a command such as :

  • ng lint --format stylish --tslint-config ci/tslint.ci.json
  • ng build by setting the default project in angular.json to my-lib anf pointing to tsconfig and ng-package in the ci folder

One tip, the package.json at the roots needs to have all the dependencies from an new angular app to be able to build or test the library.

Hope this brief explanation will help.

sebastian
  • 11
  • 1