Maintainers who ship Node libraries: you find out too late that npm pack omitted dist/, or that exports points at files that are not in the tarball — consumers install a broken package. packed-exports-smoke packs the package, installs the .tgz into a temp directory, and smoke-imports main / exports (exit 1 on failure). Unlike publint (static lint of package.json) or npm pack --dry-run (file list only), this runs a real install + resolve + import against the packed artifact.
# from the repository root
npm install
npm test
npx packed-exports-smoke --help
npx packed-exports-smoke ./fixtures/good-pkg# from the repository root
npm install
npm test
npx packed-exports-smoke --help
npx packed-exports-smoke .\fixtures\good-pkgExpect Smoke passed for fixtures/good-pkg. For a failing case:
npx packed-exports-smoke ./fixtures/bad-exports
# exit code 1 — ./missing cannot be resolved from the packed tarballnpm packthe target package directorynpm installthe produced.tgzinto a fresh temp directory- Resolve + import the root entry and every
exportssubpath - Exit 1 if pack, install, resolve, or import fails
packed-exports-smoke [packageDir] [options]
packageDir Package to pack (default: cwd)
-h, --help Show help
--keep-temp Keep temp install dir (path printed)
--entry <path> Extra subpath to smoke (repeatable)
import { runSmoke, packTarget } from "packed-exports-smoke";
const result = await runSmoke({ packageDir: "./packages/my-lib" });
if (!result.ok) {
for (const e of result.entries.filter((x) => !x.ok)) {
console.error(e.entry, e.error);
}
process.exit(1);
}| Fixture | Expected |
|---|---|
fixtures/good-pkg |
PASS — root + ./util import |
fixtures/bad-exports |
FAIL — ./missing points at a file not in the tarball |
- Node.js 20+
npmonPATH(used for pack + install)
- Does not validate TypeScript
.d.tsresolution ortypes/typesVersionsconditions - Does not exercise conditional exports matrices (browser vs node, development vs production) beyond what the current Node process resolves
- Does not replace registry publish or OIDC trusted-publishing checks
- Scoped multi-package monorepos: point
packageDirat one package at a time - Does not run package
postinstallscripts in the temp install (--ignore-scripts) by design
MIT