- Start by creating a new workspace. We can use the following command that will help us set it up.
npx create-nx-workspace@latest myorg --preset=ts
- myorg is name of workspace (can you rename for you application)
npx nx generate @nrwl/js:library is-even --publishable --importPath @myorg/is-even
- Uses the @nrwl/js plugin's library generator to scaffold a new library named is-even.
- The --publishable flag makes sure we also get a package.json generated and a publish target we can invoke to publish to NPM.
- The --importPath allows us to define the name of the NPM package.
├── dist
├── packages/
├── tools/
├── nx.json
├── package.json
├── README.md
└── tsconfig.base.json
export function isEven(x: number): boolean {
return x % 2 === 0;
}
-
npm run build is-even
-
cd /Users/phutran/Documents/package/myorg/dist/packages/is-even
-
update version package => "version": "0.0.3",
-
npm publish
-
npm publish dist/packages/is-odd
-
npm publish dist/packages/is-check-size
- npx nx test [is-even] runs the pre-configured Jest tests for the package
- npx nx test open-ai-helpers
- npx nx build open-ai-helpers
- npx nx build [is-odd]
- npx nx run-many --target=build
- npx nx affected --target=build RUN NO CACHE
- nx run [is-even]:lint
- [DOC README] (https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#quoting-text) - Learn about README SYSTAX
- [DOC NX] (https://nx.dev/) - Learn about nx tool
- [DOC NPM] (https://docs.npmjs.com/) - Learn about npm