Element-Plus-X icon indicating copy to clipboard operation
Element-Plus-X copied to clipboard

安装x-markdown-vue但没有安装shikijs,打包报错

Open ydeera opened this issue 6 months ago • 2 comments

问题描述

error during build:
node_modules/x-markdown-vue/dist/SyntaxCodeBlock-CBSKuntG.js (2:9): "getTokenStyleObject" is not exported by "__vite-optional-peer-dep:@shikijs/core:x-markdown-vue", imported by "node_modules/x-markdown-vue/dist/SyntaxCodeBlock-CBSKuntG.js".
file: project/node_modules/x-markdown-vue/dist/SyntaxCodeBlock-CBSKuntG.js:2:9

1: import { defineComponent as j, computed as i, createElementBlock as r, openBlock as s, normalizeClass as x, normalize...
2: import { getTokenStyleObject as F } from "@shikijs/core";
3: import { u as K } from "./useHighlight-DjG1N8Eo.js";
4: import { _ as O } from "./index-Be0B7rk0.js";
    at getRollupError (file:///project/node_modules/rollup/dist/es/shared/parseAst.js:406:41)
    at error (file:///project/node_modules/rollup/dist/es/shared/parseAst.js:402:42)
    at Module.error (file:///project/node_modules/rollup/dist/es/shared/node-entry.js:17390:16)
    at Module.traceVariable (file:///project/node_modules/rollup/dist/es/shared/node-entry.js:17823:29)
    at ModuleScope.findVariable (file:///project/node_modules/rollup/dist/es/shared/node-entry.js:15413:39)
    at ChildScope.findVariable (file:///project/node_modules/rollup/dist/es/shared/node-entry.js:5682:38)
    at FunctionScope.findVariable (file:///project/node_modules/rollup/dist/es/shared/node-entry.js:5682:38)
    at FunctionBodyScope.findVariable (file:///project/node_modules/rollup/dist/es/shared/node-entry.js:5682:38)
    at ReturnValueScope.findVariable (file:///project/node_modules/rollup/dist/es/shared/node-entry.js:5682:38)
    at FunctionBodyScope.findVariable (file:///project/node_modules/rollup/dist/es/shared/node-entry.js:5682:38)
    at Identifier.bind (file:///project/node_modules/rollup/dist/es/shared/node-entry.js:5449:40)
    at CallExpression.bind (file:///project/node_modules/rollup/dist/es/shared/node-entry.js:2831:23)
    at CallExpression.bind (file:///project/node_modules/rollup/dist/es/shared/node-entry.js:12522:15)
    at LogicalExpression.bind (file:///project/node_modules/rollup/dist/es/shared/node-entry.js:2831:23)
    at VariableDeclarator.bind (file:///project/node_modules/rollup/dist/es/shared/node-entry.js:2831:23)
    at VariableDeclaration.bind (file:///project/node_modules/rollup/dist/es/shared/node-entry.js:2827:28)

安装了@shikijs/core之后才可以,但项目里其实不需要安装shikijs,希望能修复

复现步骤

只安装x-markdown-vue,不安装shikijs,执行build命令

期望行为

不安装shikijs,打包成功

实际行为

只安装x-markdown-vue,打包会报错

组件库版本

2.0.3

环境信息

No response

截图或演示

No response

ydeera avatar May 22 '26 10:05 ydeera

将查看问题

webvs2 avatar May 25 '26 04:05 webvs2

我核对了当前 x-markdown-vue 包:@shikijs/core 在 peerDependenciesMeta 里标成 optional,但发布产物 SyntaxCodeBlock 又有静态 import,所以“不安装就 build 失败”是成立的发布契约问题。它不在 vue-element-plus-x core 源码里,不能在这里假修;先保留,需由 x-markdown-vue 调整条件导入或 peer 声明。

orziz avatar Aug 24 '26 09:08 orziz