Repository navigation
feat: publish dist only, and make esbuild and tsx optional peers, for a smaller install of @intentius/chant - #5130
Merged
Merged
Conversation
… 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes
A plain
npm installof@intentius/chantunpacks 60 MB for the package itself and then pullstypescript,esbuildwith its platform binary, andtsx. This change cuts the package to 25 MB and stops installingesbuildandtsxunless a project asks for them.The package published
src/besidedist/, and 25 of its 26exportsnamedsrc/*.tsasdefault. Nowdefaultnames the compileddist/*.js, asimportalready did.fileslistsdist/andbin/. The JSON schemas and.astrocomponents that compiled modules read are copied intodist/by the package's build. The sandbox drivers import chant's own modules fromdist/when the package has nosrc/. The commandchant updatecopies declaration files fromdist/when a package has nosrc/.The 22 lexicon packages get the same treatment. Each lexicon's
buildcopies the JSON its compiled modules read fromsrc/todist/. The generatedlexicon-<name>.jsonis one of those files. The functionmoduleSourceDirfalls back to the compiled directory whensrc/is not there. The optiondeclarationMapis off in the build configs, since the maps pointed at asrc/that is no longer published. The package@intentius/chant-k8s-clientstays as it is, because it ships TypeScript source on purpose.The packages
esbuildandtsxmove fromdependenciesto optional peer dependencies (peerDependenciesMetawithoptional: true) and stay indevDependencies. chant loads them only where it runs a project's TypeScript or bundles a sandbox. A missing one stops the command withchant needs tsx to run TypeScript; install it with: npm i -D tsx. The packagetypescriptstays a dependency. The commandschant initandchant carveaddtsxto the project they write. The installation and quick-start pages and the command pages say which commands need it.The
developmentconditionKept, and still pointing at
src/*.ts. Inside this repository the workspaces resolve the local package, which hassrc/. Vitest andbin/chantfrom source keep resolving it, and so do the tsx runs. The compiler reads it throughcustomConditions. A published consumer that setdevelopmentwould 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. Thetypescondition still namesdist/*.d.ts.Sizes
npm packofpackages/core, then a plain install of the tarball in an empty directory:node_modulesafter the install@intentius/behold@0.32.0with this chant as an override inoverrides: 240 MB before, 188 MB after. Behold's own tree also holds@kubernetes/client-nodeat 63 MB,typescriptat 23 MB and the publishedchant-lexicon-terraformat 12 MB, which still carries itssrc/.Lexicon packages, unpacked and as tarballs, from the same
npm pack: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,k8sandawslexicons into empty projects. I did the same with tarballs that still hadsrc/, for comparison.chant buildof thek8s-gke-microserviceandfargate-albexamples writes byte-identical output, and so does--sandbox --no-fold.chant lintoutput is the same apart from the project path. Withouttsxthe commandschant build,lint,listandupdateprint the one-line error. The commandschant importandchant --versionstill run.For the other repositories
node_modules/@intentius/chant/src/notify.schema.jsoninscripts/build-cli.mjs, andsrc/components/component.schema.jsonandsrc/workspace/point-answer.schema.jsonin two tests. These move todist/.esbuildandtsxindevDependenciesonly, and runsbin/chanton users' projects, so it needs both independencies. Three e2e scripts probenode_modules/@intentius/chant/src/...andchant-lexicon-terraform/src/...to decide whether chant is new enough, and those probes need adist/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.