fe-stack 0.0.12 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fe-stack",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13",
|
|
4
4
|
"description": "共享的配置文件集合,用于 Vite、Tailwind、Biome、Prettier 和 TypeScript",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
"tsconfig.node.json",
|
|
22
22
|
"vite.config.base.js",
|
|
23
23
|
"vite.config.base.d.ts",
|
|
24
|
-
"vite-plugin-rollup-dts.
|
|
24
|
+
"vite-plugin-rollup-dts.js",
|
|
25
|
+
"vite-plugin-rollup-dts.d.ts",
|
|
25
26
|
"README.md"
|
|
26
27
|
],
|
|
27
28
|
"keywords": [
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 入口配置
|
|
5
|
+
*/
|
|
6
|
+
export interface Entry {
|
|
7
|
+
/** 入口名称 */
|
|
8
|
+
name: string;
|
|
9
|
+
/** 主入口文件路径 */
|
|
10
|
+
mainEntryPoint: string;
|
|
11
|
+
/** 输出文件路径 */
|
|
12
|
+
output: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Rollup DTS 插件选项
|
|
17
|
+
*/
|
|
18
|
+
export interface RollupDtsPluginOptions {
|
|
19
|
+
/** 手动指定入口,如果不指定则从 vite config 的 build.lib.entry 自动获取 */
|
|
20
|
+
entries?: Entry[];
|
|
21
|
+
/** tsconfig.json 文件路径,默认为 './tsconfig.json' */
|
|
22
|
+
tsconfigPath?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* 创建 Vite 插件用于合并 TypeScript 类型声明文件
|
|
27
|
+
* @param options - 插件选项
|
|
28
|
+
* @returns Vite 插件实例
|
|
29
|
+
*/
|
|
30
|
+
export function rollupDtsPlugin(options?: RollupDtsPluginOptions): Plugin;
|
|
31
|
+
|
|
32
|
+
export default rollupDtsPlugin;
|
|
@@ -1,19 +1,6 @@
|
|
|
1
1
|
import * as fs from 'node:fs';
|
|
2
2
|
import * as path from 'node:path';
|
|
3
3
|
import { Extractor, ExtractorConfig } from '@microsoft/api-extractor';
|
|
4
|
-
import type { Plugin, ResolvedConfig } from 'vite';
|
|
5
|
-
|
|
6
|
-
interface Entry {
|
|
7
|
-
name: string;
|
|
8
|
-
mainEntryPoint: string;
|
|
9
|
-
output: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
interface RollupDtsPluginOptions {
|
|
13
|
-
/** 手动指定入口,如果不指定则从 vite config 的 build.lib.entry 自动获取 */
|
|
14
|
-
entries?: Entry[];
|
|
15
|
-
tsconfigPath?: string;
|
|
16
|
-
}
|
|
17
4
|
|
|
18
5
|
const baseConfig = {
|
|
19
6
|
$schema:
|
|
@@ -24,17 +11,17 @@ const baseConfig = {
|
|
|
24
11
|
tsdocMetadata: { enabled: false },
|
|
25
12
|
dtsRollup: { enabled: true },
|
|
26
13
|
messages: {
|
|
27
|
-
compilerMessageReporting: { default: { logLevel: 'warning'
|
|
14
|
+
compilerMessageReporting: { default: { logLevel: 'warning' } },
|
|
28
15
|
extractorMessageReporting: {
|
|
29
|
-
default: { logLevel: 'warning'
|
|
30
|
-
'ae-missing-release-tag': { logLevel: 'none'
|
|
31
|
-
'ae-unresolved-link': { logLevel: 'none'
|
|
16
|
+
default: { logLevel: 'warning' },
|
|
17
|
+
'ae-missing-release-tag': { logLevel: 'none' },
|
|
18
|
+
'ae-unresolved-link': { logLevel: 'none' },
|
|
32
19
|
},
|
|
33
|
-
tsdocMessageReporting: { default: { logLevel: 'none'
|
|
20
|
+
tsdocMessageReporting: { default: { logLevel: 'none' } },
|
|
34
21
|
},
|
|
35
22
|
};
|
|
36
23
|
|
|
37
|
-
function cleanupIntermediateFiles(dir
|
|
24
|
+
function cleanupIntermediateFiles(dir, keepFiles) {
|
|
38
25
|
if (!fs.existsSync(dir)) return;
|
|
39
26
|
|
|
40
27
|
const items = fs.readdirSync(dir, { withFileTypes: true });
|
|
@@ -73,7 +60,7 @@ function cleanupIntermediateFiles(dir: string, keepFiles: string[]) {
|
|
|
73
60
|
/**
|
|
74
61
|
* 从 vite config 的 build.lib.entry 自动生成 entries
|
|
75
62
|
*/
|
|
76
|
-
function getEntriesFromConfig(config
|
|
63
|
+
function getEntriesFromConfig(config) {
|
|
77
64
|
const lib = config.build?.lib;
|
|
78
65
|
if (!lib) return [];
|
|
79
66
|
|
|
@@ -107,10 +94,10 @@ function getEntriesFromConfig(config: ResolvedConfig): Entry[] {
|
|
|
107
94
|
}));
|
|
108
95
|
}
|
|
109
96
|
|
|
110
|
-
export function rollupDtsPlugin(options
|
|
97
|
+
export function rollupDtsPlugin(options = {}) {
|
|
111
98
|
const { tsconfigPath = './tsconfig.json' } = options;
|
|
112
|
-
let resolvedConfig
|
|
113
|
-
let entries
|
|
99
|
+
let resolvedConfig;
|
|
100
|
+
let entries = [];
|
|
114
101
|
|
|
115
102
|
return {
|
|
116
103
|
name: 'vite-plugin-rollup-dts',
|
|
@@ -130,7 +117,7 @@ export function rollupDtsPlugin(options: RollupDtsPluginOptions = {}): Plugin {
|
|
|
130
117
|
}
|
|
131
118
|
|
|
132
119
|
const projectFolder = process.cwd();
|
|
133
|
-
const results
|
|
120
|
+
const results = [];
|
|
134
121
|
|
|
135
122
|
console.log('\n[rollup-dts] Starting to bundle declaration files...');
|
|
136
123
|
|
|
@@ -206,7 +193,7 @@ export function rollupDtsPlugin(options: RollupDtsPluginOptions = {}): Plugin {
|
|
|
206
193
|
}
|
|
207
194
|
|
|
208
195
|
// Determine which directories to keep
|
|
209
|
-
const dirsToKeep = new Set
|
|
196
|
+
const dirsToKeep = new Set();
|
|
210
197
|
|
|
211
198
|
for (const { entry, success } of results) {
|
|
212
199
|
if (!success) {
|