Skip to content

Commit 388845b

Browse files
committed
Add TS docs
1 parent b36e823 commit 388845b

File tree

2 files changed

+14
-17
lines changed

2 files changed

+14
-17
lines changed

README.md

+14
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,20 @@ Size Limits supports three ways to define limits config.
532532
]
533533
```
534534
535+
4. or types `.size-limit.ts`:
536+
537+
```ts
538+
import type { SizeLimitConfig } from '../../packages/size-limit'
539+
540+
module.exports = [
541+
{
542+
path: "index.js",
543+
import: "{ createStore }",
544+
limit: "500 ms"
545+
}
546+
] satisfies SizeLimitConfig
547+
```
548+
535549
Each section in the config can have these options:
536550
537551
* **path**: relative paths to files. The only mandatory option.

packages/size-limit/get-config.js

-17
Original file line numberDiff line numberDiff line change
@@ -83,25 +83,8 @@ function toName(files, cwd) {
8383
return files.map(i => (i.startsWith(cwd) ? relative(cwd, i) : i)).join(', ')
8484
}
8585

86-
/**
87-
* Dynamically imports a module from a given file path
88-
* and returns its default export.
89-
*
90-
* @param {string} filePath - The path to the module file to be imported.
91-
* @returns {Promise<any>} A promise that resolves with the default export of the module.
92-
*/
9386
const dynamicImport = async filePath => (await import(filePath)).default
9487

95-
/**
96-
* Loads a TypeScript file from a given file path using the
97-
* {@linkcode jiti} function. This loader function simplifies the
98-
* process of dynamically importing TypeScript modules at runtime,
99-
* offering a way to execute or import TypeScript files directly
100-
* without pre-compilation.
101-
*
102-
* @param {string} filePath - The path to the TypeScript file to be loaded.
103-
* @returns {Promise<any>} The module exports from the loaded TypeScript file.
104-
*/
10588
const tsLoader = async filePath => {
10689
let jiti = (await import('jiti')).default(fileURLToPath(import.meta.url), {
10790
interopDefault: true

0 commit comments

Comments
 (0)