Skip to content
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

mpa 项目引入 mdx, md 报错 #12121

Closed
tolerance-go opened this issue Feb 13, 2024 · 2 comments
Closed

mpa 项目引入 mdx, md 报错 #12121

tolerance-go opened this issue Feb 13, 2024 · 2 comments

Comments

@tolerance-go
Copy link

文档搜索了,这方面介绍比较少,提个 issue 给大佬有时间帮忙看下咋个解决

import { defineConfig } from "umi";

export default defineConfig({
  npmClient: "pnpm",
  base: process.env.NODE_ENV === "development" ? "/" : "/pages/",
  mpa: {
    template: "src/templates/default.html",
    getConfigFromEntryFile: true,
    layout: "@/layouts/basic",
  },
  mountElementId: "root",
  publicPath: process.env.NODE_ENV === "development" ? "/" : "/pages/",
  esbuildMinifyIIFE: true,
});

引入声明报错

image

启动也报错了

> @ dev C:\Users\yarnb\xrensheng-launch\packages\pages
> umi dev

X [ERROR] Syntax error " "

    src/pages/select-films-master/readme.mdx:1:1:
      1 │ # 选片大师
        ╵  ^

fatal - Error: Build failed with 1 error:
src/pages/select-films-master/readme.mdx:1:1: ERROR: Syntax error " "
    at failureErrorWithLog (C:\Users\yarnb\xrensheng-launch\node_modules\.pnpm\esbuild@0.17.19\node_modules\esbuild\lib\main.js:1636:15)
    at C:\Users\yarnb\xrensheng-launch\node_modules\.pnpm\esbuild@0.17.19\node_modules\esbuild\lib\main.js:1048:25
    at runOnEndCallbacks (C:\Users\yarnb\xrensheng-launch\node_modules\.pnpm\esbuild@0.17.19\node_modules\esbuild\lib\main.js:1471:45)
    at buildResponseToResult (C:\Users\yarnb\xrensheng-launch\node_modules\.pnpm\esbuild@0.17.19\node_modules\esbuild\lib\main.js:1046:7)
    at C:\Users\yarnb\xrensheng-launch\node_modules\.pnpm\esbuild@0.17.19\node_modules\esbuild\lib\main.js:1075:16
    at responseCallbacks.<computed> (C:\Users\yarnb\xrensheng-launch\node_modules\.pnpm\esbuild@0.17.19\node_modules\esbuild\lib\main.js:697:9)
    at handleIncomingPacket (C:\Users\yarnb\xrensheng-launch\node_modules\.pnpm\esbuild@0.17.19\node_modules\esbuild\lib\main.js:752:9)
    at Socket.readFromStdout (C:\Users\yarnb\xrensheng-launch\node_modules\.pnpm\esbuild@0.17.19\node_modules\esbuild\lib\main.js:673:7)
    at Socket.emit (node:events:518:28)
    at addChunk (node:internal/streams/readable:559:12) {
  errors: [
    {
      detail: undefined,
      id: '',
      location: [Object],
      notes: [],
      pluginName: '',
      text: 'Syntax error " "'
    }
  ],
  warnings: []
}
fatal - A complete log of this run can be found in:
fatal - C:\Users\yarnb\xrensheng-launch\packages\pages\node_modules\.cache\logger\umi.log
fatal - Consider reporting a GitHub issue on https://github.com/umijs/umi/issues
@tolerance-go
Copy link
Author

"umi": "^4.1.0"

@tolerance-go tolerance-go changed the title mpa 项目引入 mdx 报错 mpa 项目引入 mdx, md 报错 Feb 13, 2024
@fz6m
Copy link
Contributor

fz6m commented Feb 13, 2024

报错的问题是因为 mpa 的 getConfigFromEntryFile 这个功能是实验性的功能,还有很多问题,更多详细信息见 #12103

现在这个 getConfigFromEntryFile 选项不能和 mdx 导入一起用,如果你要继续用 mdx 的导入功能,就不要打开这个选项。

另外如果要直接导入 mdx ,需要单独的配置,参考:#11966

@fz6m fz6m closed this as completed Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants