Skip to content

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

Description

@Olovyannikov

Summary

@effector/reflect@10.1.0 is published without the exports field in its package.json. Version 10.0.2 had it.

// 10.0.2 package.json
"exports": {
  ".":       { "types": "./index.d.ts", "import": "./index.mjs", "require": "./index.cjs", "default": "./index.mjs" },
  "./scope": { "types": "./scope.d.ts", "import": "./scope.mjs", "require": "./scope.js",  "default": "./scope.mjs" }
}
// 10.1.0 package.json — no `exports` at all

Root cause

build.mjs, which generates dist/package.json, uses a typo — export: Existing.export (singular, non-existent) instead of exports: Existing.exports:

const Dist = {
  ...
  export: Existing.export, // ← typo; Existing.export is undefined
  ...
};

Introduced in commit cef40e6 ("ci: include over exclude fields for dist/package.json"). The source package.json still has a correct exports, but it never reaches the built artifact.

Impact

  • The @effector/reflect/scope subpath no longer resolves via exports.
  • Bundlers fall back to main (CJS). The CJS entry requires its own copy of effector-react, producing a dual-package hazard: <Provider> (ESM) and the useUnit used inside variant/reflect (CJS) end up referencing different effector-react instances. The forked scope is then lost — variant/reflect read the store's default value instead of the scoped one.

Reproduction

React 19 app, bundler resolving the package entry (Vite/Vitest):

const Cmp = variant({ if: $flag, then: Then, else: Else });
render(
  <Provider value={fork({ values: [[$flag, false]] })}>
    <Cmp />
  </Provider>,
);
// expected: <Else/>; actual on 10.1.0: <Then/> (reads default `true`, not scoped `false`)

Pinning back to 10.0.2 (which still ships exports) fixes it.

Fix

build.mjs: exportexports. PR incoming. Also adding a guard in validate_dist.mjs so a missing exports fails dist validation (the current attw/publint calls swallow their errors).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions