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"

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you very much, that is exactly want i wanted to do.
I want a pure typescript library, not something that depends on a nodejs runtime.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.