-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Emit ESM build via tsup #5148
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
Merged
Merged
Emit ESM build via tsup #5148
Conversation
This file contains hidden or 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 was referenced Oct 25, 2024
Open
Open
Open
Open
Open
Open
Open
Open
Open
This was referenced Nov 1, 2024
Open
Open
Open
Open
Open
Open
Open
Open
Open
Open
This was referenced Nov 8, 2024
Open
Open
Open
Open
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.
Changelog Entry
Breaking changes
connect*,useRenderActivity,useRenderActivityStatus,useRenderAvatar, in PR #5148, by @compulimAdded
moduleFormatandtranspilerbuild info to<meta>tag, in PR #5148, by @compulimFixed
useNotifications, in PR #5148, by @compulimDescription
We are adding ES Modules (named exports only) along with CommonJS (both named and unnamed exports).
We expect CommonJS will only used by Webpack 4. And for most web developers who are already using modern pipeline (esbuild, Webpack 5, etc.), they should be using ES Modules.
Design
In our previous citation work, we are adding
valibotpackages. However, this is breakingcreate-react-appbecause of CJS/ESM interoperability. To efficiently resolve the issue, we are exporting ESM byesbuildandtsup.tsupalso tells us a lot of type portability issues. We are resolving many of them in this pull request.Type portability
Some exported code contains types that are not exported. We deployed 2 strategies:
WebChatAPIContextshould not be exported, but only partial of itWebChatAPIContextis directly exporting dispatchers from our internal Redux, so we are rewriting the type so it don't need to expose the typing of our internal ReduxUnify exporting types
All types are now exported via
export { type SomeType }, instead ofexport type SomeType. Default exports should be reserved for code.Precompiling
globalizeglobalizedefault use CommonJS/AMD for its runtime. This doesn't play well withesbuild. We are replacing its code-emitting template to emit solely CJS instead.We also tried to emit ESM but it will call
require()in some part ofglobalize. Switching between CJS/ESM is not very foolproof untilglobalizeexports ESM.Emitting instrumentation code
We cannot use
esbuild-plugin-istanbulbecause it sometimes not emitting instrumentation code related to JSX.We have to add
@babel/preset-typescriptand@babel/preset-reactbeforebabel-plugin-istanbul.We looked at
@istanbuljs/instrumenterbut printing the code seems more difficult to do than simply running@babel/core/transformAsync.Version of
@types/reactIt is confusing to use
@types/react@18withreact@16.8.6. We are unifying all versions to be@types/react@16instead.Some
FC/VFCwere removed in favor of newer type signature. SomeSomeComponent.propTypesandSomeComponent.defaultPropswere also removed.We should do a bigger push to clean up
FC/VFC/propTypes/defaultPropsand mark all props as read-only.Specific Changes
packages/fluent-theme/package.json/maintobotframework-webchat-fluent-theme.jsfromindex.jsCHANGELOG.mdReview Checklist
Accessibility reviewed (tab order, content readability, alt text, color contrast)CSS styles reviewed (minimal rules, noz-index)Internationalization reviewed (strings, unit formatting)package.jsonandpackage-lock.jsonreviewedSecurity reviewed (no data URIs, check for nonce leak)