-
Notifications
You must be signed in to change notification settings - Fork 32
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
chore: Switch to tsup for building and update dependencies #298
Merged
+1,839
−2,789
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
📊 Package size report -31.5%↓
Unchanged files
🤖 This report was automatically generated by pkg-size-action |
jonahallibone
approved these changes
Jun 13, 2024
This was referenced Sep 3, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
closes #260
This PR switches away from
babel
+tsc
for the build process totsup
for building the package.tsup
is a build tool based onesbuild
, which is built using golang for fast build times. The old build process was basically copied directly from Chakra UI's old build process, and they have since switched totsup
, so I figured it would be good to update: https://github.com/chakra-ui/chakra-ui/blob/main/packages/components/input/package.json#L53This motivation to make this switch was originally sparked by arethetypeswrong, which shows that the ESM exports aren't actually working properly (only the CJS files will ever actually be imported).
tsup
has the benefit of outputting the the ESM version of the files using the necessary.mjs
file extension, which allows for theexports
field in thepackage.json
to work properly, as this package is using the default of"type": "commonjs"
in the package.json. (if this project was using"type": "module"
the ESM files would be compiled to.js
files while the commonjs files would be exported as.cjs
). I also switched the"module"
field in the"exports"
field to be"import"
, as I realized the ESM version still wasn't being imported without this. I'm really not sure what the difference between these two options are, as I see different projects use each of them differently.This updated build strategy also appears to solve the problem mentioned in #260, where the
id
prop coming from Chakra'suseFormControl
hook were not defined on the server. I realized that theid
issue should not actually have been happening, as theuseFormControl
hook uses the built-inuseId
hook, which is supposed to provide an isomorphic id across the server and client. Previously however, theid
field from the form control hook was coming back undefined in the initial Next.js load. Here's the example CodeSandbox from the original issue (see the generated CodeSandbox below for the now working version): https://codesandbox.io/s/9089o6Here are the results from arethetypeswrong:
Before
https://arethetypeswrong.github.io/?p=chakra-react-select%404.7.5
After