unplugin-isolated-decl 0.8.0 → 0.8.2
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/core/ast.d.cts +1 -1
- package/dist/core/ast.d.ts +1 -1
- package/dist/core/utils.d.cts +1 -0
- package/dist/core/utils.d.ts +1 -0
- package/dist/esbuild.cjs +1 -1
- package/dist/esbuild.js +1 -1
- package/dist/farm.cjs +1 -1
- package/dist/farm.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/rolldown.cjs +1 -1
- package/dist/rolldown.js +1 -1
- package/dist/rollup.cjs +1 -1
- package/dist/rollup.js +1 -1
- package/dist/{src-BpqQm19o.cjs → src-CUBv8HDT.cjs} +16 -12
- package/dist/{src-CLCa83Ij.js → src-DF97Tiay.js} +16 -12
- package/dist/vite.cjs +1 -1
- package/dist/vite.js +1 -1
- package/package.json +1 -1
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
|
+
ext?: 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
|
+
ext?: 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/utils.d.cts
CHANGED
package/dist/core/utils.d.ts
CHANGED
package/dist/esbuild.cjs
CHANGED
package/dist/esbuild.js
CHANGED
package/dist/farm.cjs
CHANGED
package/dist/farm.js
CHANGED
package/dist/index.cjs
CHANGED
package/dist/index.js
CHANGED
package/dist/rolldown.cjs
CHANGED
package/dist/rolldown.js
CHANGED
package/dist/rollup.cjs
CHANGED
package/dist/rollup.js
CHANGED
|
@@ -64,6 +64,10 @@ function resolveEntry(input) {
|
|
|
64
64
|
inputBase
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
|
+
function guessExt(filename) {
|
|
68
|
+
const ext = node_path.default.extname(filename).slice(1);
|
|
69
|
+
return ext.replace(/^([cm]?)ts/, (_, $1) => `${$1}js`);
|
|
70
|
+
}
|
|
67
71
|
|
|
68
72
|
//#endregion
|
|
69
73
|
//#region src/core/ast.ts
|
|
@@ -83,7 +87,7 @@ function rewriteImports(s, imports, entryMap, inputBase, entryFileNames, srcFile
|
|
|
83
87
|
const offset = node_path.default.relative(emitDir, srcDirRel);
|
|
84
88
|
for (const i of imports) {
|
|
85
89
|
const { source } = i;
|
|
86
|
-
const
|
|
90
|
+
const srcIdRel = stripExt(source.value);
|
|
87
91
|
if (srcIdRel[0] !== ".") continue;
|
|
88
92
|
const srcId = node_path.default.resolve(srcDir, srcIdRel);
|
|
89
93
|
const importAlias = entryMap?.[srcId];
|
|
@@ -92,9 +96,10 @@ function rewriteImports(s, imports, entryMap, inputBase, entryFileNames, srcFile
|
|
|
92
96
|
const resolved = stripExt(entryFileNames.replaceAll("[name]", importAlias));
|
|
93
97
|
id = pathRelative(srcDirRel, resolved);
|
|
94
98
|
} else id = stripExt(entryFileNames.replaceAll("[name]", srcIdRel));
|
|
95
|
-
|
|
99
|
+
const ext = i.ext || guessExt(source.value);
|
|
100
|
+
if (ext) id += `.${ext}`;
|
|
96
101
|
let final = node_path.default.normalize(node_path.default.join(offset, id));
|
|
97
|
-
if (final !== source.value) {
|
|
102
|
+
if (final !== node_path.default.normalize(source.value)) {
|
|
98
103
|
debug$1("Patch import in", srcRel, ":", srcIdRel, "->", final);
|
|
99
104
|
final = final.replaceAll("\\", "/");
|
|
100
105
|
if (!/^\.\.?\//.test(final)) final = `./${final}`;
|
|
@@ -181,19 +186,19 @@ else {
|
|
|
181
186
|
const s = new magic_string.default(dts);
|
|
182
187
|
if (options.autoAddExts || options.rewriteImports) for (const i of imports) {
|
|
183
188
|
const { source } = i;
|
|
184
|
-
|
|
185
|
-
if (options.autoAddExts && (node_path.default.isAbsolute(value) || value[0] === ".") && !node_path.default.basename(value).includes(".")) {
|
|
186
|
-
const resolved = await resolve(context, value, id);
|
|
187
|
-
if (!resolved || resolved.external) continue;
|
|
188
|
-
if (resolved.id.endsWith(".ts") || resolved.id.endsWith(".tsx")) i.suffix = ".js";
|
|
189
|
-
}
|
|
189
|
+
let { value } = source;
|
|
190
190
|
if (options.rewriteImports) {
|
|
191
191
|
const result$1 = options.rewriteImports(value, id);
|
|
192
192
|
if (typeof result$1 === "string") {
|
|
193
|
-
source.value = result$1;
|
|
193
|
+
source.value = value = result$1;
|
|
194
194
|
s.overwrite(source.start + 1, source.end - 1, result$1);
|
|
195
195
|
}
|
|
196
196
|
}
|
|
197
|
+
if (options.autoAddExts && (node_path.default.isAbsolute(value) || value[0] === ".")) {
|
|
198
|
+
const resolved = await resolve(context, value, stripExt(id));
|
|
199
|
+
if (!resolved || resolved.external) continue;
|
|
200
|
+
i.ext = guessExt(resolved.id);
|
|
201
|
+
}
|
|
197
202
|
}
|
|
198
203
|
addOutput(id, {
|
|
199
204
|
s,
|
|
@@ -206,8 +211,7 @@ else {
|
|
|
206
211
|
if (node.type === "ImportDeclaration") return !!node.specifiers && node.specifiers.every((spec) => spec.type === "ImportSpecifier" && spec.importKind === "type");
|
|
207
212
|
return node.type === "ExportNamedDeclaration" && node.specifiers && node.specifiers.every((spec) => spec.exportKind === "type");
|
|
208
213
|
});
|
|
209
|
-
for (const
|
|
210
|
-
const { source } = i;
|
|
214
|
+
for (const { source } of typeImports) {
|
|
211
215
|
const resolved = (await resolve(context, source.value, id))?.id;
|
|
212
216
|
if (resolved && filter(resolved) && !outputFiles[stripExt(resolved)]) {
|
|
213
217
|
let source$1;
|
|
@@ -40,6 +40,10 @@ function resolveEntry(input) {
|
|
|
40
40
|
inputBase
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
|
+
function guessExt(filename) {
|
|
44
|
+
const ext = path$2.extname(filename).slice(1);
|
|
45
|
+
return ext.replace(/^([cm]?)ts/, (_, $1) => `${$1}js`);
|
|
46
|
+
}
|
|
43
47
|
|
|
44
48
|
//#endregion
|
|
45
49
|
//#region src/core/ast.ts
|
|
@@ -59,7 +63,7 @@ function rewriteImports(s, imports, entryMap, inputBase, entryFileNames, srcFile
|
|
|
59
63
|
const offset = path$1.relative(emitDir, srcDirRel);
|
|
60
64
|
for (const i of imports) {
|
|
61
65
|
const { source } = i;
|
|
62
|
-
const
|
|
66
|
+
const srcIdRel = stripExt(source.value);
|
|
63
67
|
if (srcIdRel[0] !== ".") continue;
|
|
64
68
|
const srcId = path$1.resolve(srcDir, srcIdRel);
|
|
65
69
|
const importAlias = entryMap?.[srcId];
|
|
@@ -68,9 +72,10 @@ function rewriteImports(s, imports, entryMap, inputBase, entryFileNames, srcFile
|
|
|
68
72
|
const resolved = stripExt(entryFileNames.replaceAll("[name]", importAlias));
|
|
69
73
|
id = pathRelative(srcDirRel, resolved);
|
|
70
74
|
} else id = stripExt(entryFileNames.replaceAll("[name]", srcIdRel));
|
|
71
|
-
|
|
75
|
+
const ext = i.ext || guessExt(source.value);
|
|
76
|
+
if (ext) id += `.${ext}`;
|
|
72
77
|
let final = path$1.normalize(path$1.join(offset, id));
|
|
73
|
-
if (final !== source.value) {
|
|
78
|
+
if (final !== path$1.normalize(source.value)) {
|
|
74
79
|
debug("Patch import in", srcRel, ":", srcIdRel, "->", final);
|
|
75
80
|
final = final.replaceAll("\\", "/");
|
|
76
81
|
if (!/^\.\.?\//.test(final)) final = `./${final}`;
|
|
@@ -157,19 +162,19 @@ else {
|
|
|
157
162
|
const s = new MagicString(dts);
|
|
158
163
|
if (options.autoAddExts || options.rewriteImports) for (const i of imports) {
|
|
159
164
|
const { source } = i;
|
|
160
|
-
|
|
161
|
-
if (options.autoAddExts && (path.isAbsolute(value) || value[0] === ".") && !path.basename(value).includes(".")) {
|
|
162
|
-
const resolved = await resolve(context, value, id);
|
|
163
|
-
if (!resolved || resolved.external) continue;
|
|
164
|
-
if (resolved.id.endsWith(".ts") || resolved.id.endsWith(".tsx")) i.suffix = ".js";
|
|
165
|
-
}
|
|
165
|
+
let { value } = source;
|
|
166
166
|
if (options.rewriteImports) {
|
|
167
167
|
const result$1 = options.rewriteImports(value, id);
|
|
168
168
|
if (typeof result$1 === "string") {
|
|
169
|
-
source.value = result$1;
|
|
169
|
+
source.value = value = result$1;
|
|
170
170
|
s.overwrite(source.start + 1, source.end - 1, result$1);
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
|
+
if (options.autoAddExts && (path.isAbsolute(value) || value[0] === ".")) {
|
|
174
|
+
const resolved = await resolve(context, value, stripExt(id));
|
|
175
|
+
if (!resolved || resolved.external) continue;
|
|
176
|
+
i.ext = guessExt(resolved.id);
|
|
177
|
+
}
|
|
173
178
|
}
|
|
174
179
|
addOutput(id, {
|
|
175
180
|
s,
|
|
@@ -182,8 +187,7 @@ else {
|
|
|
182
187
|
if (node.type === "ImportDeclaration") return !!node.specifiers && node.specifiers.every((spec) => spec.type === "ImportSpecifier" && spec.importKind === "type");
|
|
183
188
|
return node.type === "ExportNamedDeclaration" && node.specifiers && node.specifiers.every((spec) => spec.exportKind === "type");
|
|
184
189
|
});
|
|
185
|
-
for (const
|
|
186
|
-
const { source } = i;
|
|
190
|
+
for (const { source } of typeImports) {
|
|
187
191
|
const resolved = (await resolve(context, source.value, id))?.id;
|
|
188
192
|
if (resolved && filter(resolved) && !outputFiles[stripExt(resolved)]) {
|
|
189
193
|
let source$1;
|
package/dist/vite.cjs
CHANGED
package/dist/vite.js
CHANGED