unplugin-isolated-decl 0.6.8 → 0.7.1
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 +20 -2
- package/dist/api.cjs +1 -1
- package/dist/api.d.cts +1 -1
- package/dist/api.d.ts +1 -1
- package/dist/api.js +1 -1
- package/dist/core/ast.d.cts +7 -0
- package/dist/core/ast.d.ts +7 -0
- package/dist/core/options.d.cts +3 -0
- package/dist/core/options.d.ts +3 -0
- package/dist/core/transformer.d.cts +9 -0
- package/dist/core/transformer.d.ts +9 -0
- package/dist/core/utils.d.cts +8 -0
- package/dist/core/utils.d.ts +8 -0
- package/dist/esbuild.cjs +3 -3
- package/dist/esbuild.d.cts +18 -1
- package/dist/esbuild.d.ts +18 -1
- package/dist/esbuild.js +2 -2
- package/dist/farm.cjs +9 -0
- package/dist/farm.d.cts +21 -0
- package/dist/farm.d.ts +21 -0
- package/dist/farm.js +8 -0
- package/dist/index.cjs +3 -4
- package/dist/index.d.cts +8 -2
- package/dist/index.d.ts +8 -2
- package/dist/index.js +3 -3
- package/dist/rolldown.cjs +3 -3
- package/dist/rolldown.d.cts +19 -1
- package/dist/rolldown.d.ts +19 -1
- package/dist/rolldown.js +2 -2
- package/dist/rollup.cjs +3 -3
- package/dist/rollup.d.cts +19 -1
- package/dist/rollup.d.ts +19 -1
- package/dist/rollup.js +2 -2
- package/dist/{src_index-2WEAOr05.js → src-BatylriB.js} +194 -90
- package/dist/{src_index-NKcZyc90.cjs → src-lcwrBdQD.cjs} +193 -94
- package/dist/vite.cjs +3 -3
- package/dist/vite.d.cts +19 -1
- package/dist/vite.d.ts +19 -1
- package/dist/vite.js +2 -2
- package/package.json +21 -14
- /package/dist/{transformer-uKy0L3Za.cjs → transformer-C4rLQvdl.cjs} +0 -0
- /package/dist/{transformer-w7XvOpWe.js → transformer-DDte86lZ.js} +0 -0
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# unplugin-isolated-decl [](https://npmjs.com/package/unplugin-isolated-decl)
|
|
1
|
+
# unplugin-isolated-decl [](https://npmjs.com/package/unplugin-isolated-decl) [](https://jsr.io/@unplugin/isolated-decl)
|
|
2
2
|
|
|
3
3
|
[](https://github.com/unplugin/unplugin-isolated-decl/actions/workflows/unit-test.yml)
|
|
4
4
|
|
|
@@ -9,12 +9,16 @@
|
|
|
9
9
|
- 🚀 **Fast**: Generates `.d.ts` files significantly faster than `tsc`.
|
|
10
10
|
- 🎨 **Transformer**: Support Oxc, SWC, and TypeScript transformer.
|
|
11
11
|
- 📦 **Zero Config**: No configuration required, works out of the box.
|
|
12
|
-
- ✨ **Bundler Support**: Works with Vite, Rollup, and
|
|
12
|
+
- ✨ **Bundler Support**: Works with Vite, Rollup, esbuild and Farm. (PR of Webpack/Rspack support is welcome)
|
|
13
13
|
|
|
14
14
|
## Installation
|
|
15
15
|
|
|
16
16
|
```bash
|
|
17
|
+
# npm
|
|
17
18
|
npm i -D unplugin-isolated-decl
|
|
19
|
+
|
|
20
|
+
# jsr
|
|
21
|
+
npx jsr add -D @unplugin/isolated-decl
|
|
18
22
|
```
|
|
19
23
|
|
|
20
24
|
## Usage
|
|
@@ -75,6 +79,20 @@ build({
|
|
|
75
79
|
|
|
76
80
|
<br></details>
|
|
77
81
|
|
|
82
|
+
<details>
|
|
83
|
+
<summary>Farm</summary><br>
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
// farm.config.ts
|
|
87
|
+
import UnpluginIsolatedDecl from 'unplugin-isolated-decl/farm'
|
|
88
|
+
|
|
89
|
+
export default defineConfig({
|
|
90
|
+
plugins: [UnpluginIsolatedDecl()],
|
|
91
|
+
})
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
<br></details>
|
|
95
|
+
|
|
78
96
|
## Options
|
|
79
97
|
|
|
80
98
|
```ts
|
package/dist/api.cjs
CHANGED
package/dist/api.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { oxcTransform, swcTransform, tsTransform } from
|
|
1
|
+
export { oxcTransform, swcTransform, tsTransform } from './core/transformer.js';
|
package/dist/api.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { oxcTransform, swcTransform, tsTransform } from
|
|
1
|
+
export { oxcTransform, swcTransform, tsTransform } from './core/transformer.js';
|
package/dist/api.js
CHANGED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import MagicString from 'magic-string';
|
|
2
|
+
import type * as OxcTypes from '@oxc-project/types';
|
|
3
|
+
export type OxcImport = (OxcTypes.ImportDeclaration | OxcTypes.ExportAllDeclaration | OxcTypes.ExportNamedDeclaration) & {
|
|
4
|
+
source: OxcTypes.StringLiteral;
|
|
5
|
+
};
|
|
6
|
+
export declare function filterImports(program: OxcTypes.Program): OxcImport[];
|
|
7
|
+
export declare function patchEntryAlias(source: string, s: MagicString | undefined, imports: OxcImport[], outname: string, offset: string): string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import MagicString from 'magic-string';
|
|
2
|
+
import type * as OxcTypes from '@oxc-project/types';
|
|
3
|
+
export type OxcImport = (OxcTypes.ImportDeclaration | OxcTypes.ExportAllDeclaration | OxcTypes.ExportNamedDeclaration) & {
|
|
4
|
+
source: OxcTypes.StringLiteral;
|
|
5
|
+
};
|
|
6
|
+
export declare function filterImports(program: OxcTypes.Program): OxcImport[];
|
|
7
|
+
export declare function patchEntryAlias(source: string, s: MagicString | undefined, imports: OxcImport[], outname: string, offset: string): string;
|
package/dist/core/options.d.cts
CHANGED
package/dist/core/options.d.ts
CHANGED
|
@@ -3,6 +3,15 @@ export interface TransformResult {
|
|
|
3
3
|
code: string;
|
|
4
4
|
errors: Array<string>;
|
|
5
5
|
}
|
|
6
|
+
/**
|
|
7
|
+
* Transform isolated declarations with `oxc-transform`.
|
|
8
|
+
*/
|
|
6
9
|
export declare function oxcTransform(id: string, code: string): Promise<TransformResult>;
|
|
10
|
+
/**
|
|
11
|
+
* Transform isolated declarations with `@swc/core`.
|
|
12
|
+
*/
|
|
7
13
|
export declare function swcTransform(id: string, code: string): Promise<TransformResult>;
|
|
14
|
+
/**
|
|
15
|
+
* Transform isolated declarations with `typescript`.
|
|
16
|
+
*/
|
|
8
17
|
export declare function tsTransform(id: string, code: string, transformOptions?: TranspileOptions): Promise<TransformResult>;
|
|
@@ -3,6 +3,15 @@ export interface TransformResult {
|
|
|
3
3
|
code: string;
|
|
4
4
|
errors: Array<string>;
|
|
5
5
|
}
|
|
6
|
+
/**
|
|
7
|
+
* Transform isolated declarations with `oxc-transform`.
|
|
8
|
+
*/
|
|
6
9
|
export declare function oxcTransform(id: string, code: string): Promise<TransformResult>;
|
|
10
|
+
/**
|
|
11
|
+
* Transform isolated declarations with `@swc/core`.
|
|
12
|
+
*/
|
|
7
13
|
export declare function swcTransform(id: string, code: string): Promise<TransformResult>;
|
|
14
|
+
/**
|
|
15
|
+
* Transform isolated declarations with `typescript`.
|
|
16
|
+
*/
|
|
8
17
|
export declare function tsTransform(id: string, code: string, transformOptions?: TranspileOptions): Promise<TransformResult>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import Debug from 'debug';
|
|
2
|
+
export declare const debug: Debug.Debugger;
|
|
3
|
+
export declare function lowestCommonAncestor(...filepaths: string[]): string;
|
|
4
|
+
export declare function stripExt(filename: string): string;
|
|
5
|
+
export declare function resolveEntry(input: string[] | Record<string, string>): {
|
|
6
|
+
map: Record<string, string> | undefined;
|
|
7
|
+
outBase: string;
|
|
8
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import Debug from 'debug';
|
|
2
|
+
export declare const debug: Debug.Debugger;
|
|
3
|
+
export declare function lowestCommonAncestor(...filepaths: string[]): string;
|
|
4
|
+
export declare function stripExt(filename: string): string;
|
|
5
|
+
export declare function resolveEntry(input: string[] | Record<string, string>): {
|
|
6
|
+
map: Record<string, string> | undefined;
|
|
7
|
+
outBase: string;
|
|
8
|
+
};
|
package/dist/esbuild.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const
|
|
3
|
-
require('./transformer-
|
|
2
|
+
const require_src = require('./src-lcwrBdQD.cjs');
|
|
3
|
+
require('./transformer-C4rLQvdl.cjs');
|
|
4
4
|
|
|
5
5
|
//#region src/esbuild.ts
|
|
6
|
-
var esbuild_default =
|
|
6
|
+
var esbuild_default = require_src.IsolatedDecl.esbuild;
|
|
7
7
|
|
|
8
8
|
//#endregion
|
|
9
9
|
module.exports = esbuild_default;
|
package/dist/esbuild.d.cts
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* This entry file is for esbuild plugin.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { IsolatedDecl } from './index.js';
|
|
7
|
+
/**
|
|
8
|
+
* Esbuild plugin
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { build } from 'esbuild'
|
|
13
|
+
*
|
|
14
|
+
* build({
|
|
15
|
+
* plugins: [require('unplugin-isolated-decl/esbuild')()],
|
|
16
|
+
* })
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
2
19
|
declare const _default: typeof IsolatedDecl.esbuild;
|
|
3
20
|
export = _default;
|
package/dist/esbuild.d.ts
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* This entry file is for esbuild plugin.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { IsolatedDecl } from './index.js';
|
|
7
|
+
/**
|
|
8
|
+
* Esbuild plugin
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { build } from 'esbuild'
|
|
13
|
+
*
|
|
14
|
+
* build({
|
|
15
|
+
* plugins: [require('unplugin-isolated-decl/esbuild')()],
|
|
16
|
+
* })
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
2
19
|
declare const _default: typeof IsolatedDecl.esbuild;
|
|
3
20
|
export default _default;
|
package/dist/esbuild.js
CHANGED
package/dist/farm.cjs
ADDED
package/dist/farm.d.cts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This entry file is for Farm plugin.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { IsolatedDecl } from './index.js';
|
|
7
|
+
/**
|
|
8
|
+
* Farm plugin
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* // farm.config.js
|
|
13
|
+
* import IsolatedDecl from 'unplugin-isolated-decl/farm'
|
|
14
|
+
*
|
|
15
|
+
* export default {
|
|
16
|
+
* plugins: [IsolatedDecl()],
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
declare const _default: typeof IsolatedDecl.farm;
|
|
21
|
+
export = _default;
|
package/dist/farm.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This entry file is for Farm plugin.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { IsolatedDecl } from './index.js';
|
|
7
|
+
/**
|
|
8
|
+
* Farm plugin
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* // farm.config.js
|
|
13
|
+
* import IsolatedDecl from 'unplugin-isolated-decl/farm'
|
|
14
|
+
*
|
|
15
|
+
* export default {
|
|
16
|
+
* plugins: [IsolatedDecl()],
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
declare const _default: typeof IsolatedDecl.farm;
|
|
21
|
+
export default _default;
|
package/dist/farm.js
ADDED
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const
|
|
3
|
-
require('./transformer-
|
|
2
|
+
const require_src = require('./src-lcwrBdQD.cjs');
|
|
3
|
+
require('./transformer-C4rLQvdl.cjs');
|
|
4
4
|
|
|
5
|
-
exports.IsolatedDecl =
|
|
6
|
-
exports.lowestCommonAncestor = require_src_index.lowestCommonAncestor
|
|
5
|
+
exports.IsolatedDecl = require_src.IsolatedDecl
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This entry file is for main unplugin.
|
|
3
|
+
* @module
|
|
4
|
+
*/
|
|
1
5
|
import { type UnpluginInstance } from 'unplugin';
|
|
2
|
-
import { type Options } from
|
|
6
|
+
import { type Options } from './core/options.js';
|
|
3
7
|
export type { Options };
|
|
8
|
+
/**
|
|
9
|
+
* The main unplugin instance.
|
|
10
|
+
*/
|
|
4
11
|
export declare const IsolatedDecl: UnpluginInstance<Options | undefined, false>;
|
|
5
|
-
export declare function lowestCommonAncestor(...filepaths: string[]): string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This entry file is for main unplugin.
|
|
3
|
+
* @module
|
|
4
|
+
*/
|
|
1
5
|
import { type UnpluginInstance } from 'unplugin';
|
|
2
|
-
import { type Options } from
|
|
6
|
+
import { type Options } from './core/options.js';
|
|
3
7
|
export type { Options };
|
|
8
|
+
/**
|
|
9
|
+
* The main unplugin instance.
|
|
10
|
+
*/
|
|
4
11
|
export declare const IsolatedDecl: UnpluginInstance<Options | undefined, false>;
|
|
5
|
-
export declare function lowestCommonAncestor(...filepaths: string[]): string;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./transformer-
|
|
2
|
-
import { IsolatedDecl
|
|
1
|
+
import "./transformer-DDte86lZ.js";
|
|
2
|
+
import { IsolatedDecl } from "./src-BatylriB.js";
|
|
3
3
|
|
|
4
|
-
export { IsolatedDecl
|
|
4
|
+
export { IsolatedDecl };
|
package/dist/rolldown.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const
|
|
3
|
-
require('./transformer-
|
|
2
|
+
const require_src = require('./src-lcwrBdQD.cjs');
|
|
3
|
+
require('./transformer-C4rLQvdl.cjs');
|
|
4
4
|
|
|
5
5
|
//#region src/rolldown.ts
|
|
6
|
-
var rolldown_default =
|
|
6
|
+
var rolldown_default = require_src.IsolatedDecl.rolldown;
|
|
7
7
|
|
|
8
8
|
//#endregion
|
|
9
9
|
module.exports = rolldown_default;
|
package/dist/rolldown.d.cts
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* This entry file is for Rolldown plugin.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { IsolatedDecl } from './index.js';
|
|
7
|
+
/**
|
|
8
|
+
* Rolldown plugin
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* // rolldown.config.js
|
|
13
|
+
* import IsolatedDecl from 'unplugin-isolated-decl/rolldown'
|
|
14
|
+
*
|
|
15
|
+
* export default {
|
|
16
|
+
* plugins: [IsolatedDecl()],
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
2
20
|
declare const _default: typeof IsolatedDecl.rolldown;
|
|
3
21
|
export = _default;
|
package/dist/rolldown.d.ts
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* This entry file is for Rolldown plugin.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { IsolatedDecl } from './index.js';
|
|
7
|
+
/**
|
|
8
|
+
* Rolldown plugin
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* // rolldown.config.js
|
|
13
|
+
* import IsolatedDecl from 'unplugin-isolated-decl/rolldown'
|
|
14
|
+
*
|
|
15
|
+
* export default {
|
|
16
|
+
* plugins: [IsolatedDecl()],
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
2
20
|
declare const _default: typeof IsolatedDecl.rolldown;
|
|
3
21
|
export default _default;
|
package/dist/rolldown.js
CHANGED
package/dist/rollup.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const
|
|
3
|
-
require('./transformer-
|
|
2
|
+
const require_src = require('./src-lcwrBdQD.cjs');
|
|
3
|
+
require('./transformer-C4rLQvdl.cjs');
|
|
4
4
|
|
|
5
5
|
//#region src/rollup.ts
|
|
6
|
-
var rollup_default =
|
|
6
|
+
var rollup_default = require_src.IsolatedDecl.rollup;
|
|
7
7
|
|
|
8
8
|
//#endregion
|
|
9
9
|
module.exports = rollup_default;
|
package/dist/rollup.d.cts
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* This entry file is for Rollup plugin.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { IsolatedDecl } from './index.js';
|
|
7
|
+
/**
|
|
8
|
+
* Rollup plugin
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* // rollup.config.js
|
|
13
|
+
* import IsolatedDecl from 'unplugin-isolated-decl/rollup'
|
|
14
|
+
*
|
|
15
|
+
* export default {
|
|
16
|
+
* plugins: [IsolatedDecl()],
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
2
20
|
declare const _default: typeof IsolatedDecl.rollup;
|
|
3
21
|
export = _default;
|
package/dist/rollup.d.ts
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* This entry file is for Rollup plugin.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { IsolatedDecl } from './index.js';
|
|
7
|
+
/**
|
|
8
|
+
* Rollup plugin
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* // rollup.config.js
|
|
13
|
+
* import IsolatedDecl from 'unplugin-isolated-decl/rollup'
|
|
14
|
+
*
|
|
15
|
+
* export default {
|
|
16
|
+
* plugins: [IsolatedDecl()],
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
2
20
|
declare const _default: typeof IsolatedDecl.rollup;
|
|
3
21
|
export default _default;
|
package/dist/rollup.js
CHANGED