NPM package with shared functionalities across Panther projects (FE and BE).
The NPM contains two standalone builds made from Typescript by Rollup.
-
Globals NPM (FE + BE):
- From
index.browser.tscontaining exports fromsrc/globals/**/*. - This is shared functionality between FE and BE services like models, code helpers etc..
- From
-
Node NPM:
- Containes all from globals
- By
index.node.tscontaining exports fromsrc/node/**/*. This is Node JS only funtionality. Everything with peer dependency to Node.js packages should be here.
Production build and publishing is realised by Github Workflow.
As mentioned, Rollup set up in rollup.config.js make two standalone builds named by purpose.
Important is setup in package.json
typewith valuemoduleexports, each for one NPM target- Empty
dependencies. - All required dependencies defined in
peerDependenciesfield.
Each build platform has defined standalone tsconfig in the repository root. Final tsconfig.json is merged together by platform or purpose.
- Install Node and NPM
- Install YALC by
npm install -g yalc - Clone the package repository.
- Open terminal in package root.
- Run
npm iandnpm run buildto install dependencies and make a build of the NPM package. - Run
npm run yalc:publishfor local publishing the package into yalc repository. - Now you can add this package for local development by opening the target application repository and run
yalc add @gisatcz/ptr-be-core - Run
npm run devfor development mode with Rollup build watcher and auto yalc publishing.
- FE apps (in browser) should use imports from
@gisatcz/ptr-be-core/browser - Node.js apps and NextJS backend routes should use imports from
@gisatcz/ptr-be-core/node
- YALC (local NPM): https://github.com/wclr/yalc
- Vitest (testing): https://vitest.dev
- Barrelsby (TS Imports into one
index.ts): https://github.com/bencoveney/barrelsby - Rollup (NPM package build): https://rollupjs.org
Please folow instructions in .github/ for better code results.