vite-plugin-dts 4.0.0-beta.0 → 4.0.0-beta.2
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/README.md +8 -0
- package/README.zh-CN.md +8 -0
- package/dist/index.cjs +78 -29
- package/dist/index.mjs +79 -30
- package/package.json +23 -21
package/README.md
CHANGED
|
@@ -84,6 +84,14 @@ For example: `baseUrl: 'src'` is specified and importing from `<root>/src/compon
|
|
|
84
84
|
|
|
85
85
|
Currently, you need to avoid the above situation, or use aliases instead (with the `paths` option).
|
|
86
86
|
|
|
87
|
+
### Get module not found errors during build
|
|
88
|
+
|
|
89
|
+
This is likely due to incorrect configuration of the `include` property in your default `tsconfig.json`.
|
|
90
|
+
|
|
91
|
+
Due to some limitations, the plugin relies on the top-level `tsconfig.json` to resolve the files to include. Therefore, you need to specify the correct `include` property in the top-level `tsconfig.json`, or you can specify a configuration file path with the correct `include` property using the `tsconfigPath` option of the plugin. For example, in the Vite initial template, it is `tsconfig.app.json`.
|
|
92
|
+
|
|
93
|
+
You can refer to this [comment](https://github.com/qmhc/vite-plugin-dts/issues/343#issuecomment-2198111439).
|
|
94
|
+
|
|
87
95
|
<details>
|
|
88
96
|
<summary>Legacy</summary>
|
|
89
97
|
|
package/README.zh-CN.md
CHANGED
|
@@ -84,6 +84,14 @@ export default defineConfig({
|
|
|
84
84
|
|
|
85
85
|
目前想要正常打包,需要规避上述情况,或使用别名代替(配合 `paths` 属性)。
|
|
86
86
|
|
|
87
|
+
### 打包时出现找不到模块的错误
|
|
88
|
+
|
|
89
|
+
这很有可能是因为在你的默认 `tsconfig.json` 中未有正确配置 `include` 导致的。
|
|
90
|
+
|
|
91
|
+
由于一些局限性,插件依赖最上层的 `tsconfig.json` 来解析需要包含的文件,所以你需要在最上层的 `tsconfig.json` 中指定正确的 `include`,或者通过插件的 `tsconfigPath` 选项指定一个包含了正确 `include` 的配置文件路径,例如在 Vite 初始模板中它是 `tsconfig.app.json`。
|
|
92
|
+
|
|
93
|
+
可以参考这个 [评论](https://github.com/qmhc/vite-plugin-dts/issues/343#issuecomment-2198111439).
|
|
94
|
+
|
|
87
95
|
<details>
|
|
88
96
|
<summary>过时的</summary>
|
|
89
97
|
|
package/dist/index.cjs
CHANGED
|
@@ -9,11 +9,13 @@ const node_os = require('node:os');
|
|
|
9
9
|
const languageCore = require('@vue/language-core');
|
|
10
10
|
const typescript = require('@volar/typescript');
|
|
11
11
|
const ts = require('typescript');
|
|
12
|
-
const pluginutils = require('@rollup/pluginutils');
|
|
13
12
|
const vueTsc = require('vue-tsc');
|
|
13
|
+
const pluginutils = require('@rollup/pluginutils');
|
|
14
14
|
const debug = require('debug');
|
|
15
15
|
const kolorist = require('kolorist');
|
|
16
16
|
const apiExtractor = require('@microsoft/api-extractor');
|
|
17
|
+
const localPkg = require('local-pkg');
|
|
18
|
+
const compareVersions = require('compare-versions');
|
|
17
19
|
const MagicString = require('magic-string');
|
|
18
20
|
|
|
19
21
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
@@ -22,6 +24,29 @@ const ts__default = /*#__PURE__*/_interopDefaultCompat(ts);
|
|
|
22
24
|
const debug__default = /*#__PURE__*/_interopDefaultCompat(debug);
|
|
23
25
|
const MagicString__default = /*#__PURE__*/_interopDefaultCompat(MagicString);
|
|
24
26
|
|
|
27
|
+
const createProgram = typescript.proxyCreateProgram(ts__default, ts__default.createProgram, (ts2, options) => {
|
|
28
|
+
const { configFilePath } = options.options;
|
|
29
|
+
const vueOptions = typeof configFilePath === "string" ? languageCore.createParsedCommandLine(ts2, ts2.sys, configFilePath.replace(/\\/g, "/")).vueOptions : languageCore.resolveVueCompilerOptions({});
|
|
30
|
+
if (options.host) {
|
|
31
|
+
const writeFile = options.host.writeFile.bind(options.host);
|
|
32
|
+
options.host.writeFile = (fileName, contents, ...args) => {
|
|
33
|
+
return writeFile(fileName, vueTsc.removeEmitGlobalTypes(contents), ...args);
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
const vueLanguagePlugin = languageCore.createVueLanguagePlugin2(
|
|
37
|
+
ts2,
|
|
38
|
+
(id) => id,
|
|
39
|
+
languageCore.createRootFileChecker(
|
|
40
|
+
void 0,
|
|
41
|
+
() => options.rootNames.map((rootName) => rootName.replace(/\\/g, "/")),
|
|
42
|
+
options.host?.useCaseSensitiveFileNames?.() ?? false
|
|
43
|
+
),
|
|
44
|
+
options.options,
|
|
45
|
+
vueOptions
|
|
46
|
+
);
|
|
47
|
+
return [vueLanguagePlugin];
|
|
48
|
+
});
|
|
49
|
+
|
|
25
50
|
const windowsSlashRE = /\\+/g;
|
|
26
51
|
function slash(p) {
|
|
27
52
|
return p.replace(windowsSlashRE, "/");
|
|
@@ -363,6 +388,17 @@ export default _default;
|
|
|
363
388
|
}
|
|
364
389
|
|
|
365
390
|
const svelteRE = /\.svelte$/;
|
|
391
|
+
let lowerVersion;
|
|
392
|
+
function querySvelteVersion() {
|
|
393
|
+
if (typeof lowerVersion === "boolean")
|
|
394
|
+
return;
|
|
395
|
+
try {
|
|
396
|
+
const version = localPkg.getPackageInfoSync("svelte")?.version ?? localPkg.getPackageInfoSync("svelte", { paths: [localPkg.resolveModule("svelte") || process.cwd()] })?.version;
|
|
397
|
+
lowerVersion = version ? compareVersions.compare(version, "4.0.0", "<") : false;
|
|
398
|
+
} catch {
|
|
399
|
+
lowerVersion = false;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
366
402
|
function SvelteResolver() {
|
|
367
403
|
return {
|
|
368
404
|
name: "svelte",
|
|
@@ -370,10 +406,12 @@ function SvelteResolver() {
|
|
|
370
406
|
return svelteRE.test(id);
|
|
371
407
|
},
|
|
372
408
|
transform({ id, root }) {
|
|
409
|
+
querySvelteVersion();
|
|
373
410
|
return [
|
|
374
411
|
{
|
|
375
412
|
path: node_path.relative(root, `${id}.d.ts`),
|
|
376
|
-
content:
|
|
413
|
+
content: `export { ${lowerVersion ? "SvelteComponentTyped" : "SvelteComponent"} as default } from 'svelte';
|
|
414
|
+
`
|
|
377
415
|
}
|
|
378
416
|
];
|
|
379
417
|
}
|
|
@@ -550,7 +588,7 @@ function transformCode(options) {
|
|
|
550
588
|
return false;
|
|
551
589
|
}
|
|
552
590
|
if (ts__default.isModuleDeclaration(node)) {
|
|
553
|
-
if (node.body && ts__default.isModuleBlock(node.body) && !node.body.statements.some(
|
|
591
|
+
if (node.modifiers?.[0] && node.modifiers[0].kind === ts__default.SyntaxKind.DeclareKeyword && node.body && ts__default.isModuleBlock(node.body) && !node.body.statements.some(
|
|
554
592
|
(s2) => ts__default.isExportAssignment(s2) || ts__default.isExportDeclaration(s2) || ts__default.isImportDeclaration(s2)
|
|
555
593
|
)) {
|
|
556
594
|
declareModules.push(s.slice(node.pos, node.end + 1));
|
|
@@ -569,6 +607,29 @@ function transformCode(options) {
|
|
|
569
607
|
declareModules
|
|
570
608
|
};
|
|
571
609
|
}
|
|
610
|
+
function hasNamedExport(content) {
|
|
611
|
+
const ast = ts__default.createSourceFile("a.ts", content, ts__default.ScriptTarget.Latest);
|
|
612
|
+
let has = false;
|
|
613
|
+
walkSourceFile(ast, (node) => {
|
|
614
|
+
if (ts__default.isExportDeclaration(node) && node.exportClause && ts__default.isNamedExports(node.exportClause)) {
|
|
615
|
+
for (const element of node.exportClause.elements) {
|
|
616
|
+
if (element.name.escapedText !== "default") {
|
|
617
|
+
has = true;
|
|
618
|
+
break;
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
} else if ("modifiers" in node && Array.isArray(node.modifiers) && node.modifiers.length > 1) {
|
|
622
|
+
for (let i = 0, len = node.modifiers.length; i < len; ++i) {
|
|
623
|
+
if (node.modifiers[i].kind === ts__default.SyntaxKind.ExportKeyword && node.modifiers[i + 1]?.kind !== ts__default.SyntaxKind.DefaultKeyword) {
|
|
624
|
+
has = true;
|
|
625
|
+
break;
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
return false;
|
|
630
|
+
});
|
|
631
|
+
return has;
|
|
632
|
+
}
|
|
572
633
|
function hasExportDefault(content) {
|
|
573
634
|
const ast = ts__default.createSourceFile("a.ts", content, ts__default.ScriptTarget.Latest);
|
|
574
635
|
let has = false;
|
|
@@ -595,26 +656,6 @@ function hasExportDefault(content) {
|
|
|
595
656
|
return has;
|
|
596
657
|
}
|
|
597
658
|
|
|
598
|
-
const createProgram = typescript.proxyCreateProgram(ts__default, ts__default.createProgram, (ts2, options) => {
|
|
599
|
-
const { configFilePath } = options.options;
|
|
600
|
-
const vueOptions = typeof configFilePath === "string" ? languageCore.createParsedCommandLine(ts2, ts2.sys, configFilePath.replace(/\\/g, "/")).vueOptions : languageCore.resolveVueCompilerOptions({});
|
|
601
|
-
if (options.host) {
|
|
602
|
-
const writeFile2 = options.host.writeFile.bind(options.host);
|
|
603
|
-
options.host.writeFile = (fileName, contents, ...args) => {
|
|
604
|
-
return writeFile2(fileName, vueTsc.removeEmitGlobalTypes(contents), ...args);
|
|
605
|
-
};
|
|
606
|
-
}
|
|
607
|
-
const vueLanguagePlugin = languageCore.createVueLanguagePlugin(
|
|
608
|
-
ts2,
|
|
609
|
-
(id) => id,
|
|
610
|
-
options.host?.useCaseSensitiveFileNames?.() ?? false,
|
|
611
|
-
() => "",
|
|
612
|
-
() => options.rootNames.map((rootName) => rootName.replace(/\\/g, "/")),
|
|
613
|
-
options.options,
|
|
614
|
-
vueOptions
|
|
615
|
-
);
|
|
616
|
-
return [vueLanguagePlugin];
|
|
617
|
-
});
|
|
618
659
|
const jsRE = /\.(m|c)?jsx?$/;
|
|
619
660
|
const tsRE = /\.(m|c)?tsx?$/;
|
|
620
661
|
const dtsRE = /\.d\.(m|c)?tsx?$/;
|
|
@@ -817,7 +858,11 @@ ${logPrefix} ${kolorist.yellow(
|
|
|
817
858
|
(glob) => normalizeGlob(ensureAbsolute(glob, configPath ? node_path.dirname(configPath) : root))
|
|
818
859
|
);
|
|
819
860
|
};
|
|
820
|
-
include = computeGlobs(
|
|
861
|
+
include = computeGlobs(
|
|
862
|
+
options.include,
|
|
863
|
+
[...ensureArray(content?.raw.include ?? []), ...ensureArray(content?.raw.files ?? [])],
|
|
864
|
+
"**/*"
|
|
865
|
+
);
|
|
821
866
|
exclude = computeGlobs(options.exclude, content?.raw.exclude, "node_modules/**");
|
|
822
867
|
filter = pluginutils.createFilter(include, exclude);
|
|
823
868
|
const rootNames = [
|
|
@@ -1055,12 +1100,17 @@ ${logPrefix} ${kolorist.yellow(
|
|
|
1055
1100
|
let fromPath = normalizePath(node_path.relative(node_path.dirname(entryDtsPath), sourceEntry));
|
|
1056
1101
|
fromPath = fromPath.replace(dtsRE, "");
|
|
1057
1102
|
fromPath = fullRelativeRE.test(fromPath) ? fromPath : `./${fromPath}`;
|
|
1058
|
-
let content =
|
|
1103
|
+
let content = "";
|
|
1104
|
+
if (emittedFiles.has(sourceEntry)) {
|
|
1105
|
+
if (hasNamedExport(emittedFiles.get(sourceEntry))) {
|
|
1106
|
+
content += `export * from '${fromPath}'
|
|
1059
1107
|
`;
|
|
1060
|
-
|
|
1061
|
-
|
|
1108
|
+
}
|
|
1109
|
+
if (hasExportDefault(emittedFiles.get(sourceEntry))) {
|
|
1110
|
+
content += `import ${libName} from '${fromPath}'
|
|
1062
1111
|
export default ${libName}
|
|
1063
1112
|
`;
|
|
1113
|
+
}
|
|
1064
1114
|
}
|
|
1065
1115
|
await writeOutput(cleanPath(entryDtsPath), content, outDir);
|
|
1066
1116
|
}
|
|
@@ -1111,8 +1161,7 @@ export default ${libName}
|
|
|
1111
1161
|
await writeOutput(
|
|
1112
1162
|
filePath,
|
|
1113
1163
|
await promises.readFile(filePath, "utf-8") + (declared ? `
|
|
1114
|
-
${declared}
|
|
1115
|
-
` : ""),
|
|
1164
|
+
${declared}` : ""),
|
|
1116
1165
|
node_path.dirname(filePath)
|
|
1117
1166
|
);
|
|
1118
1167
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -9,16 +9,41 @@ import { relative, posix, resolve as resolve$1, isAbsolute, dirname, normalize,
|
|
|
9
9
|
import { existsSync, readdirSync, lstatSync, rmdirSync } from 'node:fs';
|
|
10
10
|
import { readFile, mkdir, writeFile, unlink } from 'node:fs/promises';
|
|
11
11
|
import { cpus } from 'node:os';
|
|
12
|
-
import { createParsedCommandLine, resolveVueCompilerOptions,
|
|
12
|
+
import { createParsedCommandLine, resolveVueCompilerOptions, createVueLanguagePlugin2, createRootFileChecker } from '@vue/language-core';
|
|
13
13
|
import { proxyCreateProgram } from '@volar/typescript';
|
|
14
14
|
import ts from 'typescript';
|
|
15
|
-
import { createFilter } from '@rollup/pluginutils';
|
|
16
15
|
import { removeEmitGlobalTypes } from 'vue-tsc';
|
|
16
|
+
import { createFilter } from '@rollup/pluginutils';
|
|
17
17
|
import debug from 'debug';
|
|
18
18
|
import { cyan, yellow, green } from 'kolorist';
|
|
19
19
|
import { ExtractorConfig, Extractor } from '@microsoft/api-extractor';
|
|
20
|
+
import { getPackageInfoSync, resolveModule } from 'local-pkg';
|
|
21
|
+
import { compare } from 'compare-versions';
|
|
20
22
|
import MagicString from 'magic-string';
|
|
21
23
|
|
|
24
|
+
const createProgram = proxyCreateProgram(ts, ts.createProgram, (ts2, options) => {
|
|
25
|
+
const { configFilePath } = options.options;
|
|
26
|
+
const vueOptions = typeof configFilePath === "string" ? createParsedCommandLine(ts2, ts2.sys, configFilePath.replace(/\\/g, "/")).vueOptions : resolveVueCompilerOptions({});
|
|
27
|
+
if (options.host) {
|
|
28
|
+
const writeFile = options.host.writeFile.bind(options.host);
|
|
29
|
+
options.host.writeFile = (fileName, contents, ...args) => {
|
|
30
|
+
return writeFile(fileName, removeEmitGlobalTypes(contents), ...args);
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
const vueLanguagePlugin = createVueLanguagePlugin2(
|
|
34
|
+
ts2,
|
|
35
|
+
(id) => id,
|
|
36
|
+
createRootFileChecker(
|
|
37
|
+
void 0,
|
|
38
|
+
() => options.rootNames.map((rootName) => rootName.replace(/\\/g, "/")),
|
|
39
|
+
options.host?.useCaseSensitiveFileNames?.() ?? false
|
|
40
|
+
),
|
|
41
|
+
options.options,
|
|
42
|
+
vueOptions
|
|
43
|
+
);
|
|
44
|
+
return [vueLanguagePlugin];
|
|
45
|
+
});
|
|
46
|
+
|
|
22
47
|
const windowsSlashRE = /\\+/g;
|
|
23
48
|
function slash(p) {
|
|
24
49
|
return p.replace(windowsSlashRE, "/");
|
|
@@ -360,6 +385,17 @@ export default _default;
|
|
|
360
385
|
}
|
|
361
386
|
|
|
362
387
|
const svelteRE = /\.svelte$/;
|
|
388
|
+
let lowerVersion;
|
|
389
|
+
function querySvelteVersion() {
|
|
390
|
+
if (typeof lowerVersion === "boolean")
|
|
391
|
+
return;
|
|
392
|
+
try {
|
|
393
|
+
const version = getPackageInfoSync("svelte")?.version ?? getPackageInfoSync("svelte", { paths: [resolveModule("svelte") || process.cwd()] })?.version;
|
|
394
|
+
lowerVersion = version ? compare(version, "4.0.0", "<") : false;
|
|
395
|
+
} catch {
|
|
396
|
+
lowerVersion = false;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
363
399
|
function SvelteResolver() {
|
|
364
400
|
return {
|
|
365
401
|
name: "svelte",
|
|
@@ -367,10 +403,12 @@ function SvelteResolver() {
|
|
|
367
403
|
return svelteRE.test(id);
|
|
368
404
|
},
|
|
369
405
|
transform({ id, root }) {
|
|
406
|
+
querySvelteVersion();
|
|
370
407
|
return [
|
|
371
408
|
{
|
|
372
409
|
path: relative(root, `${id}.d.ts`),
|
|
373
|
-
content:
|
|
410
|
+
content: `export { ${lowerVersion ? "SvelteComponentTyped" : "SvelteComponent"} as default } from 'svelte';
|
|
411
|
+
`
|
|
374
412
|
}
|
|
375
413
|
];
|
|
376
414
|
}
|
|
@@ -547,7 +585,7 @@ function transformCode(options) {
|
|
|
547
585
|
return false;
|
|
548
586
|
}
|
|
549
587
|
if (ts.isModuleDeclaration(node)) {
|
|
550
|
-
if (node.body && ts.isModuleBlock(node.body) && !node.body.statements.some(
|
|
588
|
+
if (node.modifiers?.[0] && node.modifiers[0].kind === ts.SyntaxKind.DeclareKeyword && node.body && ts.isModuleBlock(node.body) && !node.body.statements.some(
|
|
551
589
|
(s2) => ts.isExportAssignment(s2) || ts.isExportDeclaration(s2) || ts.isImportDeclaration(s2)
|
|
552
590
|
)) {
|
|
553
591
|
declareModules.push(s.slice(node.pos, node.end + 1));
|
|
@@ -566,6 +604,29 @@ function transformCode(options) {
|
|
|
566
604
|
declareModules
|
|
567
605
|
};
|
|
568
606
|
}
|
|
607
|
+
function hasNamedExport(content) {
|
|
608
|
+
const ast = ts.createSourceFile("a.ts", content, ts.ScriptTarget.Latest);
|
|
609
|
+
let has = false;
|
|
610
|
+
walkSourceFile(ast, (node) => {
|
|
611
|
+
if (ts.isExportDeclaration(node) && node.exportClause && ts.isNamedExports(node.exportClause)) {
|
|
612
|
+
for (const element of node.exportClause.elements) {
|
|
613
|
+
if (element.name.escapedText !== "default") {
|
|
614
|
+
has = true;
|
|
615
|
+
break;
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
} else if ("modifiers" in node && Array.isArray(node.modifiers) && node.modifiers.length > 1) {
|
|
619
|
+
for (let i = 0, len = node.modifiers.length; i < len; ++i) {
|
|
620
|
+
if (node.modifiers[i].kind === ts.SyntaxKind.ExportKeyword && node.modifiers[i + 1]?.kind !== ts.SyntaxKind.DefaultKeyword) {
|
|
621
|
+
has = true;
|
|
622
|
+
break;
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
return false;
|
|
627
|
+
});
|
|
628
|
+
return has;
|
|
629
|
+
}
|
|
569
630
|
function hasExportDefault(content) {
|
|
570
631
|
const ast = ts.createSourceFile("a.ts", content, ts.ScriptTarget.Latest);
|
|
571
632
|
let has = false;
|
|
@@ -592,26 +653,6 @@ function hasExportDefault(content) {
|
|
|
592
653
|
return has;
|
|
593
654
|
}
|
|
594
655
|
|
|
595
|
-
const createProgram = proxyCreateProgram(ts, ts.createProgram, (ts2, options) => {
|
|
596
|
-
const { configFilePath } = options.options;
|
|
597
|
-
const vueOptions = typeof configFilePath === "string" ? createParsedCommandLine(ts2, ts2.sys, configFilePath.replace(/\\/g, "/")).vueOptions : resolveVueCompilerOptions({});
|
|
598
|
-
if (options.host) {
|
|
599
|
-
const writeFile2 = options.host.writeFile.bind(options.host);
|
|
600
|
-
options.host.writeFile = (fileName, contents, ...args) => {
|
|
601
|
-
return writeFile2(fileName, removeEmitGlobalTypes(contents), ...args);
|
|
602
|
-
};
|
|
603
|
-
}
|
|
604
|
-
const vueLanguagePlugin = createVueLanguagePlugin(
|
|
605
|
-
ts2,
|
|
606
|
-
(id) => id,
|
|
607
|
-
options.host?.useCaseSensitiveFileNames?.() ?? false,
|
|
608
|
-
() => "",
|
|
609
|
-
() => options.rootNames.map((rootName) => rootName.replace(/\\/g, "/")),
|
|
610
|
-
options.options,
|
|
611
|
-
vueOptions
|
|
612
|
-
);
|
|
613
|
-
return [vueLanguagePlugin];
|
|
614
|
-
});
|
|
615
656
|
const jsRE = /\.(m|c)?jsx?$/;
|
|
616
657
|
const tsRE = /\.(m|c)?tsx?$/;
|
|
617
658
|
const dtsRE = /\.d\.(m|c)?tsx?$/;
|
|
@@ -814,7 +855,11 @@ ${logPrefix} ${yellow(
|
|
|
814
855
|
(glob) => normalizeGlob(ensureAbsolute(glob, configPath ? dirname(configPath) : root))
|
|
815
856
|
);
|
|
816
857
|
};
|
|
817
|
-
include = computeGlobs(
|
|
858
|
+
include = computeGlobs(
|
|
859
|
+
options.include,
|
|
860
|
+
[...ensureArray(content?.raw.include ?? []), ...ensureArray(content?.raw.files ?? [])],
|
|
861
|
+
"**/*"
|
|
862
|
+
);
|
|
818
863
|
exclude = computeGlobs(options.exclude, content?.raw.exclude, "node_modules/**");
|
|
819
864
|
filter = createFilter(include, exclude);
|
|
820
865
|
const rootNames = [
|
|
@@ -1052,12 +1097,17 @@ ${logPrefix} ${yellow(
|
|
|
1052
1097
|
let fromPath = normalizePath(relative(dirname(entryDtsPath), sourceEntry));
|
|
1053
1098
|
fromPath = fromPath.replace(dtsRE, "");
|
|
1054
1099
|
fromPath = fullRelativeRE.test(fromPath) ? fromPath : `./${fromPath}`;
|
|
1055
|
-
let content =
|
|
1100
|
+
let content = "";
|
|
1101
|
+
if (emittedFiles.has(sourceEntry)) {
|
|
1102
|
+
if (hasNamedExport(emittedFiles.get(sourceEntry))) {
|
|
1103
|
+
content += `export * from '${fromPath}'
|
|
1056
1104
|
`;
|
|
1057
|
-
|
|
1058
|
-
|
|
1105
|
+
}
|
|
1106
|
+
if (hasExportDefault(emittedFiles.get(sourceEntry))) {
|
|
1107
|
+
content += `import ${libName} from '${fromPath}'
|
|
1059
1108
|
export default ${libName}
|
|
1060
1109
|
`;
|
|
1110
|
+
}
|
|
1061
1111
|
}
|
|
1062
1112
|
await writeOutput(cleanPath(entryDtsPath), content, outDir);
|
|
1063
1113
|
}
|
|
@@ -1108,8 +1158,7 @@ export default ${libName}
|
|
|
1108
1158
|
await writeOutput(
|
|
1109
1159
|
filePath,
|
|
1110
1160
|
await readFile(filePath, "utf-8") + (declared ? `
|
|
1111
|
-
${declared}
|
|
1112
|
-
` : ""),
|
|
1161
|
+
${declared}` : ""),
|
|
1113
1162
|
dirname(filePath)
|
|
1114
1163
|
);
|
|
1115
1164
|
});
|
package/package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-dts",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.2",
|
|
4
4
|
"type": "module",
|
|
5
|
+
"packageManager": "pnpm@8.3.0",
|
|
5
6
|
"license": "MIT",
|
|
6
7
|
"author": "qmhc",
|
|
7
|
-
"packageManager": "pnpm@8.3.0",
|
|
8
8
|
"scripts": {
|
|
9
9
|
"build": "tsx scripts/build.ts",
|
|
10
10
|
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s --commit-path .",
|
|
11
11
|
"dev": "unbuild --stub",
|
|
12
|
-
"lint": "eslint --ext .js,.jsx,.ts,.tsx \"{src,tests}/**\"",
|
|
13
12
|
"_postinstall": "is-ci || husky install",
|
|
14
|
-
"
|
|
13
|
+
"lint": "eslint --ext .js,.jsx,.ts,.tsx \"{src,tests}/**\"",
|
|
15
14
|
"precommit": "lint-staged -c ./.husky/.lintstagedrc -q",
|
|
16
15
|
"prepublishOnly": "pinst --disable",
|
|
17
16
|
"prettier": "pretty-quick --staged && pnpm run lint",
|
|
17
|
+
"postpublish": "pinst --enable",
|
|
18
18
|
"release": "tsx scripts/release.ts",
|
|
19
19
|
"test": "vitest run",
|
|
20
20
|
"test:dev": "vitest",
|
|
@@ -39,13 +39,6 @@
|
|
|
39
39
|
"engines": {
|
|
40
40
|
"node": "^14.18.0 || >=16.0.0"
|
|
41
41
|
},
|
|
42
|
-
"repository": {
|
|
43
|
-
"type": "git",
|
|
44
|
-
"url": "git+https://github.com/qmhc/vite-plugin-dts.git"
|
|
45
|
-
},
|
|
46
|
-
"bugs": {
|
|
47
|
-
"url": "https://github.com/qmhc/vite-plugin-dts/issues"
|
|
48
|
-
},
|
|
49
42
|
"keywords": [
|
|
50
43
|
"vite",
|
|
51
44
|
"vite-plugin",
|
|
@@ -57,15 +50,24 @@
|
|
|
57
50
|
"vue-tsc",
|
|
58
51
|
"volar"
|
|
59
52
|
],
|
|
53
|
+
"repository": {
|
|
54
|
+
"type": "git",
|
|
55
|
+
"url": "git+https://github.com/qmhc/vite-plugin-dts.git"
|
|
56
|
+
},
|
|
57
|
+
"bugs": {
|
|
58
|
+
"url": "https://github.com/qmhc/vite-plugin-dts/issues"
|
|
59
|
+
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@microsoft/api-extractor": "7.47.
|
|
61
|
+
"@microsoft/api-extractor": "7.47.4",
|
|
62
62
|
"@rollup/pluginutils": "^5.1.0",
|
|
63
63
|
"@volar/typescript": "^2.3.4",
|
|
64
|
-
"@vue/language-core": "2.0.
|
|
65
|
-
"
|
|
64
|
+
"@vue/language-core": "2.0.29",
|
|
65
|
+
"compare-versions": "^6.1.1",
|
|
66
|
+
"debug": "^4.3.6",
|
|
66
67
|
"kolorist": "^1.8.0",
|
|
67
|
-
"
|
|
68
|
-
"
|
|
68
|
+
"local-pkg": "^0.5.0",
|
|
69
|
+
"magic-string": "^0.30.11",
|
|
70
|
+
"vue-tsc": "2.0.29"
|
|
69
71
|
},
|
|
70
72
|
"devDependencies": {
|
|
71
73
|
"@commitlint/cli": "^19.3.0",
|
|
@@ -76,7 +78,7 @@
|
|
|
76
78
|
"@types/semver": "^7.5.8",
|
|
77
79
|
"@vexip-ui/commitlint-config": "^0.5.0",
|
|
78
80
|
"@vexip-ui/eslint-config": "^0.12.1",
|
|
79
|
-
"@vexip-ui/prettier-config": "^0.
|
|
81
|
+
"@vexip-ui/prettier-config": "^1.0.0",
|
|
80
82
|
"@vue/eslint-config-standard": "^8.0.1",
|
|
81
83
|
"@vue/eslint-config-typescript": "^13.0.0",
|
|
82
84
|
"conventional-changelog-cli": "^5.0.0",
|
|
@@ -93,10 +95,10 @@
|
|
|
93
95
|
"rimraf": "^6.0.1",
|
|
94
96
|
"semver": "^7.6.3",
|
|
95
97
|
"tsx": "^4.16.2",
|
|
96
|
-
"typescript": "5.5.
|
|
98
|
+
"typescript": "5.5.4",
|
|
97
99
|
"unbuild": "^2.0.0",
|
|
98
|
-
"vite": "^5.3.
|
|
99
|
-
"vitest": "^2.0.
|
|
100
|
+
"vite": "^5.3.5",
|
|
101
|
+
"vitest": "^2.0.4"
|
|
100
102
|
},
|
|
101
103
|
"peerDependencies": {
|
|
102
104
|
"typescript": "*",
|
|
@@ -109,7 +111,7 @@
|
|
|
109
111
|
},
|
|
110
112
|
"pnpm": {
|
|
111
113
|
"patchedDependencies": {
|
|
112
|
-
"@microsoft/api-extractor@7.47.
|
|
114
|
+
"@microsoft/api-extractor@7.47.4": "patches/@microsoft__api-extractor@7.47.4.patch"
|
|
113
115
|
}
|
|
114
116
|
}
|
|
115
117
|
}
|