unplugin-isolated-decl 0.10.2 → 0.10.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 -2
- package/dist/core/ast.d.ts +1 -2
- package/dist/esbuild.cjs +2 -2
- package/dist/esbuild.js +2 -2
- package/dist/farm.cjs +2 -2
- 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.js +2 -2
- package/dist/rollup.cjs +2 -2
- package/dist/rollup.js +2 -2
- package/dist/{src-Yy6QF_tM.js → src-CdRSuGk8.js} +17 -17
- package/dist/{src-h7U2Vqcv.cjs → src-mIY6Bwrv.cjs} +4 -4
- package/dist/{transformer-CHqAqBjB.js → transformer-CBYRFUWY.js} +2 -1
- package/dist/{transformer-ApyMa6QO.cjs → transformer-DzpBM_tn.cjs} +12 -6
- package/dist/vite.cjs +2 -2
- package/dist/vite.js +2 -2
- package/package.json +19 -19
package/dist/api.cjs
CHANGED
package/dist/api.js
CHANGED
package/dist/core/ast.d.cts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { OptionsResolved } from './options.cjs';
|
|
2
1
|
import type * as OxcTypes from '@oxc-project/types';
|
|
3
2
|
import type MagicString from 'magic-string';
|
|
4
3
|
export type OxcImport = (OxcTypes.ImportDeclaration | OxcTypes.ExportAllDeclaration | OxcTypes.ExportNamedDeclaration) & {
|
|
@@ -6,4 +5,4 @@ export type OxcImport = (OxcTypes.ImportDeclaration | OxcTypes.ExportAllDeclarat
|
|
|
6
5
|
shouldAddIndex?: boolean;
|
|
7
6
|
};
|
|
8
7
|
export declare function filterImports(program: OxcTypes.Program): OxcImport[];
|
|
9
|
-
export declare function rewriteImports(s: MagicString,
|
|
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
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { OptionsResolved } from './options.js';
|
|
2
1
|
import type * as OxcTypes from '@oxc-project/types';
|
|
3
2
|
import type MagicString from 'magic-string';
|
|
4
3
|
export type OxcImport = (OxcTypes.ImportDeclaration | OxcTypes.ExportAllDeclaration | OxcTypes.ExportNamedDeclaration) & {
|
|
@@ -6,4 +5,4 @@ export type OxcImport = (OxcTypes.ImportDeclaration | OxcTypes.ExportAllDeclarat
|
|
|
6
5
|
shouldAddIndex?: boolean;
|
|
7
6
|
};
|
|
8
7
|
export declare function filterImports(program: OxcTypes.Program): OxcImport[];
|
|
9
|
-
export declare function rewriteImports(s: MagicString,
|
|
8
|
+
export declare function rewriteImports(s: MagicString, imports: OxcImport[], entryMap: Record<string, string> | undefined, inputBase: string, entryFileNames: string, srcFilename: 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-DzpBM_tn.cjs');
|
|
3
|
+
const require_src = require('./src-mIY6Bwrv.cjs');
|
|
4
4
|
|
|
5
5
|
//#region src/esbuild.ts
|
|
6
6
|
var esbuild_default = require_src.IsolatedDecl.esbuild;
|
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-DzpBM_tn.cjs');
|
|
3
|
+
const require_src = require('./src-mIY6Bwrv.cjs');
|
|
4
4
|
|
|
5
5
|
//#region src/farm.ts
|
|
6
6
|
var farm_default = require_src.IsolatedDecl.farm;
|
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-DzpBM_tn.cjs');
|
|
3
|
+
const require_src = require('./src-mIY6Bwrv.cjs');
|
|
4
4
|
|
|
5
5
|
//#region src/rolldown.ts
|
|
6
6
|
var rolldown_default = require_src.IsolatedDecl.rolldown;
|
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-DzpBM_tn.cjs');
|
|
3
|
+
const require_src = require('./src-mIY6Bwrv.cjs');
|
|
4
4
|
|
|
5
5
|
//#region src/rollup.ts
|
|
6
6
|
var rollup_default = require_src.IsolatedDecl.rollup;
|
package/dist/rollup.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { appendMapUrl, generateDtsMap, oxcTransform, swcTransform, tsTransform } from "./transformer-
|
|
2
|
-
import path
|
|
1
|
+
import { appendMapUrl, generateDtsMap, oxcTransform, swcTransform, tsTransform } from "./transformer-CBYRFUWY.js";
|
|
2
|
+
import path from "node:path";
|
|
3
3
|
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
4
4
|
import { createFilter } from "@rollup/pluginutils";
|
|
5
5
|
import MagicString from "magic-string";
|
|
@@ -11,7 +11,7 @@ import Debug from "debug";
|
|
|
11
11
|
const debug = Debug("unplugin-isolated-decl");
|
|
12
12
|
function lowestCommonAncestor(...filepaths) {
|
|
13
13
|
if (filepaths.length === 0) return "";
|
|
14
|
-
if (filepaths.length === 1) return path
|
|
14
|
+
if (filepaths.length === 1) return path.dirname(filepaths[0]);
|
|
15
15
|
filepaths = filepaths.map((p) => p.replaceAll("\\", "/"));
|
|
16
16
|
const [first, ...rest] = filepaths;
|
|
17
17
|
let ancestor = first.split("/");
|
|
@@ -32,7 +32,7 @@ function stripExt(filename) {
|
|
|
32
32
|
}
|
|
33
33
|
function resolveEntry(input, userInputBase) {
|
|
34
34
|
if (typeof input === "string") input = [input];
|
|
35
|
-
const entryMap = !Array.isArray(input) ? Object.fromEntries(Object.entries(input).map(([k, v]) => [path
|
|
35
|
+
const entryMap = !Array.isArray(input) ? Object.fromEntries(Object.entries(input).map(([k, v]) => [path.resolve(stripExt(v)), k])) : undefined;
|
|
36
36
|
const arr = Array.isArray(input) && input ? input : Object.values(input);
|
|
37
37
|
const inputBase = userInputBase || lowestCommonAncestor(...arr);
|
|
38
38
|
return {
|
|
@@ -52,31 +52,31 @@ function shouldAddIndex(id, resolved) {
|
|
|
52
52
|
function filterImports(program) {
|
|
53
53
|
return program.body.filter((node) => (node.type === "ImportDeclaration" || node.type === "ExportAllDeclaration" || node.type === "ExportNamedDeclaration") && !!node.source);
|
|
54
54
|
}
|
|
55
|
-
function rewriteImports(s,
|
|
56
|
-
const srcRel = path
|
|
57
|
-
const srcDir = path
|
|
58
|
-
const srcDirRel = path
|
|
55
|
+
function rewriteImports(s, imports, entryMap, inputBase, entryFileNames, srcFilename) {
|
|
56
|
+
const srcRel = path.relative(inputBase, srcFilename);
|
|
57
|
+
const srcDir = path.dirname(srcFilename);
|
|
58
|
+
const srcDirRel = path.relative(inputBase, srcDir);
|
|
59
59
|
let entryAlias = entryMap?.[srcFilename];
|
|
60
|
-
if (entryAlias && path
|
|
60
|
+
if (entryAlias && path.normalize(entryAlias) === srcRel) entryAlias = undefined;
|
|
61
61
|
const entry = entryAlias || srcRel;
|
|
62
62
|
const resolvedEntry = entryFileNames.replaceAll("[name]", entry);
|
|
63
|
-
const emitDir = path
|
|
63
|
+
const emitDir = path.dirname(resolvedEntry);
|
|
64
64
|
const emitDtsName = resolvedEntry.replace(/\.(.)?[jt]sx?$/, (_, s$1) => `.d.${s$1 || ""}ts`);
|
|
65
|
-
const offset = path
|
|
65
|
+
const offset = path.relative(emitDir, srcDirRel);
|
|
66
66
|
for (const i of imports) {
|
|
67
67
|
const { source } = i;
|
|
68
68
|
let srcIdRel = source.value;
|
|
69
69
|
if (srcIdRel[0] !== ".") continue;
|
|
70
70
|
if (i.shouldAddIndex) srcIdRel += "/index";
|
|
71
|
-
const srcId = path
|
|
71
|
+
const srcId = path.resolve(srcDir, srcIdRel);
|
|
72
72
|
const importAlias = entryMap?.[stripExt(srcId)];
|
|
73
73
|
let id;
|
|
74
74
|
if (importAlias) {
|
|
75
75
|
const resolved = entryFileNames.replaceAll("[name]", stripExt(importAlias));
|
|
76
76
|
id = pathRelative(srcDirRel, resolved);
|
|
77
77
|
} else id = entryFileNames.replaceAll("[name]", stripExt(srcIdRel));
|
|
78
|
-
let final = path
|
|
79
|
-
if (final !== path
|
|
78
|
+
let final = path.normalize(path.join(offset, id));
|
|
79
|
+
if (final !== path.normalize(source.value)) {
|
|
80
80
|
debug("Patch import in", srcRel, ":", srcIdRel, "->", final);
|
|
81
81
|
final = final.replaceAll("\\", "/");
|
|
82
82
|
if (final.startsWith("/")) final = `.${final}`;
|
|
@@ -87,7 +87,7 @@ function rewriteImports(s, options, imports, entryMap, inputBase, entryFileNames
|
|
|
87
87
|
return emitDtsName;
|
|
88
88
|
}
|
|
89
89
|
function pathRelative(from, to) {
|
|
90
|
-
return path
|
|
90
|
+
return path.join(path.relative(from, path.dirname(to)), path.basename(to));
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
//#endregion
|
|
@@ -219,7 +219,7 @@ else {
|
|
|
219
219
|
const { entryFileNames = "[name].js", dir: outDir } = outputOptions;
|
|
220
220
|
if (typeof entryFileNames !== "string") return this.error("entryFileNames must be a string");
|
|
221
221
|
for (const [srcFilename, { s, imports, map, ext }] of Object.entries(outputFiles)) {
|
|
222
|
-
let emitName = rewriteImports(s,
|
|
222
|
+
let emitName = rewriteImports(s, imports, entryMap, inputBase, entryFileNames, srcFilename);
|
|
223
223
|
let source = s.toString();
|
|
224
224
|
if (options.patchCjsDefaultExport && emitName.endsWith(".d.cts")) source = patchCjsDefaultExport(source);
|
|
225
225
|
if (options.extraOutdir) emitName = path.join(options.extraOutdir || "", emitName);
|
|
@@ -256,7 +256,7 @@ else {
|
|
|
256
256
|
output.entryFilename = output.entryFilename.replace("[ext]", extFormatMap.get(output.format || "esm") || "js");
|
|
257
257
|
const entryFileNames = output.entryFilename;
|
|
258
258
|
for (const [srcFilename, { s, imports, map, ext }] of Object.entries(outputFiles)) {
|
|
259
|
-
let emitName = rewriteImports(s,
|
|
259
|
+
let emitName = rewriteImports(s, imports, entryMap, inputBase, entryFileNames, srcFilename);
|
|
260
260
|
let source = s.toString();
|
|
261
261
|
if (options.patchCjsDefaultExport && emitName.endsWith(".d.cts")) source = patchCjsDefaultExport(source);
|
|
262
262
|
if (options.extraOutdir) emitName = path.join(options.extraOutdir || "", emitName);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const require_transformer = require('./transformer-
|
|
2
|
+
const require_transformer = require('./transformer-DzpBM_tn.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"));
|
|
@@ -53,7 +53,7 @@ function shouldAddIndex(id, resolved) {
|
|
|
53
53
|
function filterImports(program) {
|
|
54
54
|
return program.body.filter((node) => (node.type === "ImportDeclaration" || node.type === "ExportAllDeclaration" || node.type === "ExportNamedDeclaration") && !!node.source);
|
|
55
55
|
}
|
|
56
|
-
function rewriteImports(s,
|
|
56
|
+
function rewriteImports(s, imports, entryMap, inputBase, entryFileNames, srcFilename) {
|
|
57
57
|
const srcRel = node_path.default.relative(inputBase, srcFilename);
|
|
58
58
|
const srcDir = node_path.default.dirname(srcFilename);
|
|
59
59
|
const srcDirRel = node_path.default.relative(inputBase, srcDir);
|
|
@@ -220,7 +220,7 @@ else {
|
|
|
220
220
|
const { entryFileNames = "[name].js", dir: outDir } = outputOptions;
|
|
221
221
|
if (typeof entryFileNames !== "string") return this.error("entryFileNames must be a string");
|
|
222
222
|
for (const [srcFilename, { s, imports, map, ext }] of Object.entries(outputFiles)) {
|
|
223
|
-
let emitName = rewriteImports(s,
|
|
223
|
+
let emitName = rewriteImports(s, imports, entryMap, inputBase, entryFileNames, srcFilename);
|
|
224
224
|
let source = s.toString();
|
|
225
225
|
if (options.patchCjsDefaultExport && emitName.endsWith(".d.cts")) source = patchCjsDefaultExport(source);
|
|
226
226
|
if (options.extraOutdir) emitName = node_path.default.join(options.extraOutdir || "", emitName);
|
|
@@ -257,7 +257,7 @@ else {
|
|
|
257
257
|
output.entryFilename = output.entryFilename.replace("[ext]", extFormatMap.get(output.format || "esm") || "js");
|
|
258
258
|
const entryFileNames = output.entryFilename;
|
|
259
259
|
for (const [srcFilename, { s, imports, map, ext }] of Object.entries(outputFiles)) {
|
|
260
|
-
let emitName = rewriteImports(s,
|
|
260
|
+
let emitName = rewriteImports(s, imports, entryMap, inputBase, entryFileNames, srcFilename);
|
|
261
261
|
let source = s.toString();
|
|
262
262
|
if (options.patchCjsDefaultExport && emitName.endsWith(".d.cts")) source = patchCjsDefaultExport(source);
|
|
263
263
|
if (options.extraOutdir) emitName = node_path.default.join(options.extraOutdir || "", emitName);
|
|
@@ -13,7 +13,8 @@ async function oxcTransform(id, code, sourceMap) {
|
|
|
13
13
|
const result = oxc.isolatedDeclaration(id, code, { sourcemap: sourceMap });
|
|
14
14
|
return {
|
|
15
15
|
...result,
|
|
16
|
-
map: result.map?.mappings
|
|
16
|
+
map: result.map?.mappings,
|
|
17
|
+
errors: result.errors.map((error) => error.message)
|
|
17
18
|
};
|
|
18
19
|
}
|
|
19
20
|
async function swcTransform(id, code) {
|
|
@@ -37,7 +37,8 @@ async function oxcTransform(id, code, sourceMap) {
|
|
|
37
37
|
const result = oxc.isolatedDeclaration(id, code, { sourcemap: sourceMap });
|
|
38
38
|
return {
|
|
39
39
|
...result,
|
|
40
|
-
map: result.map?.mappings
|
|
40
|
+
map: result.map?.mappings,
|
|
41
|
+
errors: result.errors.map((error) => error.message)
|
|
41
42
|
};
|
|
42
43
|
}
|
|
43
44
|
async function swcTransform(id, code) {
|
|
@@ -128,27 +129,32 @@ Object.defineProperty(exports, '__toESM', {
|
|
|
128
129
|
get: function () {
|
|
129
130
|
return __toESM;
|
|
130
131
|
}
|
|
131
|
-
});
|
|
132
|
+
});
|
|
133
|
+
Object.defineProperty(exports, 'appendMapUrl', {
|
|
132
134
|
enumerable: true,
|
|
133
135
|
get: function () {
|
|
134
136
|
return appendMapUrl;
|
|
135
137
|
}
|
|
136
|
-
});
|
|
138
|
+
});
|
|
139
|
+
Object.defineProperty(exports, 'generateDtsMap', {
|
|
137
140
|
enumerable: true,
|
|
138
141
|
get: function () {
|
|
139
142
|
return generateDtsMap;
|
|
140
143
|
}
|
|
141
|
-
});
|
|
144
|
+
});
|
|
145
|
+
Object.defineProperty(exports, 'oxcTransform', {
|
|
142
146
|
enumerable: true,
|
|
143
147
|
get: function () {
|
|
144
148
|
return oxcTransform;
|
|
145
149
|
}
|
|
146
|
-
});
|
|
150
|
+
});
|
|
151
|
+
Object.defineProperty(exports, 'swcTransform', {
|
|
147
152
|
enumerable: true,
|
|
148
153
|
get: function () {
|
|
149
154
|
return swcTransform;
|
|
150
155
|
}
|
|
151
|
-
});
|
|
156
|
+
});
|
|
157
|
+
Object.defineProperty(exports, 'tsTransform', {
|
|
152
158
|
enumerable: true,
|
|
153
159
|
get: function () {
|
|
154
160
|
return tsTransform;
|
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-DzpBM_tn.cjs');
|
|
3
|
+
const require_src = require('./src-mIY6Bwrv.cjs');
|
|
4
4
|
|
|
5
5
|
//#region src/vite.ts
|
|
6
6
|
var vite_default = require_src.IsolatedDecl.vite;
|
package/dist/vite.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unplugin-isolated-decl",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.4",
|
|
4
4
|
"description": "A blazing-fast tool for generating isolated declarations.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
},
|
|
74
74
|
"peerDependencies": {
|
|
75
75
|
"@swc/core": "^1.6.6",
|
|
76
|
-
"oxc-transform": ">=0.
|
|
76
|
+
"oxc-transform": ">=0.42.0",
|
|
77
77
|
"typescript": "^5.5.2"
|
|
78
78
|
},
|
|
79
79
|
"peerDependenciesMeta": {
|
|
@@ -88,36 +88,36 @@
|
|
|
88
88
|
}
|
|
89
89
|
},
|
|
90
90
|
"dependencies": {
|
|
91
|
-
"@rollup/pluginutils": "^5.1.
|
|
91
|
+
"@rollup/pluginutils": "^5.1.4",
|
|
92
92
|
"debug": "^4.4.0",
|
|
93
|
-
"magic-string": "^0.30.
|
|
94
|
-
"oxc-parser": "^0.
|
|
95
|
-
"unplugin": "^2.
|
|
93
|
+
"magic-string": "^0.30.17",
|
|
94
|
+
"oxc-parser": "^0.44.0",
|
|
95
|
+
"unplugin": "^2.1.0"
|
|
96
96
|
},
|
|
97
97
|
"devDependencies": {
|
|
98
|
-
"@farmfe/core": "^1.
|
|
99
|
-
"@oxc-project/types": "^0.
|
|
98
|
+
"@farmfe/core": "^1.6.2",
|
|
99
|
+
"@oxc-project/types": "^0.44.0",
|
|
100
100
|
"@rollup/plugin-alias": "^5.1.1",
|
|
101
|
-
"@swc/core": "^1.10.
|
|
101
|
+
"@swc/core": "^1.10.3",
|
|
102
102
|
"@sxzz/eslint-config": "^4.5.1",
|
|
103
103
|
"@sxzz/prettier-config": "^2.0.2",
|
|
104
|
-
"@sxzz/test-utils": "^0.3.
|
|
104
|
+
"@sxzz/test-utils": "^0.3.11",
|
|
105
105
|
"@types/debug": "^4.1.12",
|
|
106
|
-
"@types/node": "^22.10.
|
|
107
|
-
"bumpp": "^9.9.
|
|
108
|
-
"esbuild": "^0.24.
|
|
109
|
-
"eslint": "^9.
|
|
106
|
+
"@types/node": "^22.10.2",
|
|
107
|
+
"bumpp": "^9.9.2",
|
|
108
|
+
"esbuild": "^0.24.2",
|
|
109
|
+
"eslint": "^9.17.0",
|
|
110
110
|
"fast-glob": "^3.3.2",
|
|
111
|
-
"oxc-transform": "^0.
|
|
111
|
+
"oxc-transform": "^0.44.0",
|
|
112
112
|
"prettier": "^3.4.2",
|
|
113
|
-
"rolldown": "
|
|
114
|
-
"rollup": "^4.
|
|
113
|
+
"rolldown": "^1.0.0-beta.1",
|
|
114
|
+
"rollup": "^4.29.1",
|
|
115
115
|
"rollup-plugin-esbuild": "^6.1.1",
|
|
116
116
|
"tinyglobby": "^0.2.10",
|
|
117
|
-
"tsdown": "^0.
|
|
117
|
+
"tsdown": "^0.5.3",
|
|
118
118
|
"tsx": "^4.19.2",
|
|
119
119
|
"typescript": "^5.7.2",
|
|
120
|
-
"vite": "^6.0.
|
|
120
|
+
"vite": "^6.0.6",
|
|
121
121
|
"vitest": "^2.1.8"
|
|
122
122
|
},
|
|
123
123
|
"engines": {
|