Code Monkey home page Code Monkey logo

Comments (10)

wooorm avatar wooorm commented on June 12, 2024

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

from direction.

wooorm avatar wooorm commented on June 12, 2024

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!

from direction.

milesj avatar milesj commented on June 12, 2024

I disagree that it's working as intended. I'll just stick with v1 indefinitely.

from direction.

wooorm avatar wooorm commented on June 12, 2024

I'll just stick with v1 indefinitely.

What’s your reasoning for never wanting to use ESM?

from direction.

milesj avatar milesj commented on June 12, 2024

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.

from direction.

wooorm avatar wooorm commented on June 12, 2024

This is a library that can be used in both web and node contexts, and should work in both of them without issue.

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.

As of right now, this is not the case

Incorrect. This project can be loaded in browsers. It couldn’t before.

I'd also say that ESM only isn't offering any benefit over the v1 code.

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.

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.

I’m not suggesting to change for a single project.
The shift is happening. Folks are changing to ESM. Even if that didn’t happen for existing tools, I think it’s allowed for developers of new projects to choose ESM. Users of dependencies will have to deal with it some time.
And existing tools will change. Soon. Did you see https://twitter.com/sindresorhus/status/1349294527350149121?

from direction.

milesj avatar milesj commented on June 12, 2024

@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.

from direction.

wooorm avatar wooorm commented on June 12, 2024

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.

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

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 direction) used to have browser builds, Bower and Component.js manifests... It’s a lot of work.

For “until we hit that threshold”, agreed, but my perspective is that we reach that in 31 days

from direction.

milesj avatar milesj commented on June 12, 2024

What’s the threshold here? When is it OK?

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.

from direction.

wooorm avatar wooorm commented on June 12, 2024

just the current state of things is non-ideal.

Yep!

I'll just wait till everything catches up.

I think that’s totally valid!

from direction.

Related Issues (3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.