Skip to content

Remove module-sync from node exports map#12708

Closed
brophdawg11 wants to merge 1 commit intodevfrom
brophdawg11/module-sync
Closed

Remove module-sync from node exports map#12708
brophdawg11 wants to merge 1 commit intodevfrom
brophdawg11/module-sync

Conversation

@brophdawg11
Copy link
Contributor

This removes the module-sync export from react-router which currently points to the ESM build.

From the Node docs:

"module-sync" - matches no matter the package is loaded via import, import() or require(). The format is expected to be ES modules that does not contain top-level await in its module graph - if it does, ERR_REQUIRE_ASYNC_MODULE will be thrown when the module is require()-ed.

It sounds like this would definitely cause issues for us to tell node to always load the ESM version - since if anything else loaded the CJS version we'd immediately have a mismatch?

Right now, we can run into issues like this on Node 22+ (repro) where we load the CJS and ESM versions during dev:

Screenshot 2025-01-08 at 10 46 21 AM

Prior to this PR I wasn't aware of module-sync, or if there was a specific reason we included it - so I'd like to get @jacob-ebey 's eyes on this as well before merging.

Closes #12475

@changeset-bot
Copy link

changeset-bot bot commented Jan 8, 2025

🦋 Changeset detected

Latest commit: 8671812

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages
Name Type
react-router Patch
@react-router/architect Patch
@react-router/cloudflare Patch
@react-router/dev Patch
react-router-dom Patch
@react-router/express Patch
@react-router/node Patch
@react-router/serve Patch
@react-router/fs-routes Patch
@react-router/remix-routes-option-adapter Patch
create-react-router Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@wobsoriano
Copy link
Contributor

Hi! I've tested this fix across multiple Node versions (from v20.x through v22.13) and can confirm it resolves our issue in the Clerk React Router SDK. 👍🏼 🚀

@brophdawg11
Copy link
Contributor Author

Replaced by #12729

@brophdawg11 brophdawg11 deleted the brophdawg11/module-sync branch January 14, 2025 15:33
haines added a commit to cerbos/react-router that referenced this pull request Mar 4, 2025
remix-run#12475
remix-run#12708

Signed-off-by: Andrew Haines <haines@cerbos.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"useSubmit must be used within a data router" for 3rd party libraries on node 22.12.0

2 participants