Comments (7)
同样的问题,我没有设置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.
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.
请问你是在什么环境下出现了这个问题?
from vite-plugin-dts.
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.
我使用了相同的环境创建了一个简单的项目,无法复现你描述的问题,还是希望你能提供一下可复现的测试仓库。
或者你的项目中是否有一些不同于传统 vite+vue+ts 的项目的用法,如 const xxx = require('xxx')
,<script>
不指定 lang="ts"
等
from vite-plugin-dts.
好。我稍后整理一个发上来。
from vite-plugin-dts.
测试工程: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)
- Errors being swallowed when `rollupTypes: true` HOT 2
- 【Regression】Library which use IterableIterator.entries() cause TS Error. HOT 2
- 升级 language-tools 到 2.0 HOT 1
- Wrong definition generations since 3.8.2 for
- feat: Add a way to get the TypeScript program instance
- 打包一个库的时候,defineProps问题 HOT 1
- 3.8.0+ Cannot build while excluding vite-env.d.ts
- Invalid imports in generated d.ts for project with tsconfig path alias defined for any module
- 【功能请求】希望可以增加一个像rollup一样可以自定义输出目录层级的功能 HOT 2
- Cannot find name'DefineComponent'
- [docs] The parameter explanation for the afterBuild option in README.md is incorrect.
- Keep comments of the variable in d.ts HOT 3
- Trigger declaration generation in vite build watch mode when non-ts file changes
- bug: tsconfig.json's "files" option is ignored HOT 1
- build fails when using yarn 4 with pnp and rollupTypes: true HOT 1
- All typescript errors are being swallowed HOT 1
- TS-Errors when building with Vite `v5.3.1` HOT 1
- DTS not compatible with latest React Vite tsconfig structure HOT 9
- `"type": "module"` with `rollupTypes: true` results in error HOT 1
- Feature: Support ${configDir} template variable in tsconfig.json (added in typescript 5.5)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vite-plugin-dts.