-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
ESM + Jest #20
Comments
ref: wooorm/markdown-table#22. I’ve slowly started pushing ESM from the low-level tools outwards. The readme + these Jest links show some solutions. Jest is having a lot of troubles with it though. Here’s one solution with TS and ESM: https://github.com/kentcdodds/mdx-bundler/blob/ee6c8d9981df93aa519f662617278e1ec3f9b2da/jest.config.js |
Closing as it works as expected, there’s ways around it, and you don’t have to change just yet if you don’t feel like it! |
I disagree that it's working as intended. I'll just stick with v1 indefinitely. |
What’s your reasoning for never wanting to use ESM? |
This is a library that can be used in both web and node contexts, and should work in both of them without issue. As of right now, this is not the case. I'd also say that ESM only isn't offering any benefit over the v1 code. IMO, it's also not a good pattern to expect all downstream consumers to reconfigure their tooling for a single library to be able to run. |
ESM can be used in both. CJS can’t. This is specifically true for this project. For projects w/ dependencies, import maps (native, proposal) or a build step would still be needed. However, that’s already the case for CJS. ESM brings us closer to that interop you’re talking about.
Incorrect. This project can be loaded in browsers. It couldn’t before.
Not much, no, for this project. But the ecosystem moving towards a single import/export syntax is a good thing. I’m pretty happy with CJS, and would’ve been fine with not changing anything and instead browsers adopting it. But, ESM happened and it is better. It is the path forward.
I’m not suggesting to change for a single project. |
@wooorm Yeah I'm well aware of the current state of modules in the frontend ecosystem. But that's also the problem, we're not 100% on ESM yet, so supporting both/all variants is good practice until we hit that threshold. Just my 2 cents. I think once all popular tooling supports ESM natively, this will be a non-issue. |
What’s the threshold here? When is it OK? A lot of the tooling does already support it. Babel, Rollup, Vite, esbuild, tape, Node, ESLint, TS. I’ve had a great experience switching. April 30 is an important date, when Node 10 is EOL. Electron and Next are gearing up for that date too. I’m seeing a couple of projects struggling: Jest and Webpack. IMO it’s really on them, they’ve supported faux-ESM for years and never bothering to make actual ESM work. It’s called ES2015 modules. These projects have had the time. I think a nudge might help push these projects to support ESM.
I’ve had a terrible experience with dual publishing. Webpack 4 doesn’t handle it well. And there’s https://nodejs.org/api/packages.html#packages_dual_commonjs_es_module_packages. All these projects (that I maintain, such as For “until we hit that threshold”, agreed, but my perspective is that we reach that in 31 days |
When they all support it. 🤷 This is all wishful thinking but not realistic. Don't mean to cause conflict, just the current state of things is non-ideal. I'll just wait till everything catches up. |
Yep!
I think that’s totally valid! |
Because this package is ESM only now and doesn't pre-compile, it complete breaks all unit testing since most (if not all) of them are unable to import ESM files.
The text was updated successfully, but these errors were encountered: