Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

packed-exports-smoke

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.

60-second quickstart

bash

# from the repository root
npm install
npm test
npx packed-exports-smoke --help
npx packed-exports-smoke ./fixtures/good-pkg

PowerShell

# from the repository root
npm install
npm test
npx packed-exports-smoke --help
npx packed-exports-smoke .\fixtures\good-pkg

Expect 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 tarball

What it does

  1. npm pack the target package directory
  2. npm install the produced .tgz into a fresh temp directory
  3. Resolve + import the root entry and every exports subpath
  4. Exit 1 if pack, install, resolve, or import fails

CLI

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)

Library API

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);
}

Fixtures

Fixture Expected
fixtures/good-pkg PASS — root + ./util import
fixtures/bad-exports FAIL — ./missing points at a file not in the tarball

Requirements

  • Node.js 20+
  • npm on PATH (used for pack + install)

v0.2 limitations (honest)

  • Does not validate TypeScript .d.ts resolution or types / typesVersions conditions
  • 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 packageDir at one package at a time
  • Does not run package postinstall scripts in the temp install (--ignore-scripts) by design

License

MIT

About

Maintainers who ship Node libraries: you find out too late that `npm pack` omitted `dist/`, or that `exports` points ...

Topics

Resources

Stars

10 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages