syntax-tree / mdast-util-from-markdown

mdast utility to parse markdown
MIT License
212 stars 20 forks source link

Parser broken #9

Closed jondashkyle closed 3 years ago

jondashkyle commented 3 years ago

Subject of the issue

Running into an issue with parser being undefined when using remark-parse. Traced the issue down to this dependency. Looks to have been introduced with the latest version of Micromark. After installing remark-parse@8.0.3 which limits mdast-util-from-markdown to semver ^0.7.0 it resolved my issue, so stopped pursuing. Leaving this here for triage, hopefully its useful!

https://github.com/syntax-tree/mdast-util-from-markdown/commit/24ec72a59505e83796301eb81993a544746a1c63

Your environment

Steps to reproduce

Install any unified plugin which depends upon mdast-util-from-markdown 0.8.4 and the latest version of micromark.

Expected behavior

Should parse the source successfully.

Actual behavior

Instead there is an error saying parse is not a function.

wooorm commented 3 years ago

hey thanks! Your steps to reproduce are too short. we have a lot of tests. It all works. I’m thinking it has to do with webpack or some other tooling you have set up

wooorm commented 3 years ago

Solved

jondashkyle commented 3 years ago

Hey! Sorry for the brevity in reproduction steps; took a while to hunt down the source of this bug and didn’t have the energy to clone locally and run the test suite :)

I had thought it could’ve been my local environment, but after spinning up a totally fresh directory and installing just the necessary dependencies (unified remark-parse remark-stringify) I ran into the same issue. After then installing an older version of remark-parse the problem was resolved, both in this fresh directory and my project directory.

Have you tried to reproduce outside of the testing? Possible test coverage doesn't catch this one.

wooorm commented 3 years ago

Heya!

A couple hours before you (while I was sleeping) this issue also arose: https://github.com/remarkjs/react-markdown/issues/518. Sorry I didn’t link that before, but that should have the info you’re looking for. Or does it seem your issue is completely unrelated?

ChristianMurphy commented 3 years ago

Have you tried to reproduce outside of the testing? Possible test coverage doesn't catch this one.

Coverage does not catch this.

The issue determined based off the reports in remarkjs/react-markdown#518 was improper handling of ESM/MJS by WebPack 4 with specific configs. Testing all possible build tools, with all possible configs is not feasible. There may be a happy middle, testing with some common build tool configs, but that brings up the thorny question of "what is a common build config?"

jondashkyle commented 3 years ago

@wooorm That resolved it! Huge thanks; this was a strange one.

@ChristianMurphy Totally. Not worth the trouble of expanding testing around this sort of issue since it was isolated to WebPack, and like you said, “when to say when” is a question with this type of thing.

Glad to know I wasn’t going crazy with this one! I encountered the problem after a decently sized refactor of my codebase, and was positive it was related to my own sloppiness for a couple hours 😂