Skip to content

feat: publish dist only, and make esbuild and tsx optional peers, for a smaller install of @intentius/chant - #5130

Merged
lex00 merged 2 commits into
mainfrom
estate/chant-slim-install
Nov 16, 2026
Merged

lex00 merged 2 commits into
mainfrom
estate/chant-slim-install

Conversation

@lex00

@lex00 lex00 commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

What changes

A plain npm install of @intentius/chant unpacks 60 MB for the package itself and then pulls typescript, esbuild with its platform binary, and tsx. This change cuts the package to 25 MB and stops installing esbuild and tsx unless a project asks for them.

The package published src/ beside dist/, and 25 of its 26 exports named src/*.ts as default. Now default names the compiled dist/*.js, as import already did. files lists dist/ and bin/. The JSON schemas and .astro components that compiled modules read are copied into dist/ by the package's build. The sandbox drivers import chant's own modules from dist/ when the package has no src/. The command chant update copies declaration files from dist/ when a package has no src/.

The 22 lexicon packages get the same treatment. Each lexicon's build copies the JSON its compiled modules read from src/ to dist/. The generated lexicon-<name>.json is one of those files. The function moduleSourceDir falls back to the compiled directory when src/ is not there. The option declarationMap is off in the build configs, since the maps pointed at a src/ that is no longer published. The package @intentius/chant-k8s-client stays as it is, because it ships TypeScript source on purpose.

The packages esbuild and tsx move from dependencies to optional peer dependencies (peerDependenciesMeta with optional: true) and stay in devDependencies. chant loads them only where it runs a project's TypeScript or bundles a sandbox. A missing one stops the command with chant needs tsx to run TypeScript; install it with: npm i -D tsx. The package typescript stays a dependency. The commands chant init and chant carve add tsx to the project they write. The installation and quick-start pages and the command pages say which commands need it.

The development condition

Kept, and still pointing at src/*.ts. Inside this repository the workspaces resolve the local package, which has src/. Vitest and bin/chant from source keep resolving it, and so do the tsx runs. The compiler reads it through customConditions. A published consumer that set development would find a path with no file behind it. I looked at terragucci and behold, and neither sets the condition: terragucci's bundler passes ["import", "default"], and behold sets no conditions. The types condition still names dist/*.d.ts.

Sizes

npm pack of packages/core, then a plain install of the tarball in an empty directory:

before after
tarball 14.6 MB 7.0 MB
unpacked 60.1 MB 25.2 MB
node_modules after the install 121 MB 68 MB

@intentius/behold@0.32.0 with this chant as an override in overrides: 240 MB before, 188 MB after. Behold's own tree also holds @kubernetes/client-node at 63 MB, typescript at 23 MB and the published chant-lexicon-terraform at 12 MB, which still carries its src/.

Lexicon packages, unpacked and as tarballs, from the same npm pack:

package unpacked before after tarball before after
aws 38.1 MB 22.8 MB 5.90 MB 3.47 MB
azure 43.0 MB 25.7 MB 3.30 MB 1.92 MB
k8s 14.7 MB 8.5 MB 2.08 MB 1.21 MB
sql 16.2 MB 7.7 MB 3.17 MB 1.57 MB
gcp 7.7 MB 4.4 MB 1.04 MB 0.58 MB
terraform 7.8 MB 3.1 MB 1.85 MB 0.88 MB
grafana 5.0 MB 2.4 MB 0.97 MB 0.52 MB
github 4.6 MB 1.1 MB 0.61 MB 0.26 MB
gitlab 4.4 MB 1.0 MB 0.55 MB 0.24 MB
otel 4.3 MB 2.0 MB 0.76 MB 0.38 MB
pulumi 3.2 MB 0.7 MB 0.52 MB 0.20 MB
forgejo 2.9 MB 0.1 MB 0.26 MB 0.05 MB

The other ten lexicons are each under 2.2 MB before and shrink by about half.

What I checked

I installed the packed core and the packed gcp, k8s and aws lexicons into empty projects. I did the same with tarballs that still had src/, for comparison. chant build of the k8s-gke-microservice and fargate-alb examples writes byte-identical output, and so does --sandbox --no-fold. chant lint output is the same apart from the project path. Without tsx the commands chant build, lint, list and update print the one-line error. The commands chant import and chant --version still run.

For the other repositories

  • terragucci reads node_modules/@intentius/chant/src/notify.schema.json in scripts/build-cli.mjs, and src/components/component.schema.json and src/workspace/point-answer.schema.json in two tests. These move to dist/.
  • behold has esbuild and tsx in devDependencies only, and runs bin/chant on users' projects, so it needs both in dependencies. Three e2e scripts probe node_modules/@intentius/chant/src/... and chant-lexicon-terraform/src/... to decide whether chant is new enough, and those probes need a dist/ path.

Level-0 record

This is a level-0 change without a warning release. The row is in the level-0 exceptions page and in the CHANGELOG. No level-0 golden moves.

… a smaller install of @intentius/chant

@intentius/chant and the lexicon packages stop publishing src/. The default
export conditions of @intentius/chant name dist/*.js, the schemas and .astro
components compiled modules read are copied into dist/, and each lexicon's
build copies the JSON its compiled modules read. moduleSourceDir and the
sandbox drivers fall back to the compiled directory when there is no src/,
and chant update reads declarations from dist/. The development condition
still names src/*.ts for the repository's own tools.

esbuild and tsx move from dependencies to optional peer dependencies. chant
loads them only where it runs a project's TypeScript or bundles a sandbox, and
a missing one stops the command with a one-line error that names the install.
chant init and chant carve add tsx to the project they write.

A plain install of the packed core goes from 121 MB to 68 MB on disk. This is a
level-0 change recorded on the exceptions page and in the CHANGELOG.
@lex00
lex00 merged commit 5540162 into main Nov 16, 2026
9 checks passed
@lex00
lex00 deleted the estate/chant-slim-install branch November 16, 2026 00:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant