From 4dc1786f968dc64348fbea3d64068ae4abd9f30d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=98=D0=BB=D1=8C=D1=8F=20=D0=92=D0=BB=D0=B0=D0=B4=D0=B8?= =?UTF-8?q?=D0=BC=D0=B8=D1=80=D0=BE=D0=B2=D0=B8=D1=87=20=D0=9E=D0=BB=D0=BE?= =?UTF-8?q?=D0=B2=D1=8F=D0=BD=D0=BD=D0=B8=D0=BA=D0=BE=D0=B2?= Date: Mon, 20 Jul 2026 14:25:52 +0500 Subject: [PATCH] fix(build): restore exports field in dist/package.json 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 #104 --- build.mjs | 2 +- validate_dist.mjs | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/build.mjs b/build.mjs index 7fbd85e..348c1fe 100644 --- a/build.mjs +++ b/build.mjs @@ -37,7 +37,7 @@ await measure(`package.json → ./dist/package.json`, `created in`, async () => maintainers: Existing.maintainers, license: Existing.license, publishConfig: Existing.publishConfig, - export: Existing.export, + exports: Existing.exports, main: Existing.main, module: Existing.module, typings: Existing.typings, diff --git a/validate_dist.mjs b/validate_dist.mjs index f7d3144..bcbf56c 100644 --- a/validate_dist.mjs +++ b/validate_dist.mjs @@ -14,3 +14,25 @@ console.log(); try { const publintResult = await $`pnpm publint ${pkgDir}`; } catch (error) {} + +// Guard against regressions in dist/package.json generation (see build.mjs): +// a missing `exports` field makes bundlers resolve the CJS build, which breaks +// the `@effector/reflect/scope` subpath and causes a dual-package hazard with +// effector-react (scope is lost inside `variant`/`reflect`). +{ + const distPkg = JSON.parse( + await fs.readFile(resolve(pkgDir, 'package.json'), { encoding: 'utf-8' }), + ); + const missing = []; + if (!distPkg.exports) missing.push('exports'); + else { + if (!distPkg.exports['.']) missing.push("exports['.']"); + if (!distPkg.exports['./scope']) missing.push("exports['./scope']"); + } + if (missing.length > 0) { + throw new Error( + `dist/package.json is missing required field(s): ${missing.join(', ')}`, + ); + } + console.log('✓ dist/package.json has valid "exports"'); +}