Nx: Make existing library publishable

Created on 16 Jan 2020  路  3Comments  路  Source: nrwl/nx

Is there any way to convert existing non-publishable nrwl library into a publishable library using any CLI command?

misc feature

Most helpful comment

@sumitparakh Thanks for submitting this question. Right now there is no automated schematic that would be able to convert an existing library into a publishable one. We're going to take a look at this, but it requires some larger changes as it involves potentially multiple libraries (angular, node, react).

Meanwhile, you could manually adjust your library. I suggest

  1. creating a new nx workspace in separate folder with the same npmScope etc as your current workspace.
  2. Generate a new publishable library in that new workspace with the same name as the library you'd like to convert

That way you have the right names in the various files and you can copy them over to your existing workspace.

Once we decide to implement an automated migration, we'll let you know 馃槂

All 3 comments

@sumitparakh Thanks for submitting this question. Right now there is no automated schematic that would be able to convert an existing library into a publishable one. We're going to take a look at this, but it requires some larger changes as it involves potentially multiple libraries (angular, node, react).

Meanwhile, you could manually adjust your library. I suggest

  1. creating a new nx workspace in separate folder with the same npmScope etc as your current workspace.
  2. Generate a new publishable library in that new workspace with the same name as the library you'd like to convert

That way you have the right names in the various files and you can copy them over to your existing workspace.

Once we decide to implement an automated migration, we'll let you know 馃槂

Additionally to copy new files created by --publishable flag in the @juristr solution , is necessary some changes in the next files:

angular.json:
... "architect": { "build": { "builder": "@nrwl/angular:package", "options": { "tsConfig": "libs/<lib-name>/tsconfig.lib.json", "project": "libs/<lib-name>/ng-package.json" }, "configurations": { "production": { "tsConfig": "libs/<lib-name>/tsconfig.lib.prod.json" } } }, ...
package.json: add 1 dependency: tslib y 2 devdependencies: @angular-devkit/build-ng-packagr y ng-packagr.

Hi folks, do we have any progress on this ? I have a shared angular library in NX morepo workspace which is not publishable. I at least want it to be packageable (create .tgz package) so that I can push to AZURE artifacts and us it from there. Can anyone please help me with this like what steps to do so that I can package it ?
Thanks !

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dereklin picture dereklin  路  3Comments

vimalraj-a picture vimalraj-a  路  3Comments

elliotmendiola picture elliotmendiola  路  3Comments

markphip picture markphip  路  3Comments

zachnewburgh picture zachnewburgh  路  3Comments