Uh oh!
There was an error while loading. Please reload this page.
feat: ES Module entry point - #1452
Conversation
UziTech
commented
Mar 21, 2019
It is going to break a lot of stuff if our main entry point isn't Would it be possible to just add |
tmcw
commented
Mar 21, 2019
This PR doesn't change the main entry point -
Not exactly - ES Module syntax is not a superset of (CommonJS + ES Module), it's just ES Module syntax. So if /lib/marked.js was CommonJS and was included with |
UziTech
commented
Mar 21, 2019
since it is in .gitignore it won't show up on any site using marked on the client side with: <scriptsrc="https://cdn.jsdelivr.net/gh/markedjs/marked/lib/marked.js"></script> |
UziTech
commented
Mar 21, 2019
That is the reason |
tmcw
commented
Mar 21, 2019
Okay, ignoring generated files is my custom but isn't a requirement. I've pushed an update that re-includes lib/marked.js. |
UziTech
commented
Mar 21, 2019
Could we make |
tmcw
commented
Mar 21, 2019
Not with any out-of-the-box solution, as far as I can tell. Detecting & transforming a UMD export is a lot less certain than detecting & transforming an ES Module. |
TrySound
commented
Mar 21, 2019
mjs in module field is broken in webpack. Webpack is quite opinionated about it. Since it's not a requirement for esm in node I would suggest to not use mjs at all and go with |
BREAKING CHANGE: some module loaders will automatically take the module entry point when they previously loaded main. This adds a rollup dependency to produce a UMD bundle, like in previous marked releases, and allows marked to be written and consumed as an ES Module.
tmcw
commented
Mar 21, 2019
Webpack has such unique opinions. Switched to .esm.js. |
styfle
commented
Mar 21, 2019
I say we wait until Node gets ESM. Right now, the API is in flux and its best to wait until things settle down. Then we can actually run tests in CI against the ESM code. |
TrySound
commented
Mar 21, 2019
|
styfle
commented
Mar 22, 2019
I think I still stand by these comments from a previous PR: #1349 (comment) |
tmcw
commented
Mar 22, 2019
Okay - it's up to the project maintainers for a final decision, but I should point out that this PR addresses many of the concerns. It doesn't switch to ES6 syntax everywhere, it requires one additional dev dependency (instead of 7), there's one build target and rollup is super fast, there's net zero size change (instead of 5kb), and it'll run in a browser everywhere and unmodified (because it's a single-file source, so module specifiers don't matter). |
Andarist
commented
Aug 23, 2019
Unfortunately, after I've analyzed the exported module shape I've come to the conclusion that this cannot be done without breaking change because of webpack's broken interop between cjs/esm formats - webpack/webpack#7973 I would very much see this refactored to ESM and to a tree-shakeable form of exports, but that's up to Marked team. Just 2 add my 2 cents - while changes around this might be "breaking" they are not functional changes, the only way that would have to change is the exported shape. Bumping a minor (as marked still is in its 0.x versions) should be sufficient to introduce any breaking changes - instead of stalling forever it's IMHO better to push such things forwards for the greater good. |
BREAKING CHANGE: some module loaders will automatically take the
module entry point when they previously loaded main.
This adds a rollup dependency to produce a UMD bundle, like in previous
marked releases, and allows marked to be written and consumed as an ES
Module.
Fixes#1288
This does the same thing as #1349, but:
.mjsto let Node with--experimental-moduleswork for now. This could be changed if folks don't care too much about Node compatibility.lib/marked.jsis now a generated file and is regenerated when you test or publish.Note that this requires a major version bump, or at least a big warning. I wrote about this here, and it's essentially unavoidable because of Webpack's rather… questionable… choice of behavior.
Description
Contributor
Committer
In most cases, this should be a different person than the contributor.