-
Notifications
You must be signed in to change notification settings - Fork 339
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
v2.3.0-beta build is not esm compliant #204
Comments
Interesting, thanks for pointing this out. I introduced this overwrite because Nonetheless, it's somewhat concerning that some tools can't handle I found this article which also points to this problem. Can you point me to an official resource that suggest how it should be done? I'd love to do this in an ESM compliant way, but without compromising support for commonly used build setups. Preact seems to export both ( |
I really don't like these tools for that reason. To really get an overview of the size, you need to test with multiple bundlers.
That article doesn't suggest a good practice btw. Just to provide some qualification here, I added ESM support to
I don't try to support these older tools. Instead, I just force them to use cjs.
Preact has a bigger interest here since they want to have the smallest size possible, even for older bundlers. Bundlers that support |
Thanks for your insights, interesting points.
You are right, they definitely don't tell you the whole story. I still like to use them, because they give me a feel what impact a PR has on bundle size. (Did it add or remove weight?)
Good point that old bundlers can use cjs as fallback. The problem with my size-limit example was, that I forced .mjs on it, which wouldn't happen if the bundler resolved it by itself.
That'd be cool. I'm playing around with it as well. This is a snippet of the version I have right now. Is that what you envisioned? "main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"exports": {
"./package.json": "./package.json",
".": {
"import": "./dist/index.mjs",
"require": "./dist/index.js",
"types": "./dist/index.d.ts"
},
"./headless": {
"import": "./headless/index.mjs",
"require": "./headless/index.js",
"types": "./headless/index.d.ts"
}
} |
Yes that's mostly right! But if you're using the |
* Update package.json according to #204
Thanks @timolins! The new release looks good |
In the new v2.3.0-beta build,
outExtension
was overridden with the build format:react-hot-toast/tsup.config.ts
Lines 9 to 13 in 39c1bda
This is not compliant with esm. tsup emits with the
.mjs
extension by default because packages with"type": "commonjs"
(all packages implicitly have this) must use the.mjs
extension for esm files according to Node's resolution. Bundlers may be more forgiving.The text was updated successfully, but these errors were encountered: