unplugin-isolated-decl 0.9.2 → 0.9.4
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.cjs +1 -1
- package/dist/api.js +1 -1
- package/dist/core/ast.d.cts +1 -1
- package/dist/core/ast.d.ts +1 -1
- package/dist/core/options.d.cts +1 -1
- package/dist/core/options.d.ts +1 -1
- package/dist/core/utils.d.cts +1 -1
- package/dist/core/utils.d.ts +1 -1
- package/dist/esbuild.cjs +2 -2
- package/dist/esbuild.d.cts +1 -1
- package/dist/esbuild.d.ts +1 -1
- package/dist/esbuild.js +2 -2
- package/dist/farm.cjs +2 -2
- package/dist/farm.d.cts +1 -1
- package/dist/farm.d.ts +1 -1
- package/dist/farm.js +2 -2
- package/dist/index.cjs +2 -2
- package/dist/index.js +2 -2
- package/dist/rolldown.cjs +2 -2
- package/dist/rolldown.d.cts +1 -1
- package/dist/rolldown.d.ts +1 -1
- package/dist/rolldown.js +2 -2
- package/dist/rollup.cjs +2 -2
- package/dist/rollup.d.cts +1 -1
- package/dist/rollup.d.ts +1 -1
- package/dist/rollup.js +2 -2
- package/dist/{src-DVALVxuy.cjs → src-Dk3pOZcL.cjs} +15 -8
- package/dist/{src-CoC_1xj6.js → src-Jtg_38T1.js} +15 -8
- package/dist/{transformer-BI1dF8s7.cjs → transformer-ApyMa6QO.cjs} +1 -5
- package/dist/{transformer-DfgXLWZQ.js → transformer-CHqAqBjB.js} +1 -5
- package/dist/vite.cjs +2 -2
- package/dist/vite.d.cts +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +2 -2
- package/package.json +11 -11
package/dist/api.cjs
CHANGED
package/dist/api.js
CHANGED
package/dist/core/ast.d.cts
CHANGED
|
@@ -2,7 +2,7 @@ import type * as OxcTypes from '@oxc-project/types';
|
|
|
2
2
|
import type MagicString from 'magic-string';
|
|
3
3
|
export type OxcImport = (OxcTypes.ImportDeclaration | OxcTypes.ExportAllDeclaration | OxcTypes.ExportNamedDeclaration) & {
|
|
4
4
|
source: OxcTypes.StringLiteral;
|
|
5
|
-
|
|
5
|
+
suffix?: string;
|
|
6
6
|
};
|
|
7
7
|
export declare function filterImports(program: OxcTypes.Program): OxcImport[];
|
|
8
8
|
export declare function rewriteImports(s: MagicString, imports: OxcImport[], entryMap: Record<string, string> | undefined, inputBase: string, entryFileNames: string, srcFilename: string): string;
|
package/dist/core/ast.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type * as OxcTypes from '@oxc-project/types';
|
|
|
2
2
|
import type MagicString from 'magic-string';
|
|
3
3
|
export type OxcImport = (OxcTypes.ImportDeclaration | OxcTypes.ExportAllDeclaration | OxcTypes.ExportNamedDeclaration) & {
|
|
4
4
|
source: OxcTypes.StringLiteral;
|
|
5
|
-
|
|
5
|
+
suffix?: string;
|
|
6
6
|
};
|
|
7
7
|
export declare function filterImports(program: OxcTypes.Program): OxcImport[];
|
|
8
8
|
export declare function rewriteImports(s: MagicString, imports: OxcImport[], entryMap: Record<string, string> | undefined, inputBase: string, entryFileNames: string, srcFilename: string): string;
|
package/dist/core/options.d.cts
CHANGED
package/dist/core/options.d.ts
CHANGED
package/dist/core/utils.d.cts
CHANGED
|
@@ -6,4 +6,4 @@ export declare function resolveEntry(input: string | string[] | Record<string, s
|
|
|
6
6
|
entryMap: Record<string, string> | undefined;
|
|
7
7
|
inputBase: string;
|
|
8
8
|
};
|
|
9
|
-
export declare function
|
|
9
|
+
export declare function guessSuffix(id: string, resolved: string): string;
|
package/dist/core/utils.d.ts
CHANGED
|
@@ -6,4 +6,4 @@ export declare function resolveEntry(input: string | string[] | Record<string, s
|
|
|
6
6
|
entryMap: Record<string, string> | undefined;
|
|
7
7
|
inputBase: string;
|
|
8
8
|
};
|
|
9
|
-
export declare function
|
|
9
|
+
export declare function guessSuffix(id: string, resolved: string): string;
|
package/dist/esbuild.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
require('./transformer-
|
|
3
|
-
const require_src = require('./src-
|
|
2
|
+
require('./transformer-ApyMa6QO.cjs');
|
|
3
|
+
const require_src = require('./src-Dk3pOZcL.cjs');
|
|
4
4
|
|
|
5
5
|
//#region src/esbuild.ts
|
|
6
6
|
var esbuild_default = require_src.IsolatedDecl.esbuild;
|
package/dist/esbuild.d.cts
CHANGED
package/dist/esbuild.d.ts
CHANGED
package/dist/esbuild.js
CHANGED
package/dist/farm.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
require('./transformer-
|
|
3
|
-
const require_src = require('./src-
|
|
2
|
+
require('./transformer-ApyMa6QO.cjs');
|
|
3
|
+
const require_src = require('./src-Dk3pOZcL.cjs');
|
|
4
4
|
|
|
5
5
|
//#region src/farm.ts
|
|
6
6
|
var farm_default = require_src.IsolatedDecl.farm;
|
package/dist/farm.d.cts
CHANGED
package/dist/farm.d.ts
CHANGED
package/dist/farm.js
CHANGED
package/dist/index.cjs
CHANGED
package/dist/index.js
CHANGED
package/dist/rolldown.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
require('./transformer-
|
|
3
|
-
const require_src = require('./src-
|
|
2
|
+
require('./transformer-ApyMa6QO.cjs');
|
|
3
|
+
const require_src = require('./src-Dk3pOZcL.cjs');
|
|
4
4
|
|
|
5
5
|
//#region src/rolldown.ts
|
|
6
6
|
var rolldown_default = require_src.IsolatedDecl.rolldown;
|
package/dist/rolldown.d.cts
CHANGED
package/dist/rolldown.d.ts
CHANGED
package/dist/rolldown.js
CHANGED
package/dist/rollup.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
require('./transformer-
|
|
3
|
-
const require_src = require('./src-
|
|
2
|
+
require('./transformer-ApyMa6QO.cjs');
|
|
3
|
+
const require_src = require('./src-Dk3pOZcL.cjs');
|
|
4
4
|
|
|
5
5
|
//#region src/rollup.ts
|
|
6
6
|
var rollup_default = require_src.IsolatedDecl.rollup;
|
package/dist/rollup.d.cts
CHANGED
package/dist/rollup.d.ts
CHANGED
package/dist/rollup.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const require_transformer = require('./transformer-
|
|
2
|
+
const require_transformer = require('./transformer-ApyMa6QO.cjs');
|
|
3
3
|
const node_path = require_transformer.__toESM(require("node:path"));
|
|
4
4
|
const node_fs_promises = require_transformer.__toESM(require("node:fs/promises"));
|
|
5
5
|
const __rollup_pluginutils = require_transformer.__toESM(require("@rollup/pluginutils"));
|
|
@@ -41,9 +41,15 @@ function resolveEntry(input, userInputBase) {
|
|
|
41
41
|
inputBase
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
|
-
function
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
function endsWithIndex(s) {
|
|
45
|
+
return /(?:^|[/\\])index\..+$/.test(s);
|
|
46
|
+
}
|
|
47
|
+
function guessSuffix(id, resolved) {
|
|
48
|
+
let suffix = "";
|
|
49
|
+
if (!endsWithIndex(id) && endsWithIndex(resolved)) suffix += "/index";
|
|
50
|
+
const ext = node_path.default.extname(resolved).slice(1).replace(/^([cm]?)ts/, (_, $1) => `${$1}js`);
|
|
51
|
+
suffix += `.${ext}`;
|
|
52
|
+
return suffix;
|
|
47
53
|
}
|
|
48
54
|
|
|
49
55
|
//#endregion
|
|
@@ -73,12 +79,13 @@ function rewriteImports(s, imports, entryMap, inputBase, entryFileNames, srcFile
|
|
|
73
79
|
const resolved = stripExt(entryFileNames.replaceAll("[name]", importAlias));
|
|
74
80
|
id = pathRelative(srcDirRel, resolved);
|
|
75
81
|
} else id = stripExt(entryFileNames.replaceAll("[name]", srcIdRel));
|
|
76
|
-
const
|
|
77
|
-
if (
|
|
82
|
+
const suffix = i.suffix || guessSuffix(source.value, source.value);
|
|
83
|
+
if (suffix) id += suffix;
|
|
78
84
|
let final = node_path.default.normalize(node_path.default.join(offset, id));
|
|
79
85
|
if (final !== node_path.default.normalize(source.value)) {
|
|
80
86
|
debug$1("Patch import in", srcRel, ":", srcIdRel, "->", final);
|
|
81
87
|
final = final.replaceAll("\\", "/");
|
|
88
|
+
if (final.startsWith("/")) final = `.${final}`;
|
|
82
89
|
if (!/^\.\.?\//.test(final)) final = `./${final}`;
|
|
83
90
|
s.overwrite(i.source.start + 1, i.source.end - 1, final);
|
|
84
91
|
}
|
|
@@ -166,7 +173,7 @@ else {
|
|
|
166
173
|
context.error(errors[0]);
|
|
167
174
|
return;
|
|
168
175
|
}
|
|
169
|
-
const { program } = await (0, oxc_parser.parseAsync)(
|
|
176
|
+
const { program } = await (0, oxc_parser.parseAsync)(id, dts);
|
|
170
177
|
const imports = filterImports(program);
|
|
171
178
|
const s = new magic_string.default(dts);
|
|
172
179
|
if (options.autoAddExts || options.rewriteImports) for (const i of imports) {
|
|
@@ -182,7 +189,7 @@ else {
|
|
|
182
189
|
if (options.autoAddExts && (node_path.default.isAbsolute(value) || value[0] === ".")) {
|
|
183
190
|
const resolved = await resolve(context, value, stripExt(id));
|
|
184
191
|
if (!resolved || resolved.external) continue;
|
|
185
|
-
i.
|
|
192
|
+
i.suffix = guessSuffix(value, resolved.id);
|
|
186
193
|
}
|
|
187
194
|
}
|
|
188
195
|
addOutput(id, {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { appendMapUrl, generateDtsMap, oxcTransform, swcTransform, tsTransform } from "./transformer-
|
|
1
|
+
import { appendMapUrl, generateDtsMap, oxcTransform, swcTransform, tsTransform } from "./transformer-CHqAqBjB.js";
|
|
2
2
|
import path, { default as path$1, default as path$2 } from "node:path";
|
|
3
3
|
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
4
4
|
import { createFilter } from "@rollup/pluginutils";
|
|
@@ -40,9 +40,15 @@ function resolveEntry(input, userInputBase) {
|
|
|
40
40
|
inputBase
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
|
-
function
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
function endsWithIndex(s) {
|
|
44
|
+
return /(?:^|[/\\])index\..+$/.test(s);
|
|
45
|
+
}
|
|
46
|
+
function guessSuffix(id, resolved) {
|
|
47
|
+
let suffix = "";
|
|
48
|
+
if (!endsWithIndex(id) && endsWithIndex(resolved)) suffix += "/index";
|
|
49
|
+
const ext = path$2.extname(resolved).slice(1).replace(/^([cm]?)ts/, (_, $1) => `${$1}js`);
|
|
50
|
+
suffix += `.${ext}`;
|
|
51
|
+
return suffix;
|
|
46
52
|
}
|
|
47
53
|
|
|
48
54
|
//#endregion
|
|
@@ -72,12 +78,13 @@ function rewriteImports(s, imports, entryMap, inputBase, entryFileNames, srcFile
|
|
|
72
78
|
const resolved = stripExt(entryFileNames.replaceAll("[name]", importAlias));
|
|
73
79
|
id = pathRelative(srcDirRel, resolved);
|
|
74
80
|
} else id = stripExt(entryFileNames.replaceAll("[name]", srcIdRel));
|
|
75
|
-
const
|
|
76
|
-
if (
|
|
81
|
+
const suffix = i.suffix || guessSuffix(source.value, source.value);
|
|
82
|
+
if (suffix) id += suffix;
|
|
77
83
|
let final = path$1.normalize(path$1.join(offset, id));
|
|
78
84
|
if (final !== path$1.normalize(source.value)) {
|
|
79
85
|
debug("Patch import in", srcRel, ":", srcIdRel, "->", final);
|
|
80
86
|
final = final.replaceAll("\\", "/");
|
|
87
|
+
if (final.startsWith("/")) final = `.${final}`;
|
|
81
88
|
if (!/^\.\.?\//.test(final)) final = `./${final}`;
|
|
82
89
|
s.overwrite(i.source.start + 1, i.source.end - 1, final);
|
|
83
90
|
}
|
|
@@ -165,7 +172,7 @@ else {
|
|
|
165
172
|
context.error(errors[0]);
|
|
166
173
|
return;
|
|
167
174
|
}
|
|
168
|
-
const { program } = await parseAsync(
|
|
175
|
+
const { program } = await parseAsync(id, dts);
|
|
169
176
|
const imports = filterImports(program);
|
|
170
177
|
const s = new MagicString(dts);
|
|
171
178
|
if (options.autoAddExts || options.rewriteImports) for (const i of imports) {
|
|
@@ -181,7 +188,7 @@ else {
|
|
|
181
188
|
if (options.autoAddExts && (path.isAbsolute(value) || value[0] === ".")) {
|
|
182
189
|
const resolved = await resolve(context, value, stripExt(id));
|
|
183
190
|
if (!resolved || resolved.external) continue;
|
|
184
|
-
i.
|
|
191
|
+
i.suffix = guessSuffix(value, resolved.id);
|
|
185
192
|
}
|
|
186
193
|
}
|
|
187
194
|
addOutput(id, {
|
|
@@ -26,11 +26,7 @@ const node_path = __toESM(require("node:path"));
|
|
|
26
26
|
|
|
27
27
|
//#region src/core/transformer.ts
|
|
28
28
|
function tryImport(pkg) {
|
|
29
|
-
|
|
30
|
-
return import(pkg);
|
|
31
|
-
} catch {
|
|
32
|
-
return Promise.resolve(null);
|
|
33
|
-
}
|
|
29
|
+
return import(pkg).catch(() => null);
|
|
34
30
|
}
|
|
35
31
|
async function oxcTransform(id, code, sourceMap) {
|
|
36
32
|
const oxc = await tryImport("oxc-transform");
|
|
@@ -2,11 +2,7 @@ import path from "node:path";
|
|
|
2
2
|
|
|
3
3
|
//#region src/core/transformer.ts
|
|
4
4
|
function tryImport(pkg) {
|
|
5
|
-
|
|
6
|
-
return import(pkg);
|
|
7
|
-
} catch {
|
|
8
|
-
return Promise.resolve(null);
|
|
9
|
-
}
|
|
5
|
+
return import(pkg).catch(() => null);
|
|
10
6
|
}
|
|
11
7
|
async function oxcTransform(id, code, sourceMap) {
|
|
12
8
|
const oxc = await tryImport("oxc-transform");
|
package/dist/vite.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
require('./transformer-
|
|
3
|
-
const require_src = require('./src-
|
|
2
|
+
require('./transformer-ApyMa6QO.cjs');
|
|
3
|
+
const require_src = require('./src-Dk3pOZcL.cjs');
|
|
4
4
|
|
|
5
5
|
//#region src/vite.ts
|
|
6
6
|
var vite_default = require_src.IsolatedDecl.vite;
|
package/dist/vite.d.cts
CHANGED
package/dist/vite.d.ts
CHANGED
package/dist/vite.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unplugin-isolated-decl",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.4",
|
|
4
4
|
"description": "A blazing-fast tool for generating isolated declarations.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -91,14 +91,14 @@
|
|
|
91
91
|
"@rollup/pluginutils": "^5.1.3",
|
|
92
92
|
"debug": "^4.3.7",
|
|
93
93
|
"magic-string": "^0.30.14",
|
|
94
|
-
"oxc-parser": "^0.
|
|
95
|
-
"unplugin": "^2.0.0
|
|
94
|
+
"oxc-parser": "^0.39.0",
|
|
95
|
+
"unplugin": "^2.0.0"
|
|
96
96
|
},
|
|
97
97
|
"devDependencies": {
|
|
98
|
-
"@farmfe/core": "^1.4.
|
|
99
|
-
"@oxc-project/types": "^0.
|
|
98
|
+
"@farmfe/core": "^1.4.7",
|
|
99
|
+
"@oxc-project/types": "^0.39.0",
|
|
100
100
|
"@rollup/plugin-alias": "^5.1.1",
|
|
101
|
-
"@swc/core": "^1.
|
|
101
|
+
"@swc/core": "^1.10.0",
|
|
102
102
|
"@sxzz/eslint-config": "^4.5.1",
|
|
103
103
|
"@sxzz/prettier-config": "^2.0.2",
|
|
104
104
|
"@sxzz/test-utils": "^0.3.8",
|
|
@@ -108,17 +108,17 @@
|
|
|
108
108
|
"esbuild": "^0.24.0",
|
|
109
109
|
"eslint": "^9.16.0",
|
|
110
110
|
"fast-glob": "^3.3.2",
|
|
111
|
-
"oxc-transform": "^0.
|
|
112
|
-
"prettier": "^3.4.
|
|
111
|
+
"oxc-transform": "^0.39.0",
|
|
112
|
+
"prettier": "^3.4.2",
|
|
113
113
|
"rolldown": "nightly",
|
|
114
114
|
"rollup": "^4.28.0",
|
|
115
115
|
"rollup-plugin-esbuild": "^6.1.1",
|
|
116
116
|
"tinyglobby": "^0.2.10",
|
|
117
|
-
"tsdown": "^0.
|
|
117
|
+
"tsdown": "^0.4.1",
|
|
118
118
|
"tsx": "^4.19.2",
|
|
119
119
|
"typescript": "^5.7.2",
|
|
120
|
-
"vite": "^6.0.
|
|
121
|
-
"vitest": "^2.1.
|
|
120
|
+
"vite": "^6.0.2",
|
|
121
|
+
"vitest": "^2.1.8"
|
|
122
122
|
},
|
|
123
123
|
"engines": {
|
|
124
124
|
"node": ">=18.12.0"
|