-
-
Notifications
You must be signed in to change notification settings - Fork 2
Closed
Description
Hi! Thank you for providing this nice preset!
I found a behavior that this preset is not work with ESM. It occurs with the latest version remark-preset-prettier@0.5.1
.
Let me show for the details.
Reproduction
Prepare the following files.
package.json
:
{
"type": "module",
"dependencies": {
"remark-cli": "10.0.0",
"remark-preset-lint-markdown-style-guide": "5.0.0",
"remark-preset-prettier": "0.5.1"
},
"scripts": {
"remark": "remark ."
}
}
.remarkrc.js
:
export default {
plugins: [
'remark-preset-lint-markdown-style-guide',
'remark-preset-prettier',
],
};
test.md
:
- a
- b
Run:
$ npm run remark
> remark
> remark .
test.md
1:5 warning Incorrect list-item indent: remove 2 spaces list-item-indent remark-lint
2:5 warning Incorrect list-item indent: remove 2 spaces list-item-indent remark-lint
⚠ 2 warnings
I expect no warnings, but 2 warnings are detected.
When I inspected node_modules/remark-preset-prettier/lib/index.js
, I found an ignored exception (_a
) at line 43:
try {
plugins.push([cjsRequire('remark-lint-' + plugin), false]);
}
catch (_a) { }
return plugins;
This ignored exception's message is something like:
Error [ERR_REQUIRE_ESM]: require() of ES Module /private/tmp/foo/node_modules/remark-lint-unordered-list-marker-style/index.js from /private/tmp/foo/node_modules/remark-preset-prettier/lib/index.js not supported.
Instead change the require of /private/tmp/foo/node_modules/remark-lint-unordered-list-marker-style/index.js in /private/tmp/foo/node_modules/remark-preset-prettier/lib/index.js to a dynamic import() which is available in all CommonJS modules.
Maybe, this exception is related to this behavior. 🤔
Environment
- OS: macOS 11.5.2 20G95
- Node.js: 16.6.1
- npm: 7.20.3
If the reproduction above or my understandings are incorrect, please feel free to tell me or close this issue.
Thank you.
Metadata
Metadata
Assignees
Labels
No labels