Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot work with vite.config.ts #44

Closed
richex-cn opened this issue Jun 7, 2022 · 4 comments
Closed

Cannot work with vite.config.ts #44

richex-cn opened this issue Jun 7, 2022 · 4 comments

Comments

@richex-cn
Copy link
Contributor

richex-cn commented Jun 7, 2022

TS 的定义和实际的 JS 输出不一致,当我在 vite.config.ts 中使用时,只能通过 vitePluginImp.default 配合 @ts-ignore 使用。

Reproduce: https://stackblitz.com/edit/vitejs-vite-wkqurd?file=vite.config.ts

目前我只能这样用:

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vitePluginImp from 'vite-plugin-imp'

export default defineConfig(({ mode }) => {
  const IS_DEV = mode === 'development'

  return {
    plugins: [
      vue(),
      // @ts-ignore: conflicting type define with default export
      vitePluginImp.default({})
    ]
  }
})
@psaren
Copy link
Contributor

psaren commented Jun 7, 2022

你删掉package.json中的type: "module"试试

https://stackblitz.com/edit/vitejs-vite-npecb7?file=package.json

@richex-cn
Copy link
Contributor Author

你删掉package.json中的type: "module"试试

删掉之后可以正常工作了,非常感谢!

考虑到未来会有越来越多项目使用 ESM,是否可以在这个项目中兼容一下?例如 vite 在 3.x 开始已经全面开启 ESM,参考 vitejs/vite#8251

@psaren

@psaren
Copy link
Contributor

psaren commented Jun 7, 2022

下个版本会兼容

@richex-cn
Copy link
Contributor Author

Awesome! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants