unplugin-isolated-decl 0.15.7 → 0.17.0
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.mjs +2 -3
- package/dist/esbuild.mjs +2 -5
- package/dist/farm.mjs +2 -5
- package/dist/index.mjs +2 -3
- package/dist/rolldown.mjs +2 -5
- package/dist/rollup.mjs +2 -5
- package/dist/{src-BYD-yWlY.mjs → src-BKCZkyQU.mjs} +13 -18
- package/dist/{transformer-CDjTlq6t.mjs → transformer-C8I6UHef.mjs} +1 -3
- package/dist/vite.mjs +2 -5
- package/package.json +31 -33
package/dist/api.mjs
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { a as tsTransform, i as swcTransform, r as oxcTransform } from "./transformer-
|
|
2
|
-
|
|
3
|
-
export { oxcTransform, swcTransform, tsTransform };
|
|
1
|
+
import { a as tsTransform, i as swcTransform, r as oxcTransform } from "./transformer-C8I6UHef.mjs";
|
|
2
|
+
export { oxcTransform, swcTransform, tsTransform };
|
package/dist/esbuild.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { t as IsolatedDecl } from "./src-
|
|
2
|
-
|
|
1
|
+
import { t as IsolatedDecl } from "./src-BKCZkyQU.mjs";
|
|
3
2
|
//#region src/esbuild.ts
|
|
4
3
|
/**
|
|
5
4
|
* This entry file is for esbuild plugin.
|
|
@@ -19,7 +18,5 @@ import { t as IsolatedDecl } from "./src-BYD-yWlY.mjs";
|
|
|
19
18
|
* ```
|
|
20
19
|
*/
|
|
21
20
|
const esbuild = IsolatedDecl.esbuild;
|
|
22
|
-
var esbuild_default = esbuild;
|
|
23
|
-
|
|
24
21
|
//#endregion
|
|
25
|
-
export {
|
|
22
|
+
export { esbuild as default, esbuild as "module.exports" };
|
package/dist/farm.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { t as IsolatedDecl } from "./src-
|
|
2
|
-
|
|
1
|
+
import { t as IsolatedDecl } from "./src-BKCZkyQU.mjs";
|
|
3
2
|
//#region src/farm.ts
|
|
4
3
|
/**
|
|
5
4
|
* This entry file is for Farm plugin.
|
|
@@ -20,7 +19,5 @@ import { t as IsolatedDecl } from "./src-BYD-yWlY.mjs";
|
|
|
20
19
|
* ```
|
|
21
20
|
*/
|
|
22
21
|
const farm = IsolatedDecl.farm;
|
|
23
|
-
var farm_default = farm;
|
|
24
|
-
|
|
25
22
|
//#endregion
|
|
26
|
-
export {
|
|
23
|
+
export { farm as default, farm as "module.exports" };
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { t as IsolatedDecl } from "./src-
|
|
2
|
-
|
|
3
|
-
export { IsolatedDecl };
|
|
1
|
+
import { t as IsolatedDecl } from "./src-BKCZkyQU.mjs";
|
|
2
|
+
export { IsolatedDecl };
|
package/dist/rolldown.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { t as IsolatedDecl } from "./src-
|
|
2
|
-
|
|
1
|
+
import { t as IsolatedDecl } from "./src-BKCZkyQU.mjs";
|
|
3
2
|
//#region src/rolldown.ts
|
|
4
3
|
/**
|
|
5
4
|
* This entry file is for Rolldown plugin.
|
|
@@ -20,7 +19,5 @@ import { t as IsolatedDecl } from "./src-BYD-yWlY.mjs";
|
|
|
20
19
|
* ```
|
|
21
20
|
*/
|
|
22
21
|
const rolldown = IsolatedDecl.rolldown;
|
|
23
|
-
var rolldown_default = rolldown;
|
|
24
|
-
|
|
25
22
|
//#endregion
|
|
26
|
-
export {
|
|
23
|
+
export { rolldown as default, rolldown as "module.exports" };
|
package/dist/rollup.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { t as IsolatedDecl } from "./src-
|
|
2
|
-
|
|
1
|
+
import { t as IsolatedDecl } from "./src-BKCZkyQU.mjs";
|
|
3
2
|
//#region src/rollup.ts
|
|
4
3
|
/**
|
|
5
4
|
* This entry file is for Rollup plugin.
|
|
@@ -20,7 +19,5 @@ import { t as IsolatedDecl } from "./src-BYD-yWlY.mjs";
|
|
|
20
19
|
* ```
|
|
21
20
|
*/
|
|
22
21
|
const rollup = IsolatedDecl.rollup;
|
|
23
|
-
var rollup_default = rollup;
|
|
24
|
-
|
|
25
22
|
//#endregion
|
|
26
|
-
export {
|
|
23
|
+
export { rollup as default, rollup as "module.exports" };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as tsTransform, i as swcTransform, n as generateDtsMap, r as oxcTransform, t as appendMapUrl } from "./transformer-
|
|
1
|
+
import { a as tsTransform, i as swcTransform, n as generateDtsMap, r as oxcTransform, t as appendMapUrl } from "./transformer-C8I6UHef.mjs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
4
4
|
import MagicString from "magic-string";
|
|
@@ -6,7 +6,6 @@ import { parse } from "oxc-parser";
|
|
|
6
6
|
import { createUnplugin } from "unplugin";
|
|
7
7
|
import { createFilter } from "unplugin-utils";
|
|
8
8
|
import { createDebug } from "obug";
|
|
9
|
-
|
|
10
9
|
//#region src/core/utils.ts
|
|
11
10
|
const debug = createDebug("unplugin-isolated-decl");
|
|
12
11
|
function lowestCommonAncestor(...filepaths) {
|
|
@@ -45,7 +44,6 @@ function endsWithIndex(s) {
|
|
|
45
44
|
function shouldAddIndex(id, resolved) {
|
|
46
45
|
return !endsWithIndex(id) && endsWithIndex(resolved);
|
|
47
46
|
}
|
|
48
|
-
|
|
49
47
|
//#endregion
|
|
50
48
|
//#region src/core/ast.ts
|
|
51
49
|
function filterImports(program) {
|
|
@@ -60,7 +58,7 @@ function rewriteImports(s, imports, entryMap, inputBase, entryFileNames, srcFile
|
|
|
60
58
|
const entry = entryAlias || srcRel;
|
|
61
59
|
const resolvedEntry = entryFileNames.replaceAll("[name]", entry);
|
|
62
60
|
const emitDir = path.dirname(resolvedEntry);
|
|
63
|
-
const emitDtsName = resolvedEntry.replace(/\.(.)?[jt]sx?$/, (_, s
|
|
61
|
+
const emitDtsName = resolvedEntry.replace(/\.(.)?[jt]sx?$/, (_, s) => `.d.${s || ""}ts`);
|
|
64
62
|
const offset = path.relative(emitDir, srcDirRel);
|
|
65
63
|
for (const i of imports) {
|
|
66
64
|
const { source } = i;
|
|
@@ -86,7 +84,6 @@ function rewriteImports(s, imports, entryMap, inputBase, entryFileNames, srcFile
|
|
|
86
84
|
function pathRelative(from, to) {
|
|
87
85
|
return path.join(path.relative(from, path.dirname(to)), path.basename(to));
|
|
88
86
|
}
|
|
89
|
-
|
|
90
87
|
//#endregion
|
|
91
88
|
//#region src/core/options.ts
|
|
92
89
|
function resolveOptions(options) {
|
|
@@ -104,7 +101,6 @@ function resolveOptions(options) {
|
|
|
104
101
|
transformOptions: options.transformOptions
|
|
105
102
|
};
|
|
106
103
|
}
|
|
107
|
-
|
|
108
104
|
//#endregion
|
|
109
105
|
//#region src/index.ts
|
|
110
106
|
/**
|
|
@@ -187,10 +183,10 @@ const IsolatedDecl = createUnplugin((rawOptions = {}) => {
|
|
|
187
183
|
const { source } = i;
|
|
188
184
|
let { value } = source;
|
|
189
185
|
if (options.rewriteImports) {
|
|
190
|
-
const result
|
|
191
|
-
if (typeof result
|
|
192
|
-
source.value = value = result
|
|
193
|
-
s.overwrite(source.start + 1, source.end - 1, result
|
|
186
|
+
const result = options.rewriteImports(value, id);
|
|
187
|
+
if (typeof result === "string") {
|
|
188
|
+
source.value = value = result;
|
|
189
|
+
s.overwrite(source.start + 1, source.end - 1, result);
|
|
194
190
|
}
|
|
195
191
|
}
|
|
196
192
|
if (path.isAbsolute(value) || value[0] === ".") {
|
|
@@ -214,14 +210,14 @@ const IsolatedDecl = createUnplugin((rawOptions = {}) => {
|
|
|
214
210
|
for (const { source } of typeImports) {
|
|
215
211
|
const resolved = (await resolve(context, source.value, id))?.id;
|
|
216
212
|
if (resolved && filter(resolved) && !outputFiles[stripExt(resolved)]) {
|
|
217
|
-
let source
|
|
213
|
+
let source;
|
|
218
214
|
try {
|
|
219
|
-
source
|
|
215
|
+
source = await readFile(resolved, "utf8");
|
|
220
216
|
} catch {
|
|
221
217
|
continue;
|
|
222
218
|
}
|
|
223
219
|
debug("transform type import:", resolved);
|
|
224
|
-
await transform(context, source
|
|
220
|
+
await transform(context, source, resolved);
|
|
225
221
|
}
|
|
226
222
|
}
|
|
227
223
|
}
|
|
@@ -260,7 +256,7 @@ const IsolatedDecl = createUnplugin((rawOptions = {}) => {
|
|
|
260
256
|
const { inputBase, entryMap } = resolveEntry(input, options.inputBase);
|
|
261
257
|
debug("[farm] input base:", inputBase);
|
|
262
258
|
if (output && typeof output.entryFilename !== "string") return console.error("entryFileName must be a string");
|
|
263
|
-
const extFormatMap = new Map([
|
|
259
|
+
const extFormatMap = /* @__PURE__ */ new Map([
|
|
264
260
|
["cjs", "cjs"],
|
|
265
261
|
["esm", "js"],
|
|
266
262
|
["mjs", "js"]
|
|
@@ -294,8 +290,8 @@ const IsolatedDecl = createUnplugin((rawOptions = {}) => {
|
|
|
294
290
|
build.onEnd(async (result) => {
|
|
295
291
|
const esbuildOptions = build.initialOptions;
|
|
296
292
|
const entries = esbuildOptions.entryPoints;
|
|
297
|
-
if (!entries || !Array.isArray(entries) ||
|
|
298
|
-
const inputBase = options.inputBase || lowestCommonAncestor(...entries);
|
|
293
|
+
if (!entries || !Array.isArray(entries) || entries.some((entry) => typeof entry !== "string")) throw new Error("unsupported entryPoints, must be an string[]");
|
|
294
|
+
const inputBase = options.inputBase || lowestCommonAncestor(...entries.map((entry) => typeof entry === "string" ? entry : entry.in));
|
|
299
295
|
debug("[esbuild] input base:", inputBase);
|
|
300
296
|
const jsExt = esbuildOptions.outExtension?.[".js"];
|
|
301
297
|
let outExt;
|
|
@@ -386,6 +382,5 @@ async function resolve(context, id, importer) {
|
|
|
386
382
|
function patchCjsDefaultExport(source) {
|
|
387
383
|
return source.replace(/(?<=(?:[;}]|^)\s*export\s*)(?:\{\s*([\w$]+)\s*as\s+default\s*\}|default\s+([\w$]+))/, (_, s1, s2) => `= ${s1 || s2}`);
|
|
388
384
|
}
|
|
389
|
-
|
|
390
385
|
//#endregion
|
|
391
|
-
export { IsolatedDecl as t };
|
|
386
|
+
export { IsolatedDecl as t };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
|
|
3
2
|
//#region src/core/transformer.ts
|
|
4
3
|
function tryImport(pkg) {
|
|
5
4
|
return import(pkg).catch(() => null);
|
|
@@ -105,6 +104,5 @@ function generateDtsMap(mappings, src, dts) {
|
|
|
105
104
|
mappings
|
|
106
105
|
});
|
|
107
106
|
}
|
|
108
|
-
|
|
109
107
|
//#endregion
|
|
110
|
-
export { tsTransform as a, swcTransform as i, generateDtsMap as n, oxcTransform as r, appendMapUrl as t };
|
|
108
|
+
export { tsTransform as a, swcTransform as i, generateDtsMap as n, oxcTransform as r, appendMapUrl as t };
|
package/dist/vite.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { t as IsolatedDecl } from "./src-
|
|
2
|
-
|
|
1
|
+
import { t as IsolatedDecl } from "./src-BKCZkyQU.mjs";
|
|
3
2
|
//#region src/vite.ts
|
|
4
3
|
/**
|
|
5
4
|
* This entry file is for Vite plugin.
|
|
@@ -20,7 +19,5 @@ import { t as IsolatedDecl } from "./src-BYD-yWlY.mjs";
|
|
|
20
19
|
* ```
|
|
21
20
|
*/
|
|
22
21
|
const vite = IsolatedDecl.vite;
|
|
23
|
-
var vite_default = vite;
|
|
24
|
-
|
|
25
22
|
//#endregion
|
|
26
|
-
export {
|
|
23
|
+
export { vite as default, vite as "module.exports" };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unplugin-isolated-decl",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.17.0",
|
|
5
5
|
"description": "A blazing-fast tool for generating isolated declarations.",
|
|
6
6
|
"author": "Kevin Deng <sxzz@sxzz.moe>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -31,9 +31,6 @@
|
|
|
31
31
|
"./vite": "./dist/vite.mjs",
|
|
32
32
|
"./package.json": "./package.json"
|
|
33
33
|
},
|
|
34
|
-
"main": "./dist/index.mjs",
|
|
35
|
-
"module": "./dist/index.mjs",
|
|
36
|
-
"types": "./dist/index.d.mts",
|
|
37
34
|
"typesVersions": {
|
|
38
35
|
"*": {
|
|
39
36
|
"*": [
|
|
@@ -49,11 +46,11 @@
|
|
|
49
46
|
"access": "public"
|
|
50
47
|
},
|
|
51
48
|
"engines": {
|
|
52
|
-
"node": ">=
|
|
49
|
+
"node": "^22.18.0 || ^24.11.0 || >=26.0.0"
|
|
53
50
|
},
|
|
54
51
|
"peerDependencies": {
|
|
55
52
|
"@swc/core": "^1.6.6",
|
|
56
|
-
"typescript": "^5.5.2"
|
|
53
|
+
"typescript": "^5.5.2 || ^6.0.0"
|
|
57
54
|
},
|
|
58
55
|
"peerDependenciesMeta": {
|
|
59
56
|
"@swc/core": {
|
|
@@ -64,37 +61,37 @@
|
|
|
64
61
|
}
|
|
65
62
|
},
|
|
66
63
|
"dependencies": {
|
|
67
|
-
"magic-string": "^
|
|
68
|
-
"obug": "^2.1.
|
|
69
|
-
"oxc-parser": ">=0.
|
|
70
|
-
"oxc-transform": ">=0.
|
|
71
|
-
"unplugin": "^
|
|
72
|
-
"unplugin-utils": "^0.3.
|
|
64
|
+
"magic-string": "^1.1.0",
|
|
65
|
+
"obug": "^2.1.4",
|
|
66
|
+
"oxc-parser": ">=0.141.0",
|
|
67
|
+
"oxc-transform": ">=0.141.0",
|
|
68
|
+
"unplugin": "^3.3.0",
|
|
69
|
+
"unplugin-utils": "^0.3.2"
|
|
73
70
|
},
|
|
74
71
|
"devDependencies": {
|
|
72
|
+
"@arethetypeswrong/core": "^0.18.5",
|
|
75
73
|
"@farmfe/core": "^1.7.11",
|
|
76
|
-
"@oxc-project/types": "^0.
|
|
74
|
+
"@oxc-project/types": "^0.141.0",
|
|
77
75
|
"@rollup/plugin-alias": "^6.0.0",
|
|
78
|
-
"@swc/core": "^1.15.
|
|
79
|
-
"@sxzz/eslint-config": "^
|
|
80
|
-
"@sxzz/prettier-config": "^2.2
|
|
81
|
-
"@sxzz/test-utils": "^0.5.
|
|
82
|
-
"@types/node": "^
|
|
83
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
84
|
-
"bumpp": "^
|
|
85
|
-
"esbuild": "^0.
|
|
86
|
-
"eslint": "^
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
"
|
|
92
|
-
"
|
|
93
|
-
"
|
|
94
|
-
"
|
|
95
|
-
"
|
|
96
|
-
"
|
|
97
|
-
"vitest": "^4.0.15"
|
|
76
|
+
"@swc/core": "^1.15.46",
|
|
77
|
+
"@sxzz/eslint-config": "^8.3.1",
|
|
78
|
+
"@sxzz/prettier-config": "^2.3.2",
|
|
79
|
+
"@sxzz/test-utils": "^0.5.18",
|
|
80
|
+
"@types/node": "^26.1.1",
|
|
81
|
+
"@typescript/native-preview": "7.0.0-dev.20260707.2",
|
|
82
|
+
"bumpp": "^12.0.0",
|
|
83
|
+
"esbuild": "^0.28.1",
|
|
84
|
+
"eslint": "^10.7.0",
|
|
85
|
+
"prettier": "^3.9.6",
|
|
86
|
+
"publint": "^0.3.22",
|
|
87
|
+
"rolldown": "^1.2.0",
|
|
88
|
+
"rollup": "^4.62.2",
|
|
89
|
+
"tinyglobby": "^0.2.17",
|
|
90
|
+
"tsdown": "^0.22.14",
|
|
91
|
+
"typescript": "^6.0.3",
|
|
92
|
+
"unplugin-oxc": "^0.6.1",
|
|
93
|
+
"vite": "^8.1.5",
|
|
94
|
+
"vitest": "^4.1.10"
|
|
98
95
|
},
|
|
99
96
|
"resolutions": {
|
|
100
97
|
"@changesets/cli": "-",
|
|
@@ -104,6 +101,7 @@
|
|
|
104
101
|
"scripts": {
|
|
105
102
|
"lint": "eslint --cache .",
|
|
106
103
|
"lint:fix": "pnpm run lint --fix",
|
|
104
|
+
"format": "prettier --write .",
|
|
107
105
|
"build": "tsdown",
|
|
108
106
|
"dev": "tsdown --watch",
|
|
109
107
|
"test": "vitest",
|