Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove re-exports from node package #11683

Conversation

markdalgleish
Copy link
Member

NOTE: This is a draft PR pointing at #11669.

Copy link

changeset-bot bot commented Jun 19, 2024

⚠️ No Changeset found

Latest commit: bc3a2a3

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/esm/index.mjs",
Copy link
Member Author

@markdalgleish markdalgleish Jun 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're no longer re-exporting the react-router/server API, consumers now import from both react-router/server and @react-router/node in their app. Since react-router/server ships ESM + CJS while @react-router/node currently only ships CJS, this introduces a new instance of the dual package hazard since consumers can end up with both ESM and CJS builds in memory. Most of the time this won't cause issues, but it can cause issues with instanceof checks across this package boundary.

In our case, this issue was caught because we're doing an instanceof MaxPartSizeExceededError check in integration/error-test.ts. In our test app, @react-router/node is using the CJS build of MaxPartSizeExceededError but then the app code is comparing it to the ESM build of MaxPartSizeExceededError, resulting in an instanceof check evaluating to false. The test failed until this additional ESM version of @react-router/node was added.

Another alternative would be for us to remove the ESM version of react-router/server and only use CJS (which @react-router/node currently does).

Comment on lines +65 to +68
// Aliases previously provided by runtime packages
ServerRuntimeMetaArgs as MetaArgs,
ServerRuntimeMetaDescriptor as MetaDescriptor,
ServerRuntimeMetaFunction as MetaFunction,
Copy link
Member Author

@markdalgleish markdalgleish Jun 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

☝️ Just calling out that this API is changing since it was being aliased when re-exported from @react-router/node.

Comment on lines +23 to +26
"./install": {
"types": "./dist/install.d.ts",
"default": "./dist/install.js"
},
Copy link
Member Author

@markdalgleish markdalgleish Jun 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note, this is replaying a subset of changes from #11675 (along with other related changes in service of this). Now that we have an exports field, this must be included.

Copy link
Member Author

@markdalgleish markdalgleish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Closing for now since this will be revisited on top of #11698.

@markdalgleish markdalgleish deleted the markdalgleish/simplify-node-package branch July 1, 2024 01:09
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.

1 participant