size-limit
Advanced tools
Comparing version 11.0.3 to 11.1.0
@@ -6,2 +6,3 @@ import bytes from 'bytes-iec' | ||
import { dirname, isAbsolute, join, relative } from 'node:path' | ||
import { fileURLToPath } from 'node:url' | ||
@@ -86,11 +87,11 @@ import { SizeLimitError } from './size-limit-error.js' | ||
/** | ||
* 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 | ||
const tsLoader = async filePath => { | ||
let jiti = (await import('jiti')).default(fileURLToPath(import.meta.url), { | ||
interopDefault: true | ||
}) | ||
return jiti(filePath) | ||
} | ||
export default async function getConfig(plugins, process, args, pkg) { | ||
@@ -127,4 +128,8 @@ let config = { | ||
loaders: { | ||
'.cjs': dynamicImport, | ||
'.cts': tsLoader, | ||
'.js': dynamicImport, | ||
'.mjs': dynamicImport | ||
'.mjs': dynamicImport, | ||
'.mts': tsLoader, | ||
'.ts': tsLoader | ||
}, | ||
@@ -137,3 +142,6 @@ searchPlaces: [ | ||
'.size-limit.mjs', | ||
'.size-limit.cjs' | ||
'.size-limit.cjs', | ||
'.size-limit.ts', | ||
'.size-limit.mts', | ||
'.size-limit.cts' | ||
] | ||
@@ -140,0 +148,0 @@ }) |
@@ -11,3 +11,3 @@ import calc from './calc.js' | ||
* | ||
* @param {functions[]} plugins The list of plugins like `@size-limit/time` | ||
* @param {Function[]} plugins The list of plugins like `@size-limit/time` | ||
* @param {string[]|object} files Path to files or internal config | ||
@@ -14,0 +14,0 @@ * @return {Promise<object>} Project size |
{ | ||
"name": "size-limit", | ||
"version": "11.0.3", | ||
"version": "11.1.0", | ||
"description": "CLI tool for Size Limit", | ||
"type": "module", | ||
"types": "index.d.ts", | ||
"keywords": [ | ||
@@ -29,2 +30,3 @@ "size-limit", | ||
"globby": "^14.0.1", | ||
"jiti": "^1.21.0", | ||
"lilconfig": "^3.1.1", | ||
@@ -31,0 +33,0 @@ "nanospinner": "^1.1.0", |
35562
18
987
7
+ Addedjiti@^1.21.0
+ Addedjiti@1.21.6(transitive)