unplugin-isolated-decl 0.6.5 → 0.6.7
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/README.md +12 -7
- package/dist/api.cjs +3 -18
- package/dist/esbuild.cjs +1 -1
- package/dist/esbuild.js +1 -1
- package/dist/index.cjs +3 -13
- 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_index-yD9cu-PW.js → src_index-jESannmB.js} +11 -3
- package/dist/{src_index-BzyMNf8g.cjs → src_index-tVPRzUWA.cjs} +11 -3
- package/dist/vite.cjs +1 -1
- package/dist/vite.js +1 -1
- package/package.json +18 -18
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://github.com/unplugin/unplugin-isolated-decl/actions/workflows/unit-test.yml)
|
|
4
4
|
|
|
5
|
-
⚡️ A blazing-fast tool for generating isolated declarations
|
|
5
|
+
⚡️ A blazing-fast tool for generating isolated declarations.
|
|
6
6
|
|
|
7
7
|
## Features
|
|
8
8
|
|
|
@@ -83,8 +83,8 @@ export interface Options {
|
|
|
83
83
|
exclude?: FilterPattern
|
|
84
84
|
enforce?: 'pre' | 'post' | undefined
|
|
85
85
|
/**
|
|
86
|
-
*
|
|
87
|
-
* @default
|
|
86
|
+
* You need to install one of the supported transformers yourself.
|
|
87
|
+
* @default typescript
|
|
88
88
|
*/
|
|
89
89
|
transformer?: 'oxc' | 'swc' | 'typescript'
|
|
90
90
|
/** Only for typescript transformer */
|
|
@@ -114,6 +114,15 @@ With `autoAddExts`, it will be transformed to:
|
|
|
114
114
|
import {} from './foo.js'
|
|
115
115
|
```
|
|
116
116
|
|
|
117
|
+
### `patchCjsDefaultExport`
|
|
118
|
+
|
|
119
|
+
Patch `export default` in `.d.cts` to `export =`
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
> [!NOTE]
|
|
124
|
+
> For the exhaustive set of options check [options](src/core/options.ts)
|
|
125
|
+
|
|
117
126
|
## Sponsors
|
|
118
127
|
|
|
119
128
|
<p align="center">
|
|
@@ -125,7 +134,3 @@ import {} from './foo.js'
|
|
|
125
134
|
## License
|
|
126
135
|
|
|
127
136
|
[MIT](./LICENSE) License © 2024-PRESENT [三咲智子](https://github.com/sxzz)
|
|
128
|
-
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
```
|
package/dist/api.cjs
CHANGED
|
@@ -1,21 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const require_transformer = require('./transformer-9aaNC01N.cjs');
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return require_transformer.oxcTransform;
|
|
8
|
-
}
|
|
9
|
-
});
|
|
10
|
-
Object.defineProperty(exports, 'swcTransform', {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function () {
|
|
13
|
-
return require_transformer.swcTransform;
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
Object.defineProperty(exports, 'tsTransform', {
|
|
17
|
-
enumerable: true,
|
|
18
|
-
get: function () {
|
|
19
|
-
return require_transformer.tsTransform;
|
|
20
|
-
}
|
|
21
|
-
});
|
|
4
|
+
exports.oxcTransform = require_transformer.oxcTransform
|
|
5
|
+
exports.swcTransform = require_transformer.swcTransform
|
|
6
|
+
exports.tsTransform = require_transformer.tsTransform
|
package/dist/esbuild.cjs
CHANGED
package/dist/esbuild.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1,16 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const require_src_index = require('./src_index-
|
|
2
|
+
const require_src_index = require('./src_index-tVPRzUWA.cjs');
|
|
3
3
|
require('./transformer-9aaNC01N.cjs');
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
get: function () {
|
|
8
|
-
return require_src_index.IsolatedDecl;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
Object.defineProperty(exports, 'lowestCommonAncestor', {
|
|
12
|
-
enumerable: true,
|
|
13
|
-
get: function () {
|
|
14
|
-
return require_src_index.lowestCommonAncestor;
|
|
15
|
-
}
|
|
16
|
-
});
|
|
5
|
+
exports.IsolatedDecl = require_src_index.IsolatedDecl
|
|
6
|
+
exports.lowestCommonAncestor = require_src_index.lowestCommonAncestor
|
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
|
@@ -31,7 +31,8 @@ const IsolatedDecl = createUnplugin((rawOptions = {}) => {
|
|
|
31
31
|
}
|
|
32
32
|
const rollup = { renderStart(outputOptions, inputOptions) {
|
|
33
33
|
const { input } = inputOptions;
|
|
34
|
-
const
|
|
34
|
+
const inputMap = !Array.isArray(input) ? Object.fromEntries(Object.entries(input).map(([k, v]) => [path.resolve(stripExt(v)), k])) : undefined;
|
|
35
|
+
const normalizedInput = Array.isArray(input) ? input : Object.values(input);
|
|
35
36
|
const outBase = lowestCommonAncestor(...normalizedInput);
|
|
36
37
|
if (typeof outputOptions.entryFileNames !== "string") {
|
|
37
38
|
return this.error("entryFileNames must be a string");
|
|
@@ -41,7 +42,8 @@ const IsolatedDecl = createUnplugin((rawOptions = {}) => {
|
|
|
41
42
|
entryFileNames = path.join(options.extraOutdir, entryFileNames);
|
|
42
43
|
}
|
|
43
44
|
for (let [outname, source] of Object.entries(outputFiles)) {
|
|
44
|
-
const
|
|
45
|
+
const name = inputMap?.[outname] || path.relative(outBase, outname);
|
|
46
|
+
const fileName = entryFileNames.replace("[name]", name);
|
|
45
47
|
if (options.patchCjsDefaultExport && fileName.endsWith(".d.cts")) {
|
|
46
48
|
source = patchCjsDefaultExport(source);
|
|
47
49
|
}
|
|
@@ -84,7 +86,13 @@ const IsolatedDecl = createUnplugin((rawOptions = {}) => {
|
|
|
84
86
|
const resolved = await resolve(context, i.source.value, id);
|
|
85
87
|
if (!resolved || resolved.external) continue;
|
|
86
88
|
if (resolved.id.endsWith(".ts") || resolved.id.endsWith(".tsx")) {
|
|
87
|
-
s.overwrite(
|
|
89
|
+
s.overwrite(
|
|
90
|
+
// @ts-expect-error
|
|
91
|
+
i.source.start,
|
|
92
|
+
// @ts-expect-error
|
|
93
|
+
i.source.end,
|
|
94
|
+
JSON.stringify(`${i.source.value}.js`)
|
|
95
|
+
);
|
|
88
96
|
}
|
|
89
97
|
}
|
|
90
98
|
code = s.toString();
|
|
@@ -55,7 +55,8 @@ const IsolatedDecl = createUnplugin((rawOptions = {}) => {
|
|
|
55
55
|
}
|
|
56
56
|
const rollup = { renderStart(outputOptions, inputOptions) {
|
|
57
57
|
const { input } = inputOptions;
|
|
58
|
-
const
|
|
58
|
+
const inputMap = !Array.isArray(input) ? Object.fromEntries(Object.entries(input).map(([k, v]) => [path.resolve(stripExt(v)), k])) : undefined;
|
|
59
|
+
const normalizedInput = Array.isArray(input) ? input : Object.values(input);
|
|
59
60
|
const outBase = lowestCommonAncestor(...normalizedInput);
|
|
60
61
|
if (typeof outputOptions.entryFileNames !== "string") {
|
|
61
62
|
return this.error("entryFileNames must be a string");
|
|
@@ -65,7 +66,8 @@ const IsolatedDecl = createUnplugin((rawOptions = {}) => {
|
|
|
65
66
|
entryFileNames = path.join(options.extraOutdir, entryFileNames);
|
|
66
67
|
}
|
|
67
68
|
for (let [outname, source] of Object.entries(outputFiles)) {
|
|
68
|
-
const
|
|
69
|
+
const name = inputMap?.[outname] || path.relative(outBase, outname);
|
|
70
|
+
const fileName = entryFileNames.replace("[name]", name);
|
|
69
71
|
if (options.patchCjsDefaultExport && fileName.endsWith(".d.cts")) {
|
|
70
72
|
source = patchCjsDefaultExport(source);
|
|
71
73
|
}
|
|
@@ -108,7 +110,13 @@ const IsolatedDecl = createUnplugin((rawOptions = {}) => {
|
|
|
108
110
|
const resolved = await resolve(context, i.source.value, id);
|
|
109
111
|
if (!resolved || resolved.external) continue;
|
|
110
112
|
if (resolved.id.endsWith(".ts") || resolved.id.endsWith(".tsx")) {
|
|
111
|
-
s.overwrite(
|
|
113
|
+
s.overwrite(
|
|
114
|
+
// @ts-expect-error
|
|
115
|
+
i.source.start,
|
|
116
|
+
// @ts-expect-error
|
|
117
|
+
i.source.end,
|
|
118
|
+
JSON.stringify(`${i.source.value}.js`)
|
|
119
|
+
);
|
|
112
120
|
}
|
|
113
121
|
}
|
|
114
122
|
code = s.toString();
|
package/dist/vite.cjs
CHANGED
package/dist/vite.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unplugin-isolated-decl",
|
|
3
|
-
"version": "0.6.
|
|
4
|
-
"description": "A blazing-fast tool for generating isolated declarations
|
|
3
|
+
"version": "0.6.7",
|
|
4
|
+
"description": "A blazing-fast tool for generating isolated declarations.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"unplugin",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
},
|
|
70
70
|
"peerDependencies": {
|
|
71
71
|
"@swc/core": "^1.6.6",
|
|
72
|
-
"oxc-transform": "
|
|
72
|
+
"oxc-transform": ">=0.28.0",
|
|
73
73
|
"typescript": "^5.5.2"
|
|
74
74
|
},
|
|
75
75
|
"peerDependenciesMeta": {
|
|
@@ -84,31 +84,31 @@
|
|
|
84
84
|
}
|
|
85
85
|
},
|
|
86
86
|
"dependencies": {
|
|
87
|
-
"@rollup/pluginutils": "^5.1.
|
|
88
|
-
"magic-string": "^0.30.
|
|
89
|
-
"oxc-parser": "^0.
|
|
87
|
+
"@rollup/pluginutils": "^5.1.2",
|
|
88
|
+
"magic-string": "^0.30.12",
|
|
89
|
+
"oxc-parser": "^0.31.0",
|
|
90
90
|
"unplugin": "^1.14.1"
|
|
91
91
|
},
|
|
92
92
|
"devDependencies": {
|
|
93
|
-
"@swc/core": "^1.7.
|
|
94
|
-
"@sxzz/eslint-config": "^4.
|
|
93
|
+
"@swc/core": "^1.7.35",
|
|
94
|
+
"@sxzz/eslint-config": "^4.4.0",
|
|
95
95
|
"@sxzz/prettier-config": "^2.0.2",
|
|
96
|
-
"@types/node": "^22.
|
|
97
|
-
"@typescript-eslint/typescript-estree": "^8.
|
|
98
|
-
"bumpp": "^9.
|
|
96
|
+
"@types/node": "^22.7.5",
|
|
97
|
+
"@typescript-eslint/typescript-estree": "^8.8.1",
|
|
98
|
+
"bumpp": "^9.7.1",
|
|
99
99
|
"esbuild": "^0.24.0",
|
|
100
|
-
"eslint": "^9.
|
|
100
|
+
"eslint": "^9.12.0",
|
|
101
101
|
"fast-glob": "^3.3.2",
|
|
102
|
-
"oxc-transform": "^0.
|
|
102
|
+
"oxc-transform": "^0.31.0",
|
|
103
103
|
"prettier": "^3.3.3",
|
|
104
104
|
"rolldown": "nightly",
|
|
105
|
-
"rollup": "^4.
|
|
105
|
+
"rollup": "^4.24.0",
|
|
106
106
|
"rollup-plugin-esbuild": "^6.1.1",
|
|
107
|
-
"tsdown": "^0.2.
|
|
107
|
+
"tsdown": "^0.2.17",
|
|
108
108
|
"tsx": "^4.19.1",
|
|
109
|
-
"typescript": "^5.6.
|
|
110
|
-
"vite": "^5.4.
|
|
111
|
-
"vitest": "^2.1.
|
|
109
|
+
"typescript": "^5.6.3",
|
|
110
|
+
"vite": "^5.4.9",
|
|
111
|
+
"vitest": "^2.1.3"
|
|
112
112
|
},
|
|
113
113
|
"engines": {
|
|
114
114
|
"node": ">=18.12.0"
|