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.
Files changed (42) hide show
  1. package/README.md +20 -2
  2. package/dist/api.cjs +1 -1
  3. package/dist/api.d.cts +1 -1
  4. package/dist/api.d.ts +1 -1
  5. package/dist/api.js +1 -1
  6. package/dist/core/ast.d.cts +7 -0
  7. package/dist/core/ast.d.ts +7 -0
  8. package/dist/core/options.d.cts +3 -0
  9. package/dist/core/options.d.ts +3 -0
  10. package/dist/core/transformer.d.cts +9 -0
  11. package/dist/core/transformer.d.ts +9 -0
  12. package/dist/core/utils.d.cts +8 -0
  13. package/dist/core/utils.d.ts +8 -0
  14. package/dist/esbuild.cjs +3 -3
  15. package/dist/esbuild.d.cts +18 -1
  16. package/dist/esbuild.d.ts +18 -1
  17. package/dist/esbuild.js +2 -2
  18. package/dist/farm.cjs +9 -0
  19. package/dist/farm.d.cts +21 -0
  20. package/dist/farm.d.ts +21 -0
  21. package/dist/farm.js +8 -0
  22. package/dist/index.cjs +3 -4
  23. package/dist/index.d.cts +8 -2
  24. package/dist/index.d.ts +8 -2
  25. package/dist/index.js +3 -3
  26. package/dist/rolldown.cjs +3 -3
  27. package/dist/rolldown.d.cts +19 -1
  28. package/dist/rolldown.d.ts +19 -1
  29. package/dist/rolldown.js +2 -2
  30. package/dist/rollup.cjs +3 -3
  31. package/dist/rollup.d.cts +19 -1
  32. package/dist/rollup.d.ts +19 -1
  33. package/dist/rollup.js +2 -2
  34. package/dist/{src_index-2WEAOr05.js → src-BatylriB.js} +194 -90
  35. package/dist/{src_index-NKcZyc90.cjs → src-lcwrBdQD.cjs} +193 -94
  36. package/dist/vite.cjs +3 -3
  37. package/dist/vite.d.cts +19 -1
  38. package/dist/vite.d.ts +19 -1
  39. package/dist/vite.js +2 -2
  40. package/package.json +21 -14
  41. /package/dist/{transformer-uKy0L3Za.cjs → transformer-C4rLQvdl.cjs} +0 -0
  42. /package/dist/{transformer-w7XvOpWe.js → transformer-DDte86lZ.js} +0 -0
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # unplugin-isolated-decl [![npm](https://img.shields.io/npm/v/unplugin-isolated-decl.svg)](https://npmjs.com/package/unplugin-isolated-decl)
1
+ # unplugin-isolated-decl [![npm](https://img.shields.io/npm/v/unplugin-isolated-decl.svg)](https://npmjs.com/package/unplugin-isolated-decl) [![jsr](https://jsr.io/badges/@unplugin/isolated-decl)](https://jsr.io/@unplugin/isolated-decl)
2
2
 
3
3
  [![Unit Test](https://github.com/unplugin/unplugin-isolated-decl/actions/workflows/unit-test.yml/badge.svg)](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 esbuild.
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
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const require_transformer = require('./transformer-uKy0L3Za.cjs');
2
+ const require_transformer = require('./transformer-C4rLQvdl.cjs');
3
3
 
4
4
  exports.oxcTransform = require_transformer.oxcTransform
5
5
  exports.swcTransform = require_transformer.swcTransform
package/dist/api.d.cts CHANGED
@@ -1 +1 @@
1
- export { oxcTransform, swcTransform, tsTransform } from "./core/transformer.js";
1
+ export { oxcTransform, swcTransform, tsTransform } from './core/transformer.js';
package/dist/api.d.ts CHANGED
@@ -1 +1 @@
1
- export { oxcTransform, swcTransform, tsTransform } from "./core/transformer.js";
1
+ export { oxcTransform, swcTransform, tsTransform } from './core/transformer.js';
package/dist/api.js CHANGED
@@ -1,3 +1,3 @@
1
- import { oxcTransform, swcTransform, tsTransform } from "./transformer-w7XvOpWe.js";
1
+ import { oxcTransform, swcTransform, tsTransform } from "./transformer-DDte86lZ.js";
2
2
 
3
3
  export { oxcTransform, swcTransform, tsTransform };
@@ -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;
@@ -1,5 +1,8 @@
1
1
  import type { FilterPattern } from '@rollup/pluginutils';
2
2
  import type { TranspileOptions } from 'typescript';
3
+ /**
4
+ * Represents the options for the plugin.
5
+ */
3
6
  export type Options = {
4
7
  include?: FilterPattern;
5
8
  exclude?: FilterPattern;
@@ -1,5 +1,8 @@
1
1
  import type { FilterPattern } from '@rollup/pluginutils';
2
2
  import type { TranspileOptions } from 'typescript';
3
+ /**
4
+ * Represents the options for the plugin.
5
+ */
3
6
  export type Options = {
4
7
  include?: FilterPattern;
5
8
  exclude?: FilterPattern;
@@ -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 require_src_index = require('./src_index-NKcZyc90.cjs');
3
- require('./transformer-uKy0L3Za.cjs');
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 = require_src_index.IsolatedDecl.esbuild;
6
+ var esbuild_default = require_src.IsolatedDecl.esbuild;
7
7
 
8
8
  //#endregion
9
9
  module.exports = esbuild_default;
@@ -1,3 +1,20 @@
1
- import { IsolatedDecl } from "./index.js";
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
- import { IsolatedDecl } from "./index.js";
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
@@ -1,5 +1,5 @@
1
- import "./transformer-w7XvOpWe.js";
2
- import { IsolatedDecl } from "./src_index-2WEAOr05.js";
1
+ import "./transformer-DDte86lZ.js";
2
+ import { IsolatedDecl } from "./src-BatylriB.js";
3
3
 
4
4
  //#region src/esbuild.ts
5
5
  var esbuild_default = IsolatedDecl.esbuild;
package/dist/farm.cjs ADDED
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ const require_src = require('./src-lcwrBdQD.cjs');
3
+ require('./transformer-C4rLQvdl.cjs');
4
+
5
+ //#region src/farm.ts
6
+ var farm_default = require_src.IsolatedDecl.farm;
7
+
8
+ //#endregion
9
+ module.exports = farm_default;
@@ -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
@@ -0,0 +1,8 @@
1
+ import "./transformer-DDte86lZ.js";
2
+ import { IsolatedDecl } from "./src-BatylriB.js";
3
+
4
+ //#region src/farm.ts
5
+ var farm_default = IsolatedDecl.farm;
6
+
7
+ //#endregion
8
+ export { farm_default as default };
package/dist/index.cjs CHANGED
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
- const require_src_index = require('./src_index-NKcZyc90.cjs');
3
- require('./transformer-uKy0L3Za.cjs');
2
+ const require_src = require('./src-lcwrBdQD.cjs');
3
+ require('./transformer-C4rLQvdl.cjs');
4
4
 
5
- exports.IsolatedDecl = require_src_index.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 "./core/options.js";
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 "./core/options.js";
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-w7XvOpWe.js";
2
- import { IsolatedDecl, lowestCommonAncestor } from "./src_index-2WEAOr05.js";
1
+ import "./transformer-DDte86lZ.js";
2
+ import { IsolatedDecl } from "./src-BatylriB.js";
3
3
 
4
- export { IsolatedDecl, lowestCommonAncestor };
4
+ export { IsolatedDecl };
package/dist/rolldown.cjs CHANGED
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
- const require_src_index = require('./src_index-NKcZyc90.cjs');
3
- require('./transformer-uKy0L3Za.cjs');
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 = require_src_index.IsolatedDecl.rolldown;
6
+ var rolldown_default = require_src.IsolatedDecl.rolldown;
7
7
 
8
8
  //#endregion
9
9
  module.exports = rolldown_default;
@@ -1,3 +1,21 @@
1
- import { IsolatedDecl } from "./index.js";
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;
@@ -1,3 +1,21 @@
1
- import { IsolatedDecl } from "./index.js";
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
@@ -1,5 +1,5 @@
1
- import "./transformer-w7XvOpWe.js";
2
- import { IsolatedDecl } from "./src_index-2WEAOr05.js";
1
+ import "./transformer-DDte86lZ.js";
2
+ import { IsolatedDecl } from "./src-BatylriB.js";
3
3
 
4
4
  //#region src/rolldown.ts
5
5
  var rolldown_default = IsolatedDecl.rolldown;
package/dist/rollup.cjs CHANGED
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
- const require_src_index = require('./src_index-NKcZyc90.cjs');
3
- require('./transformer-uKy0L3Za.cjs');
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 = require_src_index.IsolatedDecl.rollup;
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
- import { IsolatedDecl } from "./index.js";
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
- import { IsolatedDecl } from "./index.js";
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
@@ -1,5 +1,5 @@
1
- import "./transformer-w7XvOpWe.js";
2
- import { IsolatedDecl } from "./src_index-2WEAOr05.js";
1
+ import "./transformer-DDte86lZ.js";
2
+ import { IsolatedDecl } from "./src-BatylriB.js";
3
3
 
4
4
  //#region src/rollup.ts
5
5
  var rollup_default = IsolatedDecl.rollup;