From 00a039a7130a12d6fe3bdecab12fd781ca9fe277 Mon Sep 17 00:00:00 2001 From: Aria Minaei Date: Tue, 12 Jul 2022 16:28:52 +0200 Subject: [PATCH] Fix `exports` of `@theatre/r3f` so it is consistently interpreted across bundlers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before this commit, the exports field of `@theatre/r3f` was: ``` "exports": { ".": "./dist/index.js", "./extension": "./dist/extension/index.js" }, ``` So users could import the extension from '@theatre/r3f/extension' However, if the user’s bundler doesn’t support the exports field, they’d have to import from @theatre/r3f/dist/extension. There are 3 problems with this approach: 1. We have to ask users to try both paths and see which works for their bundler. 2. Users can’t copy code from each other if their bundler setups are different. 3. To make matters worse, if a user’s bundler supports exports, they can’t import from @theatre/r3f/dist/extension. This is all confusing, so we're fixing it by exposing @theatrer/3f/dist/extension and not @theatre/r3f/extension. Uglier, but more consistent, and avoids the above 3 problems. --- packages/r3f/package.json | 2 +- packages/r3f/src/index.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/r3f/package.json b/packages/r3f/package.json index 912bdb0..5549d24 100644 --- a/packages/r3f/package.json +++ b/packages/r3f/package.json @@ -27,7 +27,7 @@ ], "exports": { ".": "./dist/index.js", - "./extension": "./dist/extension/index.js" + "./dist/extension": "./dist/extension/index.js" }, "scripts": { "prepack": "yarn run build", diff --git a/packages/r3f/src/index.ts b/packages/r3f/src/index.ts index 5939ac6..f030548 100644 --- a/packages/r3f/src/index.ts +++ b/packages/r3f/src/index.ts @@ -1,7 +1,7 @@ export {default as editable} from './main/editable' export type {EditableState, BindFunction} from './main/store' /** - * This is a private API that's exported so that `@theatre/r3f/extension` + * This is a private API that's exported so that `@theatre/r3f/dist/extension` * and `@theatre/r3f` can talk to one another. This API _could_ change * between patch releases, so please don't build on it :) * @@ -12,7 +12,7 @@ export { allRegisteredObjects as __private_allRegisteredObjects, } from './main/store' /** - * This is a private API that's exported so that `@theatre/r3f/extension` + * This is a private API that's exported so that `@theatre/r3f/dist/extension` * and `@theatre/r3f` can talk to one another. This API _could_ change * between patch releases, so please don't build on it :) *