Entrysmith is a CLI tool for keeping package entrypoints in sync across a TypeScript workspace.
It lets a package expose imports such as @scope/package/model or @scope/package/test/another from files under src, then updates the package metadata and TypeScript project references needed for other workspace packages to consume those entrypoints.
Running entrysmith fix in a configured package:
- ensures the configured build output directory is listed in
package.jsonfiles - rewrites
package.jsonexportsfor every configured entrypoint - keeps
./package.jsonexported - adds TypeScript project references for workspace dependencies
- adds
compilerOptions.pathsmappings for entrypoints exposed by workspace dependencies
Running entrysmith without arguments runs entrysmith fix.
Entrypoints are files in the package src directory. Each entrypoint becomes an importable package subpath.
{
"entrysmith": {
"entrypoints": [
"model/index.ts",
"test/index.ts",
"test/another.ts"
],
"exportConditions": ["types", "import"]
}
}These entrypoints expose imports like:
import { Model } from "@scope/package/model";
import { testHelper } from "@scope/package/test";
import { anotherHelper } from "@scope/package/test/another";index.ts maps to its containing directory. Other file names map to their full path without extension.
Entrysmith loads configuration from one of:
package.jsonunder theentrysmithkeyentrysmith.config.jsentrysmith.config.tsentrysmith.config.json
Configuration fields:
entrypoints: list of entrypoint files undersrcexportConditions: package export conditions. Use"types","import","require", or"default". When entrypoints exist, provide a non-empty list with at least one runtime condition ("import","require", or"default").packageOutputDirectory: build output directory used in package exports, defaults to"dist"barrelFileExtensions: file extensions exported from each configuredindex.tsentrypoint, defaults to["ts", "js"]. Use[]to disable barrel generation.extraExports: additionalpackage.jsonexport entries copied without modification. Keys must be"."or start with"./". They cannot conflict with generated entrypoints or"./package.json".typescript.tsConfigReferenceTargetPath: target path used when other workspace packages reference this package, defaults to the package roottypescript.referenceTsConfigPaths: tsconfig files that receive references and path mappings, defaults to["tsconfig.json"]
Example:
{
"entrysmith": {
"entrypoints": [
"model/index.ts",
"test/another.ts"
],
"exportConditions": ["types", "import"],
"packageOutputDirectory": "dist",
"barrelFileExtensions": ["ts", "js"],
"typescript": {
"tsConfigReferenceTargetPath": "tsconfig.json",
"referenceTsConfigPaths": ["tsconfig.json"]
}
}
}Entrysmith overwrites each configured index.ts entrypoint with exports for matching files in its immediate directory. It does not scan nested directories. It excludes index.* files to prevent self-exports. It omits file extensions from export specifiers.
For example, with entrypoints: ["model/index.ts"] and src/model/example.ts:
// generated by entrysmith - don't change
export * from './example';Version 0.4 removes entrypointOutputMode. Replace it with explicit exportConditions:
{
"entrysmith": {
"entrypoints": ["index.ts"],
"exportConditions": ["default"]
}
}Configure Entrysmith workspaces at the workspace root:
{
"entrysmith": {
"workspaces": ["packages/*", "tools/*"]
}
}workspaces must be a non-empty list of glob patterns. Entrysmith resolves patterns from the workspace root. It deduplicates overlapping matches. It skips matched directories without Entrysmith package configuration.
Run entrysmith fix at this root to update every configured package. Entrysmith loads and validates every configured package before it writes files. It applies packages in dependency-first order. Dependencies in dependencies, devDependencies, peerDependencies, and optionalDependencies set this order. Dependency cycles and duplicate package names fail the command.
When root Entrysmith workspace configuration is absent, Entrysmith uses package-manager workspaces. Set entrysmith.workspaces to apply a narrower package set. Entrysmith does not run package scripts or compile TypeScript.
For exportConditions: ["types", "import"], Entrysmith writes exports like:
{
"exports": {
"./model": {
"types": "./dist/model/index.d.ts",
"import": "./dist/model/index.js"
},
"./test/another": {
"types": "./dist/test/another.d.ts",
"import": "./dist/test/another.js"
},
"./package.json": "./package.json"
}
}Entrysmith emits only configured conditions. It emits types first and default last. Use exportConditions: ["default"] for a legacy default export without an explicit types condition.
Use extraExports for non-TypeScript assets or export shapes that Entrysmith does not generate. Entrysmith copies each value without changing paths or export conditions:
{
"entrysmith": {
"extraExports": {
"./styles.css": "./dist/styles.css",
"./schema.json": {
"default": "./dist/schema.json"
}
}
}
}When invoked inside one configured package, Entrysmith discovers packages in the current package-manager workspace.
When the current package depends on another workspace package that has Entrysmith configuration, entrysmith fix updates the configured tsconfig files with:
referencespointing to the dependency package or its configuredtsConfigReferenceTargetPathcompilerOptions.pathsentries such as@scope/dependency/modelpointing at the dependency source entrypoint
If multiple configured tsconfig files extend a common parent that is also configured, Entrysmith stores path mappings in the common parent.
Run from a configured package directory:
entrysmith fixRun from a package-manager workspace root to update each configured package. Add entrysmith.workspaces only when you need a narrower package set:
entrysmith fixTo keep entrypoints synchronized automatically, add entrysmith fix to the package prepare script:
{
"scripts": {
"prepare": "entrysmith fix"
}
}