vite插件使用tsup打包后引入报错 Error: Dynamic require of "fs" is not supported
参考tsup.config.ts配置
import type { Options } from 'tsup'
export const tsup: Options = {
splitting: false,
sourcemap: false,
clean: true,
format: ['cjs', 'esm'],
dts: true,
entryPoints: [
'src/index.ts'
],
external: [
'vite',
'webpack',
'rollup',
'esbuild',
],
define: {
__DEV__: 'false',
},
bundle: true,
banner: {
js: 'import { createRequire } from \'module\';const require = createRequire(import.meta.url);'
},
platform: "node"
}