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

没有正确导出类型 #272

Closed
3 tasks done
kanocence opened this issue Sep 20, 2023 · 3 comments
Closed
3 tasks done

没有正确导出类型 #272

kanocence opened this issue Sep 20, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@kanocence
Copy link

Describe the bug

项目目录

├─packages
│  └─layout          <------ pnpm build
│    ├─dist
│    ├─src
│    ├─package.json
│    └─vite.config.ts
├─play
├─package.json
├─tsconfig.json
└─vite.config.ts

这是/packages/layout/vite.config的配置

import { resolve } from 'node:path';
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import dts from 'vite-plugin-dts';

export default defineConfig({
  build: {
    outDir: './dist',
    emptyOutDir: true,
    cssCodeSplit: true,
    sourcemap: true,
    lib: {
      formats: ['es'],
      entry: [resolve(__dirname, './src/index.ts')],
    }
  },
  define: { 'process.env.NODE_ENV': '"production"' },
  plugins: [vue(), dts()],
});

似乎是入口文件读取错了,没有生成 index.d.ts 生成了 vite.config.d.ts

image

image

Reproduction

暂无

Steps to reproduce

pnpm up

cd ./packages/layout

pnpm build

System Info

System:
    OS: Windows 10 10.0.22621
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz
    Memory: 1.93 GB / 15.69 GB
  Binaries:
    Node: 16.20.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 8.19.4 - C:\Program Files\nodejs\npm.CMD
    pnpm: 7.32.0 - ~\AppData\Roaming\npm\pnpm.CMD
  Browsers:
    Chrome: 117.0.5938.89
    Edge: Spartan (44.22621.2283.0), Chromium (116.0.1938.81)
    Internet Explorer: 11.0.22621.1

Validations

@qmhc
Copy link
Owner

qmhc commented Sep 20, 2023

请提供一下复现项目。

@kanocence
Copy link
Author

请提供一下复现项目。

https://github.com/kanocence/dts-demo

@qmhc qmhc added the bug Something isn't working label Sep 21, 2023
@qmhc qmhc closed this as completed in a7bab4d Sep 21, 2023
@qmhc
Copy link
Owner

qmhc commented Sep 21, 2023

新版收集文件的逻辑有一些变化,表现上基本是按照 TypeScript 原本的方式去收集(旧版并不是),所以建议你打包的时候最好在打包的 root 目录有 tsconfig.json 并指定好 include,或者直接使用插件选项的 include

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants