"jsx": "react-jsx",我在 tsconfig 文件中使用并使用 Vite/rollup 进行捆绑。由于某种原因,即使 NODE_ENV 设置为生产环境,我的模块始终与react-jsx-runtime.production.min.js和捆绑在一起。react-jsx-runtime.development.js我只希望包含生产代码。
我可以通过'react/jsx-runtime'在汇总选项中设置为 external 来删除这两个选项,但这也不是我想要的产品包。我找不到解释这一点的文档。有谁知道如何阻止捆绑程序包含开发运行时?
vite.config.ts
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
export default defineConfig({
build: {
lib: {
entry: './src/index.tsx',
formats: ['es'],
name: `button`,
fileName: `button`,
},
rollupOptions: {
external: ['react'],
},
},
plugins: [react()],
})
Run Code Online (Sandbox Code Playgroud)
tsconfig.json
{
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"skipLibCheck": true,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext", …Run Code Online (Sandbox Code Playgroud)