Skip to content
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

Create separate CJS and UMD builds #2281

Merged
merged 1 commit into from
Nov 12, 2021
Merged

Conversation

benmccann
Copy link
Contributor

@benmccann benmccann commented Nov 12, 2021

Marked version: 4.0.1

Markdown flavor: n/a

Description

Fixes #2265

This comment pointed out that it would be very weird to use a CJS file in the browser: #2265 (comment)

That's true, but it's not actually CJS. It's UMD. And I think UMD was specified for the CDNs, which makes a lot more sense. It's just really confusing the way we have it setup now because the file extension doesn't match the actual file type.

Putting a UMD file as main is breaking people in 4.0.1. I didn't realize we were doing that in the last PR because I was thrown off by the file extensions. Bundlers generally know how to deal with CJS and ESM, but not UMD. It's reported that this change fixes things: #2265 (comment)

Contributor

  • Test(s) exist to ensure functionality and minimize regression (if no tests added, list tests covering this PR); or,
  • no tests required for this PR.
  • If submitting new feature, it has been documented in the appropriate places.

Committer

In most cases, this should be a different person than the contributor.

@vercel
Copy link

vercel bot commented Nov 12, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/markedjs/markedjs/Cvg8tgQHQVgfWDbN9XKNiiAVpWWH
✅ Preview: https://markedjs-git-fork-benmccann-browser-esm-markedjs.vercel.app

@benmccann benmccann changed the title Use ESM build for browser key in package.json Create separate CJS and UMD builds Nov 12, 2021
@UziTech
Copy link
Member

UziTech commented Nov 12, 2021

@benmccann You have been helping out a lot recently. Would you like to join @markedjs and help maintain marked?

@benmccann
Copy link
Contributor Author

Thanks for the offer, but I'll probably disappear once this conversion to ESM has settled down 😄 I've got a fair amount of open source projects on my plate already

Copy link
Member

@styfle styfle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its an unfortunate state of the JS ecosystem but this change looks correct, thanks!

@UziTech UziTech merged commit 62faaf4 into markedjs:master Nov 12, 2021
github-actions bot pushed a commit that referenced this pull request Nov 12, 2021
## [4.0.2](v4.0.1...v4.0.2) (2021-11-12)

### Bug Fixes

* Create separate CJS and UMD builds ([#2281](#2281)) ([62faaf4](62faaf4))
@github-actions
Copy link

🎉 This PR is included in version 4.0.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

@splch
Copy link

splch commented Nov 12, 2021

Just to understand this correctly, if we're using marked on the client side, we now will be using lib/marked.umd.js?

@UziTech
Copy link
Member

UziTech commented Nov 12, 2021

@splch if you are using marked in a script tag you should use /marked.min.js. if you use marked in node or webpack you should use import { marked } from 'marked'; and the loader should choose the correct file.

The cjs and umd files should be the exact same the only difference should be the file name which some loaders require to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

module import/export issue
4 participants