Skip to content

fix(build): restore exports field in dist/package.json - #105

Open
Olovyannikov wants to merge 1 commit into
effector:masterfrom
Olovyannikov:fix/dist-package-json-exports
Open

fix(build): restore exports field in dist/package.json#105
Olovyannikov wants to merge 1 commit into
effector:masterfrom
Olovyannikov:fix/dist-package-json-exports

Conversation

@Olovyannikov

Copy link
Copy Markdown
Contributor

Problem

build.mjs generates dist/package.json from a whitelist of fields, but uses a typo export: Existing.export (singular, non-existent) instead of exports: Existing.exports (introduced in cef40e6). As a result the published 10.1.0 package has no exports field.

Impact

  • The @effector/reflect/scope subpath no longer resolves.
  • Bundlers fall back to main (CJS). The CJS entry requires its own copy of effector-react, causing a dual-package hazard: <Provider> (ESM) and useUnit inside variant/reflect (CJS) reference different effector-react instances, so the forked scope is lost — variant reads the store default instead of the scoped value.

Reproduced in a React 19 app: variant({ if: $store, then, else }) under <Provider value={fork(...)}> rendered the then branch even though the scoped value was false. Pinning back to 10.0.2 (which still shipped exports) fixed it.

Fix

  • build.mjs: exportexports.
  • validate_dist.mjs: fail when the generated dist/package.json is missing the exports field (. / ./scope). The existing attw/publint calls swallow their errors, so the regression went unnoticed.

Verify

pnpm build now emits dist/package.json with the full exports map (both . and ./scope conditions).

Closes #104

The dist package.json generator used a typo `export` instead of `exports`
(reading the non-existent `Existing.export`), so the published package lost its
`exports` map. Without it, bundlers resolve the CJS build and the
`@effector/reflect/scope` subpath breaks; the CJS entry also triggers a
dual-package hazard with effector-react, losing the Provider scope inside
`variant`/`reflect`.

Also add a guard in validate_dist.mjs so a missing exports field fails the
dist validation instead of being silently ignored.

Closes effector#104
@bolt-new-by-stackblitz

Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

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.

10.1.0: dist/package.json is missing the exports field (breaks /scope subpath and scope in bundlers)

1 participant