Skip to content

Commit 7132a58

Browse files
committed
feat: add loader option
1 parent cf4ae90 commit 7132a58

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

docs/.vitepress/scripts/docs-generate.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ safe_sed() {
1111
echo "📚 Generating reference..."
1212

1313
# Generate API documentation
14-
./node_modules/.bin/typedoc --tsconfig tsconfig.json >/dev/null 2>&1
14+
./node_modules/.bin/typedoc --tsconfig tsconfig.json
1515

1616
echo "✅ Reference generated successfully!"
1717

@@ -27,7 +27,7 @@ fi
2727
# Create the type-aliases folder
2828
mkdir -p ./docs/reference/type-aliases
2929
# Move types-aliases/{Sourcemap,Format}.md to ./docs/reference/type-aliases
30-
mv ./docs/reference/api/type-aliases/{Sourcemap,Format}.md ./docs/reference/type-aliases
30+
mv ./docs/reference/api/type-aliases/{Sourcemap,Format,ModuleTypes}.md ./docs/reference/type-aliases
3131

3232
# Remove the api folder
3333
rm -rf ./docs/reference/api

src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ async function getBuildOptions(
201201
report,
202202
env,
203203
removeNodeProtocol,
204+
loader,
204205
} = config
205206

206207
const plugins: RolldownPluginOption = []
@@ -279,6 +280,7 @@ async function getBuildOptions(
279280
inject: {
280281
...(shims && !cjsDts && getShimsInject(format, platform)),
281282
},
283+
moduleTypes: loader,
282284
},
283285
config.inputOptions,
284286
[format],

src/options.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,21 @@ const debug = Debug('tsdown:options')
4343
export type Sourcemap = boolean | 'inline' | 'hidden'
4444
export type Format = Exclude<ModuleFormat, 'experimental-app'>
4545
export type NormalizedFormat = Exclude<InternalModuleFormat, 'app'>
46+
export type ModuleTypes = Record<
47+
string,
48+
| 'js'
49+
| 'jsx'
50+
| 'ts'
51+
| 'tsx'
52+
| 'json'
53+
| 'text'
54+
| 'base64'
55+
| 'dataurl'
56+
| 'binary'
57+
| 'empty'
58+
| 'css'
59+
| 'asset'
60+
>
4661

4762
/**
4863
* Options for tsdown.
@@ -248,6 +263,17 @@ export interface Options {
248263
* @default process.cwd()
249264
*/
250265
cwd?: string
266+
267+
/**
268+
* Sets how input files are processed.
269+
* For example, use 'js' to treat files as JavaScript or 'base64' for images.
270+
* Lets you import or require files like images or fonts.
271+
* @example
272+
* ```json
273+
* { '.jpg': 'asset', '.png': 'base64' }
274+
* ```
275+
*/
276+
loader?: ModuleTypes
251277
}
252278

253279
/**
@@ -275,6 +301,7 @@ export type ResolvedOptions = Omit<
275301
| 'hooks'
276302
| 'removeNodeProtocol'
277303
| 'copy'
304+
| 'loader'
278305
>,
279306
{
280307
format: NormalizedFormat[]

0 commit comments

Comments
 (0)