Nx workspace CLI does not allow to create pure typescript library since version 8
Asked Answered
K

1

5

Since updating our project to nx workspace 8 the generation of libraries "ng g lib mylib" does not allow to create a pure typescript library only.

Previously the question: "What framework should this library use?" allowed the selection of "TypeScript" to avoid creating UI specific configurations for the library.

Since in version 8 changed (https://nx.dev/guides/nx7-to-nx8) to the schematics have been made i an looking for the correct configuration of the workspace to avoid creating and maintaining a custom schematic.

Thanks in advance for recommendations.

Deleted respective entries in config files manually:

Delete node in tsconfiglib.json ->

  "angularCompilerOptions": {
    "annotateForClosureCompiler": true,
    "skipTemplateCodegen": true,
    "strictMetadataEmit": true,
    "fullTemplateTypeCheck": true,
    "strictInjectionParameters": true,
    "enableResourceInlining": true
  },

Delete node in jest.config.js ->

  snapshotSerializers: [
    'jest-preset-angular/AngularSnapshotSerializer.js',
    'jest-preset-angular/HTMLCommentSerializer.js'
  ]

Change "schematics" in angular.js from "@nrwl/angular:component" to "@nrwl/schematics:component"

Kleinstein answered 1/7, 2019 at 9:0 Comment(0)
T
14

You can add a TS library with command below:

ng g @nrwl/node:lib my-ts-lib

If the first time, you should install schematics before :

ng add @nrwl/node

Hope it will help.

Torpedo answered 1/7, 2019 at 9:40 Comment(2)
Thank you very much, that is exactly want i wanted to do.Kleinstein
I want a pure typescript library, not something that depends on a nodejs runtime.Heterodoxy

© 2022 - 2024 — McMap. All rights reserved.