Skip to content

fix: make built ESM entrypoint importable#2

Open
slegarraga wants to merge 1 commit into
voidrot:mainfrom
slegarraga:fix-node-esm-entrypoint
Open

fix: make built ESM entrypoint importable#2
slegarraga wants to merge 1 commit into
voidrot:mainfrom
slegarraga:fix-node-esm-entrypoint

Conversation

@slegarraga

Copy link
Copy Markdown

Summary

  • Add .js extensions to local relative source imports/exports so the built ESM files are directly importable by Node.
  • Add a CI smoke check that imports ./dist/index.js after npm run build.

Why

The package is published with "type": "module", but the current build emits extensionless relative imports such as ./provider in dist/index.js. Node's ESM loader does not resolve those specifiers, so importing the built package entrypoint fails with ERR_MODULE_NOT_FOUND after a clean build.

The new CI check catches that failure mode before publishing:

node --input-type=module -e "await import('./dist/index.js')"

Validation

npm test
npm run build
node --input-type=module -e "await import('./dist/index.js'); console.log('entrypoint import ok')"
npm pack --dry-run

Local results:

  • npm test: 3 files passed, 101 tests passed.
  • npm run build: completed successfully.
  • Entrypoint import: entrypoint import ok.
  • npm pack --dry-run: tarball includes dist/index.js.

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