Skip to content

Exclude compiled test files from the published npm package - #140

Merged
tbroadley merged 1 commit into
masterfrom
exclude-tests-from-package
Sep 6, 2026
Merged

tbroadley merged 1 commit into
masterfrom
exclude-tests-from-package

Conversation

@tbroadley

Copy link
Copy Markdown
Owner

Problem

tsconfig.json compiles index.ts, lib/ and test/ into build/, and package.json had "files": ["build", "dictionaries"]. That meant every published tarball contained build/test/*.js — the compiled mocha test suite, including the 56 kB cli-test.js — which consumers download but can never use.

Fix

Add a !build/test negation entry to the files array. Test code is still compiled into build/test locally, so yarn test (tsc && mocha build/test/**/*test.js) is unchanged.

Pack before/after

Verified with npm pack --dry-run:

Files Package size
Before 29 20.8 kB
After 22 14.6 kB

The 7 removed files are all build/test/... entries. build/index.js, all of build/lib/, dictionaries/, README.md, LICENSE and package.json are still included.

yarn ci (spellcheck + eslint + 101 mocha tests) passes.

🤖 Generated with Claude Code

`tsc` compiles `test/` into `build/test`, and the `files` field included
all of `build`, so compiled mocha tests shipped to consumers. Add a
`!build/test` negation entry so the tarball only contains the library and
CLI code.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@tbroadley
tbroadley force-pushed the exclude-tests-from-package branch from 7c591e7 to d9bb4df Compare September 6, 2026 20:54
@tbroadley
tbroadley merged commit 41d8959 into master Sep 6, 2026
6 checks passed
@tbroadley
tbroadley deleted the exclude-tests-from-package branch September 6, 2026 20:55
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