Skip to content

Commit

Permalink
Add TS docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ai committed Mar 13, 2024
1 parent b36e823 commit 388845b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
14 changes: 14 additions & 0 deletions README.md
Expand Up @@ -532,6 +532,20 @@ Size Limits supports three ways to define limits config.
]
```

4. or types `.size-limit.ts`:

```ts
import type { SizeLimitConfig } from '../../packages/size-limit'

module.exports = [
{
path: "index.js",
import: "{ createStore }",
limit: "500 ms"
}
] satisfies SizeLimitConfig
```

Each section in the config can have these options:

* **path**: relative paths to files. The only mandatory option.
Expand Down
17 changes: 0 additions & 17 deletions packages/size-limit/get-config.js
Expand Up @@ -83,25 +83,8 @@ function toName(files, cwd) {
return files.map(i => (i.startsWith(cwd) ? relative(cwd, i) : i)).join(', ')
}

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

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

0 comments on commit 388845b

Please sign in to comment.