transitive-bullshit / npm-es-modules

Breakdown of 7 different ways to use ES modules with npm today.
74 stars 10 forks source link

Discussing esm + best practices #2

Open transitive-bullshit opened 6 years ago

transitive-bullshit commented 6 years ago

This issue is intended to discuss @jdalton's PR #1 in more depth, with the goal of unifying a set of best practices across the other example modules.

One thing I'll likely do in the near future is create a sibling repo that doesn't create different browser and node entrypoints, because that's complicated these examples quite a bit, and I feel like it's not necessary for the majority use case.

@jdalton a few notes on your PR (merged):

  1. Completely agree with having files end in js instead of mjs. Trying to get existing tools to play nicely with mjs is currently a serious pain point.

  2. Having index.js instead of main.js is reasonable, in terms of interop with existing developer expectations, but then renaming the ES module entrypoint main.js instead of module.js seems really weird and backwards to me, so I reverted this part of the change.

  3. I was surprised to find that the webpack config wouldn't load because of it's ES module syntax after the PR, but once I moved the example to its own, isolated directory, everything worked fine. It seems there's some oddness around different versions of ava being included in different workspaces within the same lerna monorepo. To get around this, I just ended up upgrading all uses of ava to the latest alpha.

  4. I'm going through now and applying as many of your suggestions to the other example modules as possible.

jdalton commented 6 years ago
transitive-bullshit commented 6 years ago

Can you provide a bit more info on the webpack issue?

This was just caused by it using an older version of ava that didn't recognize the "compileEnhancements": false option.

jdalton commented 6 years ago

Ah ok cool! So that means it all works now? If so could you update your post with the simplified babel-less bits.