welives / vitepress-code-preview

一款给 vitepress 文档中嵌入的 Vue 示例代码增加演示功能的插件, 支持 SFC, JSX, TSX
https://welives.github.io/vitepress-code-preview/
MIT License
15 stars 4 forks source link

vitepress build failed #9

Closed changweihua closed 3 months ago

changweihua commented 3 months ago

When i try to run docs build, it failed.

Any thing about rollup?

x Build failed in 8.94s ✖ building client + server bundles... parse markdown error in function transformCodeToComponent build error: [vite]: Rollup failed to resolve import "virtual:vite_npm.md.21e0c5cf.bash" from "/home/runner/work/changweihua.github.io/changweihua.github.io/zh-CN/blog/2024-07/vite_npm.md". This is most likely unintended because it can break your application at runtime. If you do want to externalize this module explicitly add it to build.rollupOptions.external [vite]: Rollup failed to resolve import "virtual:vite_npm.md.21e0c5cf.bash" from "/home/runner/work/changweihua.github.io/changweihua.github.io/zh-CN/blog/2024-07/vite_npm.md". This is most likely unintended because it can break your application at runtime. If you do want to externalize this module explicitly add it to build.rollupOptions.external at viteWarn (file:///home/runner/work/changweihua.github.io/changweihua.github.io/node_modules/vite/dist/node/chunks/dep-BzOvws4Y.js:65477:17) at onRollupWarning (file:///home/runner/work/changweihua.github.io/changweihua.github.io/node_modules/vite/dist/node/chunks/dep-BzOvws4Y.js:65509:5) at onwarn (file:///home/runner/work/changweihua.github.io/changweihua.github.io/node_modules/vite/dist/node/chunks/dep-BzOvws4Y.js:65172:7) at file:///home/runner/work/changweihua.github.io/changweihua.github.io/node_modules/rollup/dist/es/shared/node-entry.js:18646:13 at Object.logger [as onLog] (file:///home/runner/work/changweihua.github.io/changweihua.github.io/node_modules/rollup/dist/es/shared/node-entry.js:20301:9) at ModuleLoader.handleInvalidResolvedId (file:///home/runner/work/changweihua.github.io/changweihua.github.io/node_modules/rollup/dist/es/shared/node-entry.js:19236:26) at file:///home/runner/work/changweihua.github.io/changweihua.github.io/node_modules/rollup/dist/es/shared/node-entry.js:19194:26 Error: Process completed with exit code 1.

changweihua commented 3 months ago

⠋ building client + server bundles...parse markdown error in function transformCodeToComponent parse markdown error in function transformCodeToComponent ⠼ building client + server bundles...parse markdown error in function transformCodeToComponent

changweihua commented 3 months ago

There are something helpful .

When markdown content contains demo , error will occured .

const hasDemo = node.children[0].value.trim().match(/demo\s*(.*)$/)

Rollup failed to resolve import "virtual:vite_npm.

still something more need to be found because when my files building, parse markdown error in function transformCodeToComponent was shown many times

welives commented 3 months ago

你编译报错时的markdown是怎么写的?

const hasDemo = node.children[0].value.trim().match(/demo\s*(.*)$/)

你觉得是这段代码引起的?

changweihua commented 3 months ago

猜测,因为我把demo换成sample就没问题了

sample项目,安装该开发中的库:

# 安装:这里link相当于install
npm link packagename

# 从`sample`项目的node_modules目录中删除该库,
# 但库的软链接还是会留在全局的node_modules目录中
npm unlink packagename

查看sample项目中,是否成功安装该库:

你可以试试,把sample换成demo。

welives commented 3 months ago

example_1 example_2

我在子项目docs里试了,没重现你的遇到的编译错误

changweihua commented 3 months ago

demo项目,安装该开发中的库:

# 安装:这里link相当于install
npm link packagename

# 从`demo`项目的node_modules目录中删除该库,
# 但库的软链接还是会留在全局的node_modules目录中
npm unlink packagename

查看demo项目中,是否成功安装该库:

你看我的,是在代码块内还有个demo

# 安装:这里link相当于install
npm link packagename

# 从`sample`项目的node_modules目录中删除该库,
# 但库的软链接还是会留在全局的node_modules目录中
npm unlink packagename
changweihua commented 3 months ago

JZF}`5R84I0H1LB KB{%R~6

changweihua commented 3 months ago

判断demo是不是应该用:::demo比较好,和下面判断 :::demo src 一样

welives commented 3 months ago

判断demo是不是应该用:::demo比较好,和下面判断 :::demo src 一样

plugin子项目推更新了,大概半小时这样npm就刷新了缓存了

我直接改成严格全等了

const hasDemo = node.children[0].value.trim() === ':::demo'