lisonge / vite-plugin-monkey

A vite plugin server and build your.user.js for userscript engine like Tampermonkey, Violentmonkey, Greasemonkey, ScriptCat

Repository from Github https://github.comlisonge/vite-plugin-monkeyRepository from Github https://github.comlisonge/vite-plugin-monkey

(await import("json-to-ts")).default 打包报错

wencaizhang opened this issue · comments

开发环境正常运行,但是打包会报错
image

我把 (await import("json-to-ts")).default 部分代码注释掉,就能打包成功了。

我找到了官方提供的示例:https://github.com/lisonge/vite-plugin-monkey/blob/main/playground/dynamic-import/src/main.ts
但是其中的 md5 文件是通过 externalGlobals 引入的,而我这里是通过 pnpm 安装的,略有不同。

       externalGlobals: {
          md5: cdn.jsdelivr('MD5', 'dist/md5.min.js'),
       },

请问我该怎么写呢?

import jsonTots from 'json-to-ts'
import jsonTots from 'json-to-ts'

成了,竟然可以直接引入 cjs 啊,我还在各种找方案 😂