Eternaltwin

Home | Tools

package.json

Reference

Every Node.js package (the root of the repository, each package under packages/*, and each SDK under sdk/node/*) is described by a package.json manifest. This page documents the conventions Eternaltwin follows, on top of the standard fields described in the reference above.

Common fields

  • name: scoped as @eternaltwin/<name> (e.g. @eternaltwin/core, @eternaltwin/client-node).
  • version: kept in sync across the whole workspace (Rust crates included) and bumped in one step by cargo xtask release <version>. Do not bump it by hand in a single package.
  • type: "module". All packages are ESM-only: sources are .mts files, compiled to .mjs.
  • licenses: an array of { "type": "AGPL-3.0-or-later", "url": "..." } (this predates the standard SPDX license string field, but is what the workspace consistently uses — keep the existing style when adding a package rather than switching to license).
  • publishConfig: { "access": "public", "registry": "https://registry.npmjs.org/" } on every published package.
  • engines.node: declares the minimum supported Node.js version for that package. The root manifest currently requires >=20.11.0; some older packages under packages/* and sdk/node/* still declare lower floors (>=14.13.1 or >=18.13.0) inherited from when they were last touched — when editing a package, prefer aligning it with the root requirement.
  • exports: maps the package's public entry points to compiled output, e.g. { ".": "./lib/index.mjs", "./*": "./lib/*.mjs" } for a library, or { ".": "./bin/etwin.mjs" } for a CLI package.
  • files: whitelists what gets published, typically the compiled output (./lib/**/*.(mjs|map|mts)) and sometimes the sources needed to rebuild type declarations (./src/lib/).

Standard scripts

Most packages implement the same task names, so they can be run uniformly with yarn run <task> from any workspace, or yarn workspaces foreach from the root:

  • build: compile the package, usually tsc --build src/lib/tsconfig.json.
  • lint: eslint "./src/**/*.mts".
  • format: eslint --fix "./src/**/*.mts".
  • test:build + test:run (aggregated as test): compile then run tests with node --test.
  • prepack: runs before publishing (usually yarn run build), so the published tarball always contains fresh compiled output.

The root package.json additionally exposes workspace-wide tasks such as lint, format, start, clean, test, db:check, db:reset, db:sync, start:dev:back, and start:dev:front — see the root README.md for the full list.