@@ -9,24 +9,48 @@ export type BundleReport = {
99 brotli : number
1010}
1111
12+ const PKG_TARGET_ORDER = [
13+ 'shared' ,
14+ 'message-compiler' ,
15+ 'devtools-types' ,
16+ 'core-base' ,
17+ 'core' ,
18+ 'vue-i18n-core' ,
19+ 'petite-vue-i18n' ,
20+ 'vue-i18n'
21+ ]
22+
23+ function resolveTargets ( targets : string [ ] ) {
24+ return targets . sort ( ( a , b ) => {
25+ const ia = PKG_TARGET_ORDER . indexOf ( a )
26+ const ib = PKG_TARGET_ORDER . indexOf ( b )
27+ return ia > ib ? 1 : ia < ib ? - 1 : 0
28+ } )
29+ }
30+
1231export const targets = async ( ) => {
1332 const packages = await fs . readdir ( 'packages' )
33+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
34+ const pkgCaches = new Map < string , any > ( )
1435 const files = await Promise . all (
1536 packages . map ( async f => {
1637 const stat = await fs . stat ( `packages/${ f } ` )
1738 if ( ! stat . isDirectory ( ) ) {
1839 return ''
1940 }
20- const pkg = await readJson (
21- resolve ( dirname ( '' ) , `./packages/${ f } /package.json` )
22- )
41+ const pkgfile = resolve ( dirname ( '' ) , `./packages/${ f } /package.json` )
42+ let pkg = pkgCaches . get ( pkgfile )
43+ if ( pkg == null ) {
44+ pkg = await readJson ( pkgfile )
45+ pkgCaches . set ( pkgfile , pkg )
46+ }
2347 if ( pkg . private || ! pkg . buildOptions ) {
2448 return ''
2549 }
2650 return f
2751 } )
2852 )
29- return files . filter ( ( _ , f ) => files [ f ] )
53+ return resolveTargets ( files . filter ( ( _ , f ) => files [ f ] ) )
3054}
3155
3256export const fuzzyMatchTarget = async (
@@ -78,7 +102,9 @@ export async function sizeTargets() {
78102 return f
79103 } )
80104 )
81- return files . filter ( ( _ , f ) => files [ f ] ) . filter ( f => / s i z e - c h e c k / . test ( f ) )
105+ return resolveTargets (
106+ files . filter ( ( _ , f ) => files [ f ] ) . filter ( f => / s i z e - c h e c k / . test ( f ) )
107+ )
82108}
83109
84110export async function checkSizeDistFiles ( target : string ) {
0 commit comments