diff --git a/README.md b/README.md index 91752f15..de16e333 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/packages/size-limit/get-config.js b/packages/size-limit/get-config.js index 7b4e2c8c..a5290502 100644 --- a/packages/size-limit/get-config.js +++ b/packages/size-limit/get-config.js @@ -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} 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} The module exports from the loaded TypeScript file. - */ const tsLoader = async filePath => { let jiti = (await import('jiti')).default(fileURLToPath(import.meta.url), { interopDefault: true