Skip to content

fix: Convert to ESM#2227

Merged
UziTech merged 11 commits intomarkedjs:masterfrom
benmccann:esm-named-only
Nov 2, 2021
Merged

fix: Convert to ESM#2227
UziTech merged 11 commits intomarkedjs:masterfrom
benmccann:esm-named-only

Conversation

@benmccann
Copy link
Copy Markdown
Contributor

@benmccann benmccann commented Oct 7, 2021

Marked version: master

Markdown flavor: all

Description

Converts the source code to ESM to be more modern and allow Rollup to better handle it. Rollup will still convert the final code to be UMD / ESM, but will do so more efficiently resulting in smaller output files

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
Copy Markdown

vercel bot commented Oct 7, 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/4GVhinkD5B8e9yGBnM2czZnEa748
✅ Preview: https://markedjs-git-fork-benmccann-esm-named-only-markedjs.vercel.app

Comment thread test/helpers/helpers.js Outdated
Comment thread test/unit/marked-spec.js
@UziTech UziTech mentioned this pull request Oct 8, 2021
5 tasks
@UziTech
Copy link
Copy Markdown
Member

UziTech commented Oct 8, 2021

We could probably remove lib/marked.esm.js with this update. Or make it just a file that exports src/marked.js

@benmccann
Copy link
Copy Markdown
Contributor Author

Ok, I've added "type": "module" and converted all the tests to ESM as well

We could probably remove lib/marked.esm.js with this update. Or make it just a file that exports src/marked.js

We could, but I actually think it might be preferable to keep as is so that we know the UMD and ESM versions have the same exposed APIs. I think it could be easier to document and explain that way.

Comment thread lib/marked.js
@benmccann
Copy link
Copy Markdown
Contributor Author

@UziTech I was wondering if you had any other thoughts about this? Is it something we could move forward with in the near future to avoid merge conflicts from accruing?

@UziTech
Copy link
Copy Markdown
Member

UziTech commented Oct 20, 2021

Looks like vercel is failing because npm run build:docs is failing. That will need to be fixed before this is merged.

@benmccann
Copy link
Copy Markdown
Contributor Author

Ok, thanks for letting me know. I didn't have permission to see the Vercel link, so didn't know what was wrong. I've updated it so that it's working now

@UziTech
Copy link
Copy Markdown
Member

UziTech commented Oct 22, 2021

I'll take a look at this soon and make sure all the ways of importing marked works or see where we would have to update our docs.

@UziTech
Copy link
Copy Markdown
Member

UziTech commented Oct 24, 2021

Can you fix the npm run bench command? it seems to have some issues with ESM.

@benmccann
Copy link
Copy Markdown
Contributor Author

I think that might have been from @UziTech 's changes. I'm not sure if perhaps that file is autogenerated from something, but I just manually updated it

@UziTech
Copy link
Copy Markdown
Member

UziTech commented Oct 31, 2021

That is auto generated but we can edit it manually.

marked/Makefile

Lines 12 to 13 in e93f800

man/marked.1.txt:
groff -man -Tascii man/marked.1 | col -b > man/marked.1.txt

@benmccann
Copy link
Copy Markdown
Contributor Author

Cool. Do we need to wait for @davisjam, @joshbruce and @styfle to weigh in before merging?

@UziTech
Copy link
Copy Markdown
Member

UziTech commented Nov 1, 2021

I was just giving a little bit of time for anyone to weigh in. I'll merge this later today if there is no issues.

@UziTech UziTech changed the title Convert to ESM fix: Convert to ESM Nov 2, 2021
@UziTech UziTech merged commit 4afb228 into markedjs:master Nov 2, 2021
github-actions bot pushed a commit that referenced this pull request Nov 2, 2021
# [4.0.0](v3.0.8...v4.0.0) (2021-11-02)

### Bug Fixes

* Convert to ESM ([#2227](#2227)) ([4afb228](4afb228))

### BREAKING CHANGES

* - Default export removed. Use `import { marked } from 'marked'` or `const { marked } = require('marked')` instead.
- `/lib/marked.js` removed. Use `/marked.min.js` in script tag instead.
- When using marked in a script tag use `marked.parse(...)` instead of `marked(...)`
@github-actions
Copy link
Copy Markdown

github-actions bot commented Nov 2, 2021

🎉 This PR is included in version 4.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

XuluWarrior added a commit to XuluWarrior/jsonresume-theme-kards that referenced this pull request Dec 3, 2021
XuluWarrior added a commit to XuluWarrior/jsonresume-theme-orbit-original that referenced this pull request Dec 3, 2021
XuluWarrior added a commit to XuluWarrior/jsonresume-theme-orbit that referenced this pull request Jan 1, 2022
@jimmywarting
Copy link
Copy Markdown
Contributor

Ty 4 this!

Logiclayer1111 pushed a commit to Logiclayer1111/marked that referenced this pull request Apr 20, 2026
# [4.0.0](markedjs/marked@v3.0.8...v4.0.0) (2021-11-02)

### Bug Fixes

* Convert to ESM ([#2227](markedjs/marked#2227)) ([0b0522e](markedjs/marked@0b0522e))

### BREAKING CHANGES

* - Default export removed. Use `import { marked } from 'marked'` or `const { marked } = require('marked')` instead.
- `/lib/marked.js` removed. Use `/marked.min.js` in script tag instead.
- When using marked in a script tag use `marked.parse(...)` instead of `marked(...)`
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.

4 participants