Skip to content

Commit 7bad4fb

Browse files
committed
Make variable names more descriptive
1 parent f362a96 commit 7bad4fb

File tree

1 file changed

+24
-16
lines changed

1 file changed

+24
-16
lines changed

.size-limit.mts

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,46 @@ import type { Check, SizeLimitConfig } from 'size-limit'
44

55
const __dirname = fileURLToPath(new URL('.', import.meta.url))
66

7-
const getAllEntryPoints = async () => {
8-
const pkgJson = await import('./package.json', { with: { type: 'json' } })
7+
const getAllPackageEntryPoints = async () => {
8+
const packageJson = await import('./package.json', { with: { type: 'json' } })
99

10-
const entryPoints = Object.entries(pkgJson.exports['.'])
10+
const packageExports = Object.entries(packageJson.exports['.'])
1111
.filter(([condition]) => condition !== 'types')
12-
.map(([, entryPoint]) =>
12+
.map(([_condition, entryPoint]) =>
1313
path.isAbsolute(entryPoint) ? `./${entryPoint}` : entryPoint,
1414
)
1515

16-
return entryPoints
16+
return [...new Set(packageExports)]
1717
}
1818

1919
const getAllImports = async (
2020
entryPoint: string,
2121
index: number,
2222
): Promise<SizeLimitConfig> => {
23-
const allImports = await import(entryPoint)
23+
const allNamedImports = await import(entryPoint)
2424

25-
return Object.keys(allImports)
25+
return Object.keys(allNamedImports)
2626
.map<Check>((namedImport) => ({
2727
path: entryPoint,
28-
name: `${namedImport} (${entryPoint})`,
28+
name: `import { ${namedImport} } from "${entryPoint}"`,
2929
import: `{ ${namedImport} }`,
3030
}))
31-
.concat({
32-
path: entryPoint,
33-
name: `${index + 1}. Entry point: ${entryPoint}`,
34-
import: '*',
35-
})
31+
.concat([
32+
{
33+
path: entryPoint,
34+
name: `import * from "${entryPoint}"`,
35+
import: '*',
36+
},
37+
{
38+
path: entryPoint,
39+
name: `import "${entryPoint}"`,
40+
},
41+
])
3642
}
3743

38-
const config: Promise<SizeLimitConfig> = (async () =>
39-
(await Promise.all((await getAllEntryPoints()).map(getAllImports))).flat())()
44+
const sizeLimitConfig: Promise<SizeLimitConfig> = (async () =>
45+
(
46+
await Promise.all((await getAllPackageEntryPoints()).map(getAllImports))
47+
).flat())()
4048

41-
export default config
49+
export default sizeLimitConfig

0 commit comments

Comments
 (0)