vite-plugin-dts 4.0.0-beta.0 → 4.0.0-beta.1
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 +21 -2
- package/dist/index.mjs +21 -2
- package/package.json +3 -1
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
|
@@ -14,6 +14,8 @@ const vueTsc = require('vue-tsc');
|
|
|
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; }
|
|
@@ -363,6 +365,17 @@ export default _default;
|
|
|
363
365
|
}
|
|
364
366
|
|
|
365
367
|
const svelteRE = /\.svelte$/;
|
|
368
|
+
let lowerVersion;
|
|
369
|
+
function querySvelteVersion() {
|
|
370
|
+
if (typeof lowerVersion === "boolean")
|
|
371
|
+
return;
|
|
372
|
+
try {
|
|
373
|
+
const version = localPkg.getPackageInfoSync("svelte")?.version ?? localPkg.getPackageInfoSync("svelte", { paths: [localPkg.resolveModule("svelte") || process.cwd()] })?.version;
|
|
374
|
+
lowerVersion = version ? compareVersions.compare(version, "4.0.0", "<") : false;
|
|
375
|
+
} catch {
|
|
376
|
+
lowerVersion = false;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
366
379
|
function SvelteResolver() {
|
|
367
380
|
return {
|
|
368
381
|
name: "svelte",
|
|
@@ -370,10 +383,12 @@ function SvelteResolver() {
|
|
|
370
383
|
return svelteRE.test(id);
|
|
371
384
|
},
|
|
372
385
|
transform({ id, root }) {
|
|
386
|
+
querySvelteVersion();
|
|
373
387
|
return [
|
|
374
388
|
{
|
|
375
389
|
path: node_path.relative(root, `${id}.d.ts`),
|
|
376
|
-
content:
|
|
390
|
+
content: `export { ${lowerVersion ? "SvelteComponentTyped" : "SvelteComponent"} as default } from 'svelte';
|
|
391
|
+
`
|
|
377
392
|
}
|
|
378
393
|
];
|
|
379
394
|
}
|
|
@@ -817,7 +832,11 @@ ${logPrefix} ${kolorist.yellow(
|
|
|
817
832
|
(glob) => normalizeGlob(ensureAbsolute(glob, configPath ? node_path.dirname(configPath) : root))
|
|
818
833
|
);
|
|
819
834
|
};
|
|
820
|
-
include = computeGlobs(
|
|
835
|
+
include = computeGlobs(
|
|
836
|
+
options.include,
|
|
837
|
+
[...ensureArray(content?.raw.include ?? []), ...ensureArray(content?.raw.files ?? [])],
|
|
838
|
+
"**/*"
|
|
839
|
+
);
|
|
821
840
|
exclude = computeGlobs(options.exclude, content?.raw.exclude, "node_modules/**");
|
|
822
841
|
filter = pluginutils.createFilter(include, exclude);
|
|
823
842
|
const rootNames = [
|
package/dist/index.mjs
CHANGED
|
@@ -17,6 +17,8 @@ import { removeEmitGlobalTypes } from 'vue-tsc';
|
|
|
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
|
|
|
22
24
|
const windowsSlashRE = /\\+/g;
|
|
@@ -360,6 +362,17 @@ export default _default;
|
|
|
360
362
|
}
|
|
361
363
|
|
|
362
364
|
const svelteRE = /\.svelte$/;
|
|
365
|
+
let lowerVersion;
|
|
366
|
+
function querySvelteVersion() {
|
|
367
|
+
if (typeof lowerVersion === "boolean")
|
|
368
|
+
return;
|
|
369
|
+
try {
|
|
370
|
+
const version = getPackageInfoSync("svelte")?.version ?? getPackageInfoSync("svelte", { paths: [resolveModule("svelte") || process.cwd()] })?.version;
|
|
371
|
+
lowerVersion = version ? compare(version, "4.0.0", "<") : false;
|
|
372
|
+
} catch {
|
|
373
|
+
lowerVersion = false;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
363
376
|
function SvelteResolver() {
|
|
364
377
|
return {
|
|
365
378
|
name: "svelte",
|
|
@@ -367,10 +380,12 @@ function SvelteResolver() {
|
|
|
367
380
|
return svelteRE.test(id);
|
|
368
381
|
},
|
|
369
382
|
transform({ id, root }) {
|
|
383
|
+
querySvelteVersion();
|
|
370
384
|
return [
|
|
371
385
|
{
|
|
372
386
|
path: relative(root, `${id}.d.ts`),
|
|
373
|
-
content:
|
|
387
|
+
content: `export { ${lowerVersion ? "SvelteComponentTyped" : "SvelteComponent"} as default } from 'svelte';
|
|
388
|
+
`
|
|
374
389
|
}
|
|
375
390
|
];
|
|
376
391
|
}
|
|
@@ -814,7 +829,11 @@ ${logPrefix} ${yellow(
|
|
|
814
829
|
(glob) => normalizeGlob(ensureAbsolute(glob, configPath ? dirname(configPath) : root))
|
|
815
830
|
);
|
|
816
831
|
};
|
|
817
|
-
include = computeGlobs(
|
|
832
|
+
include = computeGlobs(
|
|
833
|
+
options.include,
|
|
834
|
+
[...ensureArray(content?.raw.include ?? []), ...ensureArray(content?.raw.files ?? [])],
|
|
835
|
+
"**/*"
|
|
836
|
+
);
|
|
818
837
|
exclude = computeGlobs(options.exclude, content?.raw.exclude, "node_modules/**");
|
|
819
838
|
filter = createFilter(include, exclude);
|
|
820
839
|
const rootNames = [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-dts",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "qmhc",
|
|
@@ -62,8 +62,10 @@
|
|
|
62
62
|
"@rollup/pluginutils": "^5.1.0",
|
|
63
63
|
"@volar/typescript": "^2.3.4",
|
|
64
64
|
"@vue/language-core": "2.0.19",
|
|
65
|
+
"compare-versions": "^6.1.1",
|
|
65
66
|
"debug": "^4.3.5",
|
|
66
67
|
"kolorist": "^1.8.0",
|
|
68
|
+
"local-pkg": "^0.5.0",
|
|
67
69
|
"magic-string": "^0.30.10",
|
|
68
70
|
"vue-tsc": "2.0.19"
|
|
69
71
|
},
|