unplugin-isolated-decl 0.13.7 → 0.13.9
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/dist/api.js +1 -1
- package/dist/esbuild.js +2 -2
- package/dist/farm.js +2 -2
- package/dist/index.js +2 -2
- package/dist/rolldown.js +2 -2
- package/dist/rollup.js +2 -2
- package/dist/{src-DAG_rtx2.js → src-B5I0aiDn.js} +7 -10
- package/dist/{transformer-Bp3NCHCk.js → transformer-CiAWE027.js} +9 -0
- package/dist/vite.js +2 -2
- package/package.json +12 -12
package/dist/api.js
CHANGED
package/dist/esbuild.js
CHANGED
package/dist/farm.js
CHANGED
package/dist/index.js
CHANGED
package/dist/rolldown.js
CHANGED
package/dist/rollup.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { appendMapUrl, generateDtsMap, oxcTransform, swcTransform, tsTransform } from "./transformer-
|
|
1
|
+
import { appendMapUrl, generateDtsMap, oxcTransform, swcTransform, tsTransform } from "./transformer-CiAWE027.js";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
4
4
|
import MagicString from "magic-string";
|
|
@@ -50,7 +50,7 @@ function shouldAddIndex(id, resolved) {
|
|
|
50
50
|
//#endregion
|
|
51
51
|
//#region src/core/ast.ts
|
|
52
52
|
function filterImports(program) {
|
|
53
|
-
return program.body.filter((node) => (
|
|
53
|
+
return program.body.filter((node) => !!("source" in node && node.source));
|
|
54
54
|
}
|
|
55
55
|
function rewriteImports(s, imports, entryMap, inputBase, entryFileNames, srcFilename) {
|
|
56
56
|
const srcRel = path.relative(inputBase, srcFilename);
|
|
@@ -110,6 +110,9 @@ function resolveOptions(options) {
|
|
|
110
110
|
|
|
111
111
|
//#endregion
|
|
112
112
|
//#region src/index.ts
|
|
113
|
+
/**
|
|
114
|
+
* The main unplugin instance.
|
|
115
|
+
*/
|
|
113
116
|
const IsolatedDecl = createUnplugin((rawOptions = {}) => {
|
|
114
117
|
const options = resolveOptions(rawOptions);
|
|
115
118
|
const filter = createFilter(options.include, options.exclude);
|
|
@@ -195,14 +198,8 @@ const IsolatedDecl = createUnplugin((rawOptions = {}) => {
|
|
|
195
198
|
imports,
|
|
196
199
|
map
|
|
197
200
|
});
|
|
198
|
-
const
|
|
199
|
-
|
|
200
|
-
if ("importKind" in node && node.importKind === "type") return true;
|
|
201
|
-
if ("exportKind" in node && node.exportKind === "type") return true;
|
|
202
|
-
if (node.type === "ImportDeclaration") return !!node.specifiers && node.specifiers.every((spec) => spec.type === "ImportSpecifier" && spec.importKind === "type");
|
|
203
|
-
return node.type === "ExportNamedDeclaration" && node.specifiers && node.specifiers.every((spec) => spec.exportKind === "type");
|
|
204
|
-
});
|
|
205
|
-
for (const { source } of typeImports) {
|
|
201
|
+
const importsInDts = filterImports(program);
|
|
202
|
+
for (const { source } of importsInDts) {
|
|
206
203
|
const resolved = (await resolve(context, source.value, id))?.id;
|
|
207
204
|
if (resolved && filter(resolved) && !outputFiles[stripExt(resolved)]) {
|
|
208
205
|
let source$1;
|
|
@@ -4,6 +4,9 @@ import path from "node:path";
|
|
|
4
4
|
function tryImport(pkg) {
|
|
5
5
|
return import(pkg).catch(() => null);
|
|
6
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* Transform isolated declarations with `oxc-transform`.
|
|
9
|
+
*/
|
|
7
10
|
async function oxcTransform(id, code, transformOptions) {
|
|
8
11
|
const oxc = await tryImport("oxc-transform");
|
|
9
12
|
if (!oxc) return {
|
|
@@ -17,6 +20,9 @@ async function oxcTransform(id, code, transformOptions) {
|
|
|
17
20
|
errors: result.errors.map((error) => error.message)
|
|
18
21
|
};
|
|
19
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Transform isolated declarations with `@swc/core`.
|
|
25
|
+
*/
|
|
20
26
|
async function swcTransform(id, code) {
|
|
21
27
|
const swc = await tryImport("@swc/core");
|
|
22
28
|
if (!swc) return {
|
|
@@ -46,6 +52,9 @@ async function swcTransform(id, code) {
|
|
|
46
52
|
};
|
|
47
53
|
}
|
|
48
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* Transform isolated declarations with `typescript`.
|
|
57
|
+
*/
|
|
49
58
|
async function tsTransform(id, code, transformOptions, sourceMap) {
|
|
50
59
|
const ts = await tryImport("typescript");
|
|
51
60
|
if (!ts) return {
|
package/dist/vite.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unplugin-isolated-decl",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.9",
|
|
4
4
|
"description": "A blazing-fast tool for generating isolated declarations.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -63,35 +63,35 @@
|
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"debug": "^4.4.0",
|
|
65
65
|
"magic-string": "^0.30.17",
|
|
66
|
-
"oxc-parser": "^0.
|
|
67
|
-
"oxc-transform": "^0.
|
|
66
|
+
"oxc-parser": "^0.65.0",
|
|
67
|
+
"oxc-transform": "^0.65.0",
|
|
68
68
|
"unplugin": "^2.3.2",
|
|
69
69
|
"unplugin-utils": "^0.2.4"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@farmfe/core": "^1.7.4",
|
|
73
|
-
"@oxc-project/types": "^0.
|
|
73
|
+
"@oxc-project/types": "^0.65.0",
|
|
74
74
|
"@rollup/plugin-alias": "^5.1.1",
|
|
75
75
|
"@swc/core": "^1.11.21",
|
|
76
|
-
"@sxzz/eslint-config": "^6.1.
|
|
76
|
+
"@sxzz/eslint-config": "^6.1.2",
|
|
77
77
|
"@sxzz/prettier-config": "^2.2.1",
|
|
78
78
|
"@sxzz/test-utils": "^0.5.5",
|
|
79
79
|
"@types/debug": "^4.1.12",
|
|
80
80
|
"@types/node": "^22.14.1",
|
|
81
81
|
"bumpp": "^10.1.0",
|
|
82
|
-
"esbuild": "^0.25.
|
|
83
|
-
"eslint": "^9.25.
|
|
82
|
+
"esbuild": "^0.25.3",
|
|
83
|
+
"eslint": "^9.25.1",
|
|
84
84
|
"fast-glob": "^3.3.3",
|
|
85
85
|
"prettier": "^3.5.3",
|
|
86
|
-
"rolldown": "^1.0.0-beta.
|
|
86
|
+
"rolldown": "^1.0.0-beta.8",
|
|
87
87
|
"rollup": "^4.40.0",
|
|
88
|
-
"tinyglobby": "^0.2.
|
|
89
|
-
"tsdown": "^0.9.
|
|
88
|
+
"tinyglobby": "^0.2.13",
|
|
89
|
+
"tsdown": "^0.9.5",
|
|
90
90
|
"tsx": "^4.19.3",
|
|
91
91
|
"typescript": "^5.8.3",
|
|
92
|
-
"unplugin-oxc": "^0.3.
|
|
92
|
+
"unplugin-oxc": "^0.3.5",
|
|
93
93
|
"vite": "^6.3.2",
|
|
94
|
-
"vitest": "^3.1.
|
|
94
|
+
"vitest": "^3.1.2"
|
|
95
95
|
},
|
|
96
96
|
"engines": {
|
|
97
97
|
"node": ">=18.12.0"
|