Skip to content

Commit c2fa577

Browse files
committed
docs: add jsdoc
1 parent 4f03f74 commit c2fa577

File tree

8 files changed

+114
-0
lines changed

8 files changed

+114
-0
lines changed

src/core/options.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import type { FilterPattern } from '@rollup/pluginutils'
22
import type { TranspileOptions } from 'typescript'
33

4+
/**
5+
* Represents the options for the plugin.
6+
*/
47
export type Options = {
58
include?: FilterPattern
69
exclude?: FilterPattern

src/core/transformer.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ function tryImport<T>(pkg: string): Promise<T | null> {
1313
}
1414
}
1515

16+
/**
17+
* Transform isolated declarations with `oxc-transform`.
18+
*/
1619
export async function oxcTransform(
1720
id: string,
1821
code: string,
@@ -29,6 +32,9 @@ export async function oxcTransform(
2932
return oxc.isolatedDeclaration(id, code, { sourcemap: false })
3033
}
3134

35+
/**
36+
* Transform isolated declarations with `@swc/core`.
37+
*/
3238
export async function swcTransform(
3339
id: string,
3440
code: string,
@@ -70,6 +76,9 @@ export async function swcTransform(
7076
}
7177
}
7278

79+
/**
80+
* Transform isolated declarations with `typescript`.
81+
*/
7382
export async function tsTransform(
7483
id: string,
7584
code: string,

src/esbuild.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
/**
2+
* This entry file is for esbuild plugin.
3+
*
4+
* @module
5+
*/
6+
17
import { IsolatedDecl } from './index'
28

9+
/**
10+
* Esbuild plugin
11+
*
12+
* @example
13+
* ```ts
14+
* import { build } from 'esbuild'
15+
*
16+
* build({
17+
* plugins: [require('unplugin-isolated-decl/esbuild')()],
18+
* })
19+
* ```
20+
*/
321
export default IsolatedDecl.esbuild as typeof IsolatedDecl.esbuild

src/farm.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,23 @@
1+
/**
2+
* This entry file is for Farm plugin.
3+
*
4+
* @module
5+
*/
16
/* eslint-disable import/no-default-export */
7+
28
import { IsolatedDecl } from './index'
39

10+
/**
11+
* Farm plugin
12+
*
13+
* @example
14+
* ```ts
15+
* // farm.config.js
16+
* import IsolatedDecl from 'unplugin-isolated-decl/farm'
17+
*
18+
* export default {
19+
* plugins: [IsolatedDecl()],
20+
* }
21+
* ```
22+
*/
423
export default IsolatedDecl.farm as typeof IsolatedDecl.farm

src/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/**
2+
* This entry file is for main unplugin.
3+
* @module
4+
*/
5+
16
import { mkdir, readFile, writeFile } from 'node:fs/promises'
27
import path from 'node:path'
38
import { createFilter } from '@rollup/pluginutils'
@@ -33,6 +38,9 @@ import type {
3338

3439
export type { Options }
3540

41+
/**
42+
* The main unplugin instance.
43+
*/
3644
export const IsolatedDecl: UnpluginInstance<Options | undefined, false> =
3745
createUnplugin((rawOptions = {}) => {
3846
const options = resolveOptions(rawOptions)

src/rolldown.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
/**
2+
* This entry file is for Rolldown plugin.
3+
*
4+
* @module
5+
*/
6+
17
import { IsolatedDecl } from './index'
28

9+
/**
10+
* Rolldown plugin
11+
*
12+
* @example
13+
* ```ts
14+
* // rolldown.config.js
15+
* import IsolatedDecl from 'unplugin-isolated-decl/rolldown'
16+
*
17+
* export default {
18+
* plugins: [IsolatedDecl()],
19+
* }
20+
* ```
21+
*/
322
export default IsolatedDecl.rolldown as typeof IsolatedDecl.rolldown

src/rollup.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
/**
2+
* This entry file is for Rollup plugin.
3+
*
4+
* @module
5+
*/
6+
17
import { IsolatedDecl } from './index'
28

9+
/**
10+
* Rollup plugin
11+
*
12+
* @example
13+
* ```ts
14+
* // rollup.config.js
15+
* import IsolatedDecl from 'unplugin-isolated-decl/rollup'
16+
*
17+
* export default {
18+
* plugins: [IsolatedDecl()],
19+
* }
20+
* ```
21+
*/
322
export default IsolatedDecl.rollup as typeof IsolatedDecl.rollup

src/vite.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
/**
2+
* This entry file is for Vite plugin.
3+
*
4+
* @module
5+
*/
6+
17
import { IsolatedDecl } from './index'
28

9+
/**
10+
* Vite plugin
11+
*
12+
* @example
13+
* ```ts
14+
* // vite.config.js
15+
* import IsolatedDecl from 'unplugin-isolated-decl/vite'
16+
*
17+
* export default {
18+
* plugins: [IsolatedDecl()],
19+
* }
20+
* ```
21+
*/
322
export default IsolatedDecl.vite as typeof IsolatedDecl.vite

0 commit comments

Comments
 (0)