GithubHelp home page GithubHelp logo

Comments (7)

luozhihua avatar luozhihua commented on July 2, 2024 1

同样的问题,我没有设置build.rollupOptions.external,应该不是跟 external 有关,而是因为项目中有 CommonJS 模块, 导致Vite 在源码中插入了 commonjsHelpers.js 虚拟模块以处理 CommonJS 代码, 而commonjsHelpers.js 实际上 不是 一个真实存在的文件,只是一个 Vite 所支持的虚拟模块:https://vitejs.dev/guide/api-plugin.html#importing-a-virtual-file

按照 @chrisxvin 的修改,过滤掉以\0为前缀的文件是可以解决问题的,Vite 的虚拟模块约定是就是以\0开头;

from vite-plugin-dts.

chrisxvin avatar chrisxvin commented on July 2, 2024

emmm....破电脑没法 push 代码,放个 patch 吧🤣

--- plugin.ts	2022-01-05 15:47:52.824843900 +0800
+++ plugin-mod.ts	2022-01-05 15:13:31.864190100 +0800
@@ -188,7 +188,7 @@
 
           project.createSourceFile(`${id}.${ext || 'js'}`, content, { overwrite: true })
         }
-      } else if (!id.includes('.vue?vue') && (tsRE.test(id) || (allowJs && jsRE.test(id)))) {
+      } else if (!id.includes('.vue?vue') && (tsRE.test(id) || (allowJs && jsRE.test(id))) && !id.startsWith('\0')) {
         project.addSourceFileAtPath(id)
       }
 
@@ -242,7 +242,7 @@
             dtsRE.test(file) ? file : `${tjsRE.test(file) ? file.replace(tjsRE, '') : file}.d.ts`
           )
 
-          if (dtsRE.test(file)) {
+          if (dtsRE.test(file) && !file.startsWith('\0')) {
             sourceDtsFiles.add(project.addSourceFileAtPath(file))
           }
         })

from vite-plugin-dts.

qmhc avatar qmhc commented on July 2, 2024

请问你是在什么环境下出现了这个问题?

from vite-plugin-dts.

chrisxvin avatar chrisxvin commented on July 2, 2024

RHEL 7.3
node 16.13

vite 2.7.10
vite-plugin-dts 0.9.7
vue-tsc 0.30.2
vue 3.2.6
devextreme 21.2.4
devextreme-vue 21.2.4
typescript 4.5.4

主要就这些.

from vite-plugin-dts.

qmhc avatar qmhc commented on July 2, 2024

我使用了相同的环境创建了一个简单的项目,无法复现你描述的问题,还是希望你能提供一下可复现的测试仓库。

或者你的项目中是否有一些不同于传统 vite+vue+ts 的项目的用法,如 const xxx = require('xxx')<script> 不指定 lang="ts"

from vite-plugin-dts.

chrisxvin avatar chrisxvin commented on July 2, 2024

好。我稍后整理一个发上来。

from vite-plugin-dts.

chrisxvin avatar chrisxvin commented on July 2, 2024

测试工程:vite-plugin-dts-test.zip
yarn && yarn build

我又实验了一下,vite.config.ts 里面,设置 build.rollupOptions.external 的时候,不同的方式会有不同的结果。
直接给 external 设置数组,会导致报错。如果写个函数处理一下,就不会。我在测试工程里面写出来了。
给 external 设置数组的时候,导致报错的是一个用 TypeScript class 写的组件(/libs/my-data-grid),不是 setup,也不是 defineComponent.

from vite-plugin-dts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.