Nx: @nrwl/workspace:library: support publishable libraries

Created on 9 Mar 2020  路  7Comments  路  Source: nrwl/nx

Expected Behavior

To officially support nx generate @nrwl/workspace:library --name pubtest --publishable

The idea is to publish a framework-less library

Current Behavior

> nx generate @nrwl/workspace:library --name pubtest --publishable
Could not match option 'publishable' to the @nrwl/workspace:library schema.

NX Report

>  NX  Report complete - copy this into the issue template

  @nrwl/angular : 9.0.4
  @nrwl/cli : 9.0.4
  @nrwl/cypress : 9.0.4
  @nrwl/eslint-plugin-nx : 9.0.4
  @nrwl/express : Not Found
  @nrwl/jest : 9.0.4
  @nrwl/linter : Not Found
  @nrwl/nest : Not Found
  @nrwl/next : Not Found
  @nrwl/node : Not Found
  @nrwl/react : Not Found
  @nrwl/schematics : Not Found
  @nrwl/tao : 9.0.4
  @nrwl/web : Not Found
  @nrwl/workspace : 9.0.4
  typescript : 3.7.5
node question / discussion

Most helpful comment

Yeah what @vsavkin said 馃憣. I guess good solution would be to have lib schematic for web and thus make it publishable.

there already is a web builder https://github.com/nrwl/nx/blob/master/packages/web/builders.json#L9-L13

There might be some issues as creating bundles for web-components is not trivial task... but as I said there is already builder for that 馃

All 7 comments

you can do that with @nrwl/node:lib (but yeah, it should be available in the core schematic -> which is workspace)

Ah thanks for the tip. I can look at what @nrwl/node:lib generates and copy the relevant parts

When building with @nrwl/node:package I've noticed that I don't get these dist folders

image

Is that intentional?

We cannot really make @nrwl/workpace:lib publishable because we need to know how to build it. That's why it has to be node, or react, or angular.

@snebjorn we don't bundle node libs. Any particular reason you want it to be bundled?

We cannot really make @nrwl/workpace:lib publishable because we need to know how to build it. That's why it has to be node, or react, or angular.

I see. I just figured a @nrwl/workpace:lib would always be published as an NPM package. And had assumed that a @nrwl/node:lib was a lib meant to be run on node like express

@snebjorn we don't bundle node libs. Any particular reason you want it to be bundled?

No particular reason. I just thought it would be good form to publish JS in a standardized module format. The tree-shakeability of ESM seems like a good ability to have.

Yeah what @vsavkin said 馃憣. I guess good solution would be to have lib schematic for web and thus make it publishable.

there already is a web builder https://github.com/nrwl/nx/blob/master/packages/web/builders.json#L9-L13

There might be some issues as creating bundles for web-components is not trivial task... but as I said there is already builder for that 馃

can this be closed @snebjorn ? thanks

Was this page helpful?
0 / 5 - 0 ratings