-
-
Notifications
You must be signed in to change notification settings - Fork 880
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
TypeError: parser is not a function #518
Comments
@pmartin-cogility thanks for the report, could you please fill in the full issue template? |
@pmartin-cogility trying this out with CRA in codesandbox, it appears to still work with the latest micromark (2.11.0). |
My app is a create-react-app ("react-scripts": "3.4.4") and TypeScript 4.1, so there's a good bit of code transpiling. Sorry. Don't have the time right now to fill out the issue template. Just wanted to post something in case anybody else has the issue. Also, I'm passing in a custom renderer to |
Here's the project working with CRA 3.4.4 and TypeScript 4.1.2 |
I'm also running into the same issue. I fixed it temporarily by downgrading to name: 🐛 Bug report
|
Thanks @dabit3, I'm able to reproduce that. /cc @TrySound thoughts or insights? |
This comment has been minimized.
This comment has been minimized.
This may be an upstream bug, it looks a lot like vercel/next.js#17806 |
@ChristianMurphy unsure if this helps, but the issue goes away when downgrading to version |
Both
and
point to micromark/micromark#36 as being related.
|
This comment has been minimized.
This comment has been minimized.
@saillinux please provide your build configuration or even better a codesandbox with an example. |
Just tried reproducing with a CodeSandbox but it worked there, but when I created a new app using CRA I got the same error. Steps to reproduce with CRA:
import Markdown from 'react-markdown'
const markdown = `
# Hello World
`
export default function App() {
return (
<div>
<Markdown children={markdown} />
</div>
);
}
Here's my package.json: {
"name": "markdown-with-cra",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-markdown": "^5.0.3",
"react-scripts": "4.0.1",
"web-vitals": "^0.2.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
} |
Default exports strikes again (there should not be a problem with named exports). |
Good morning everyone! Unfortunate, a bug, let me see what I can find. This seems to be webpack related. Rollup and Node itself work fine. Using the repro from @dabit3, it seems webpack is using ESM where require is used.
|
Just webpack w/o cra or next is fine: index.html: <!doctypehtml>
<title>hi</title>
<body>
<script src="./index.min.js"></script> index.js: import fromMarkdown from 'mdast-util-from-markdown'
console.log('tree:', fromMarkdown('# hi2')); package.json: {
"scripts": {
"test": "webpack"
},
"devDependencies": {
"mdast-util-from-markdown": "^0.8.4",
"webpack": "^5.10.0",
"webpack-cli": "^4.2.0"
}
} webpack.config.js: const path = require('path');
module.exports = {
entry: './index.js',
output: {path: __dirname, filename: 'index.min.js'}
};
|
This is solved in webpack to 5 |
This comment has been minimized.
This comment has been minimized.
webpack 4 is widely used (CRA, next) and does not like actual ESM + CJS projects if default exports are used. This removes ESM from `dist/` and tests on `lib/` (dev build) instead. Related to remarkjs/react-markdown#518. Related to syntax-tree/mdast-util-from-markdown#9.
Solved. Remove your lockfiles and reinstalling things should fix it for y’all |
Thank you @wooorm ! |
This error occurs because
micromark
(https://github.com/micromark/micromark/releases) updated from2.10.1
to2.11.0
.This lib is found in this dependency chain: react-markdown > remark-parse > mdast-util-from-markdown > micormark.
I fixed this issue by adding to my package.json:
The text was updated successfully, but these errors were encountered: