Skip to content

Fix CommonJS package entrypoint#1

Open
alejandrorivas-pixel wants to merge 1 commit into
svar-widgets:mainfrom
alejandrorivas-pixel:fix-cjs-entrypoint
Open

Fix CommonJS package entrypoint#1
alejandrorivas-pixel wants to merge 1 commit into
svar-widgets:mainfrom
alejandrorivas-pixel:fix-cjs-entrypoint

Conversation

@alejandrorivas-pixel

Copy link
Copy Markdown

Summary

  • update the CommonJS package entrypoint from ./dist/index.cjs.js to ./dist/index.cjs
  • keep the existing ESM and types entries unchanged

Why

The build already emits dist/index.cjs, but the published package metadata points CommonJS consumers at dist/index.cjs.js. As a result, require('@svar-ui/react-core') fails with MODULE_NOT_FOUND in a clean install.

Validation

Reproduced against the published package:

npm install @svar-ui/react-core@2.6.0 --ignore-scripts --no-audit --no-fund
node -e "require('@svar-ui/react-core')"
# MODULE_NOT_FOUND ... dist/index.cjs.js

Validated this patch:

npm ci --ignore-scripts
npm run build
npm pack --silent

tmp="$(mktemp -d)"
cd "$tmp"
npm init -y >/dev/null
npm install /path/to/svar-ui-react-core-2.6.0.tgz react@18 react-dom@18 --ignore-scripts --no-audit --no-fund >/dev/null
node -e "const mod = require('@svar-ui/react-core'); console.log(typeof mod)"
node --input-type=module -e "const mod = await import('@svar-ui/react-core'); console.log(typeof mod)"

Both CommonJS require() and ESM import() pass with the packed tarball.

Also ran:

git diff --check

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.

2 participants