This repository uses npm Workspaces to manage the library package (mummet-core) and a side‑by‑side test application (test-app). The workspace makes it easy to build, test, and verify the package locally, and then publish it to npm.
mummet-core: the published TypeScript librarytest-app: a small TS app used to validate the library (both the released and local builds)
- Node.js 18+ (Node 20+ recommended)
- npm 9+
- Logged in to npm (
npm login) for publish steps
From the repository root:
- Install all workspace deps:
npm install
This installs dependencies for both mummet-core and test-app.
- Build the library:
npm -w mummet-core run build - Build the test app:
npm -w test-app run build
Notes:
mummet-corehas apreparescript that builds automatically on local install and on publish.- tsup emits CommonJS (
dist/index.js) and ES Module (dist/index.mjs) outputs plus.d.tstypes.
- Run unit tests:
npm -w mummet-core test - Watch mode:
npm -w mummet-core run test:watch - Coverage:
npm -w mummet-core run test:cov - Typecheck only:
npm -w mummet-core run typecheck - Lint code:
npm -w mummet-core run lint
The test app can depend on either the released version from npm or the local workspace build.
-
Use the published release ([email protected]):
npm -w test-app run use:releasenpm -w test-app run buildnode test-app/dist/index.js
-
Switch back to the local workspace build:
npm -w test-app run use:localnpm -w test-app run buildnode test-app/dist/index.js
Import the public API directly from mummet-core. Internal folders like by-item are not exposed as subpath imports.
Example:
import { track, addOrUpdate, commit, findModified } from 'mummet-core';
type Entity = { id: number; value: string };
const state0 = { 1: track<Entity>({ id: 1, value: 'a' }) };
const s1 = addOrUpdate({ ...state0 }, { id: 2, value: 'b' }, 'id');
const s2 = commit({ ...s1 }, [1, 2]);
const modified = findModified(s2 as any);Publishing is done from the library workspace. The prepare script ensures dist/ is built during publish.
- Ensure everything is clean and green
npm installnpm -w mummet-core run lintnpm -w mummet-core testnpm -w mummet-core run build
- Bump the version in
mummet-core/package.json
- Choose semver appropriately (patch/minor/major)
- Example:
npm --workspace mummet-core version patch(this updates the version and creates a git tag if git is configured)
- Optional: Pack locally to verify published contents
npm -w mummet-core pack- Inspect the generated tarball to confirm
dist/and type declarations are included
- Login (once per environment)
npm login- If your account has 2FA, be ready to enter the OTP
- Publish
- From repo root, publish the workspace package:
npm -w mummet-core publish --access public
- Alternatively,
cd mummet-core && npm publish --access public
- Verify publication
- In
test-app:npm -w test-app run use:release(updates dependency to the new version) - Build and run:
npm -w test-app run buildnode test-app/dist/index.js
- Out‑of‑date installs or conflicts:
rm -rf node_modules package-lock.json && npm install
- TypeScript cannot find declarations for
mummet-core:- Ensure
mummet-core/dist/*.d.tsare present (they’re generated on build) mummet-core/package.jsonhas"types"and"exports"entries that expose types
- Ensure
- The library exposes dual ESM/CJS builds via
exports(root only):"."maps todist/index.mjs(import),dist/index.js(require), anddist/index.d.ts
- The
by-itemfolder is internal and not exposed as a subpath export; import only frommummet-core. - The test app uses
"module": "NodeNext"and"moduleResolution": "NodeNext"intsconfig.jsonto align with modern Node +exports.
Happy hacking!