remark-mdx plugin does not support import alias - throw Errors.
sxhuan opened this issue · comments
StanleyS commented
Initial checklist
- I read the support docs
- I read the contributing guide
- I agree to follow the code of conduct
- I searched issues and couldn’t find anything (or linked relevant results below)
Affected packages and versions
remark-mdx ^2.2.1
Link to runnable example
No response
Steps to reproduce
I got the error below when I use the import alias.
My example code:
import { remark } from "remark";
import remarkMdx from "remark-mdx";
const outputStream = remark().use(remarkMdx) processSync(`
import { Test as AliasTest } from "my-package"
`)
remove alias "as" it works fine.
Expected behavior
I should get the return stream without any error
Actual behavior
Error throw out
node:internal/process/promises:289
│ triggerUncaughtException(err, true /* fromPromise */);
│ ^
│ [7:26: Could not parse expression with acorn: Unexpected content after expression] {
│ reason: 'Could not parse expression with acorn: Unexpected content after expression',
│ line: 7,
│ column: 26,
│ position: {
│ start: { line: 7, column: 26, offset: 211 },
│ end: { line: null, column: null }
│ },
│ source: 'micromark-extension-mdx-expression',
│ ruleId: 'acorn'
│ }
│ Node.js v19.0.1
Runtime
Other (please specify in steps to reproduce)
Package manager
npm v8
OS
macOS
Build and bundle tools
esbuild, Other (please specify in steps to reproduce)
Titus commented
Exports/imports must start on the first column. You use an indented string. Don’t:
const outputStream = remark().use(remarkMdx) processSync(`
import { Test as AliasTest } from "my-package"
`)