@@ -12,51 +12,62 @@ const allPackageEntryPoints = [
1212 './dist/react/redux-toolkit-react.modern.mjs' ,
1313 './dist/query/rtk-query.modern.mjs' ,
1414 './dist/query/react/rtk-query-react.modern.mjs' ,
15- ] as const
15+ ] as const satisfies string [ ]
1616
17- const dependencies = Object . keys ( packageJson . dependencies ?? { } )
17+ const peerAndProductionDependencies = Object . keys ( {
18+ ...packageJson . dependencies ,
19+ ...packageJson . peerDependencies ,
20+ } as const )
1821
1922const sizeLimitConfig : SizeLimitConfig = (
2023 await Promise . all (
2124 allNodeEnvs . flatMap ( ( nodeEnv ) => {
22- const modifyWebpackConfig = ( ( config : Configuration ) => {
23- ; ( config . optimization ??= { } ) . nodeEnv = nodeEnv
24-
25- return config
26- } ) satisfies Check [ 'modifyWebpackConfig' ]
25+ const modifyWebpackConfig = ( ( config : Configuration ) : Configuration =>
26+ ( {
27+ ...config ,
28+ optimization : {
29+ ...config . optimization ,
30+ nodeEnv,
31+ } ,
32+ } ) as const satisfies Configuration ) satisfies Check [ 'modifyWebpackConfig' ]
2733
2834 return allPackageEntryPoints . map ( async ( entryPoint , index ) => {
2935 const allNamedImports = Object . keys ( await import ( entryPoint ) ) . filter (
3036 ( namedImport ) => namedImport !== 'default' ,
3137 )
3238
33- const sizeLimitConfigWithDependencies = allNamedImports
34- . map < Check > ( ( namedImport , namedImportIndex ) => ( {
39+ const sizeLimitConfigWithDependencies = [
40+ ...allNamedImports . map (
41+ ( namedImport , namedImportIndex ) =>
42+ ( {
43+ path : entryPoint ,
44+ name : `${ ( index + 1 ) . toString ( ) } -${ ( namedImportIndex + 1 ) . toString ( ) } . import { ${ namedImport } } from "${ entryPoint } " ('${ nodeEnv } ' mode)` ,
45+ import : `{ ${ namedImport } }` ,
46+ modifyWebpackConfig,
47+ } ) as const satisfies Check ,
48+ ) ,
49+ {
50+ path : entryPoint ,
51+ name : `${ ( index + 1 ) . toString ( ) } -${ ( allNamedImports . length + 1 ) . toString ( ) } . import * from "${ entryPoint } " ('${ nodeEnv } ' mode)` ,
52+ import : '*' ,
53+ modifyWebpackConfig,
54+ } ,
55+ {
3556 path : entryPoint ,
36- name : `${ index + 1 } -${ namedImportIndex + 1 } . import { ${ namedImport } } from "${ entryPoint } " ('${ nodeEnv } ' mode)` ,
37- import : `{ ${ namedImport } }` ,
57+ name : `${ ( index + 1 ) . toString ( ) } -${ ( allNamedImports . length + 2 ) . toString ( ) } . import "${ entryPoint } " ('${ nodeEnv } ' mode)` ,
3858 modifyWebpackConfig,
39- } ) )
40- . concat ( [
41- {
42- path : entryPoint ,
43- name : `${ index + 1 } -${ allNamedImports . length + 1 } . import * from "${ entryPoint } " ('${ nodeEnv } ' mode)` ,
44- import : '*' ,
45- modifyWebpackConfig,
46- } ,
47- {
48- path : entryPoint ,
49- name : `${ index + 1 } -${ allNamedImports . length + 2 } . import "${ entryPoint } " ('${ nodeEnv } ' mode)` ,
50- modifyWebpackConfig,
51- } ,
52- ] )
59+ } ,
60+ ] as const satisfies SizeLimitConfig
5361
5462 const sizeLimitConfigWithoutDependencies =
55- sizeLimitConfigWithDependencies . map ( ( check ) => ( {
56- ...check ,
57- name : `${ check . name } (excluding dependencies)` ,
58- ignore : dependencies ,
59- } ) )
63+ sizeLimitConfigWithDependencies . map (
64+ ( check ) =>
65+ ( {
66+ ...check ,
67+ name : `${ check . name } (excluding dependencies)` ,
68+ ignore : peerAndProductionDependencies ,
69+ } ) as const satisfies Check ,
70+ )
6071
6172 return [
6273 // ...sizeLimitConfigWithDependencies,
0 commit comments