[GH-ISSUE #788] "Failed to resolve markdownlint-micromark" when using markdownlint in a browser build #534

Closed
opened 2026-03-03 01:27:45 +03:00 by kerem · 2 comments
Owner

Originally created by @stephane-martin on GitHub (Apr 23, 2023).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/788

Description

I import markdownlint in a browser build using parcel (the point is to provide markdown linting to some codemirror editor). Something like:

import markdownlint from "markdownlint"

async function m(view) {
    return await markdownlint.promises.markdownlint({
        strings: {
            current: view.state.doc.sliceString(0),
        },
        config: {
            MD013: { // line length
                code_block_line_length: 92,
                code_blocks: true,
                heading_line_length: 92,
                headings: true,
                line_length: 92,
                stern: false,
                strict: false,
                tables: false,
            },
            MD041: false, // first line heading
            MD047: false, // single trailing newline
        },
    })
}

No problem using v0.27. But from v0.28.1 i get at build time:

@parcel/core: Failed to resolve 'markdownlint-micromark' from './.yarn/cache/markdownlint-npm-0.28.1-7ecbfb2613-d606e3f069.zip/node_modules/markdownlint/helpers/micromark.cjs'

  .../.yarn/cache/markdownlint-npm-0.28.1-7ecbfb2613-d606e3f069.zip/node_modules/markdownlint/helpers/micromark.cjs:9:13
     8 |   // @ts-ignore
  >  9 | } = require("markdownlint-micromark");
  >    |             ^^^^^^^^^^^^^^^^^^^^^^^^
    10 |
    11 | /**

I guess it has something to do with CommonJS vs ES6 packaging, but I couldn't find a workaround.

Environment

parcel 2.8.3 to build a browser app (not node.js)

MDL Version
0.28.1

Expected Behavior

build successful

Actual Behavior

build fails: parcel unable to resolve markdownlint-micromark lib/

Originally created by @stephane-martin on GitHub (Apr 23, 2023). Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/788 ## Description I import markdownlint in a browser build using parcel (the point is to provide markdown linting to some codemirror editor). Something like: ```javascript import markdownlint from "markdownlint" async function m(view) { return await markdownlint.promises.markdownlint({ strings: { current: view.state.doc.sliceString(0), }, config: { MD013: { // line length code_block_line_length: 92, code_blocks: true, heading_line_length: 92, headings: true, line_length: 92, stern: false, strict: false, tables: false, }, MD041: false, // first line heading MD047: false, // single trailing newline }, }) } ``` No problem using v0.27. But from v0.28.1 i get at build time: ``` @parcel/core: Failed to resolve 'markdownlint-micromark' from './.yarn/cache/markdownlint-npm-0.28.1-7ecbfb2613-d606e3f069.zip/node_modules/markdownlint/helpers/micromark.cjs' .../.yarn/cache/markdownlint-npm-0.28.1-7ecbfb2613-d606e3f069.zip/node_modules/markdownlint/helpers/micromark.cjs:9:13 8 | // @ts-ignore > 9 | } = require("markdownlint-micromark"); > | ^^^^^^^^^^^^^^^^^^^^^^^^ 10 | 11 | /** ``` I guess it has something to do with CommonJS vs ES6 packaging, but I couldn't find a workaround. ### Environment parcel 2.8.3 to build a browser app (not node.js) **MDL Version** 0.28.1 ### Expected Behavior build successful ### Actual Behavior build fails: parcel unable to resolve markdownlint-micromark lib/
kerem 2026-03-03 01:27:45 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@DavidAnson commented on GitHub (Apr 24, 2023):

You should be able to load it with a script tag like the demo does:

github.com/DavidAnson/markdownlint@fcb8190781/demo/default.htm (L37)

https://dlaa.me/markdownlint/

<!-- gh-comment-id:1519207346 --> @DavidAnson commented on GitHub (Apr 24, 2023): You should be able to load it with a script tag like the demo does: https://github.com/DavidAnson/markdownlint/blob/fcb8190781c80b292ac44f6df984326e0e6c69cd/demo/default.htm#L37 https://dlaa.me/markdownlint/
Author
Owner

@DavidAnson commented on GitHub (Apr 24, 2023):

Or maybe you are not using the browser build? In which case, I'm not sure why your scenario is different than standard Node dependency resolution?

For example: github.com/DavidAnson/markdownlint-cli2@0654309961

<!-- gh-comment-id:1519208154 --> @DavidAnson commented on GitHub (Apr 24, 2023): Or maybe you are not using the browser build? In which case, I'm not sure why your scenario is different than standard Node dependency resolution? For example: https://github.com/DavidAnson/markdownlint-cli2/commit/065430996160a0dbaa957884cba5cac9b2ffb910
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/markdownlint#534
No description provided.