xplat icon indicating copy to clipboard operation
xplat copied to clipboard

Publishable Feature/Library

Open pavelekNET opened this issue 5 years ago • 3 comments

In Nx there is option to generate Library as npm package including schemantics for build,link,test

nx g library mypackagelibrary --publishable

After installing xplat the option is not possible to use anymore with getting error: Could not match option 'publishable' to the @nstudio/xplat:library schema.

Is there any way how to make it work again (for Library/Feature).

Many thanks!

pavelekNET avatar Jan 20 '20 19:01 pavelekNET

@pavelekNET this is likely due to your default schematic setting. xplat sets @nstudio/xplat as defaultCollection inside the cli section of workspace.json. You can set this to any schematics you have installed in your workspace; whichever you invoke/use the most.

Try this:

nx g @nrwl/angular:library mypackagelibrary --publishable --dry-run

Assuming you may be wanting to generate an angular based libary. If not you can prefix the library generator command with any of @nrwl's packages that support library.

I'd also recommend installing Angular Console plugin if you use VS Code - really helps navigating and working with all sorts of schematics in your workspace.

NathanWalker avatar Jan 23 '20 07:01 NathanWalker

@mbaljeetsingh this command works great, command nx build mypackagelibrary builds the package. But there is a problem when I reference some module that is included in "paths" of tsconfig.json.

For example if exists in root tsconfig.json: "paths": { "@myworkspace/*": ["libs/features/*"], "@myworkspace/shared": ["libs/shared/index.ts"] }

i get many errors with: ..... is not under 'rootDir' 'mypackagelibrary\src'. 'rootDir' is expected to contain all source files.

pavelekNET avatar Jan 26 '20 23:01 pavelekNET

ok i find out that this is problem of NX architecture with publishable libraries and will be reworked in 8.12 version --> https://github.com/nrwl/nx/issues/602

pavelekNET avatar Jan 28 '20 15:01 pavelekNET