1
1
import { promisify } from 'node:util' ;
2
2
import child_process from 'node:child_process' ;
3
3
import fs from 'fs' ;
4
+ import equal from 'deep-equal' ;
4
5
5
6
const exec = promisify ( child_process . exec ) ;
6
7
const readJSON = filePath => JSON . parse ( fs . readFileSync ( filePath , 'utf-8' ) ) ;
@@ -34,10 +35,10 @@ function checkPackages(pkgJson, vitePkgJson) {
34
35
const differences = [ ] ;
35
36
36
37
for ( const field of fields ) {
37
- const pkg = JSON . stringify ( pkgJson [ field ] ) ;
38
- const vitePkg = JSON . stringify ( vitePkgJson [ field ] ) ;
38
+ const pkg = pkgJson [ field ] ;
39
+ const vitePkg = vitePkgJson [ field ] ;
39
40
40
- if ( pkg !== vitePkg ) {
41
+ if ( ! equal ( pkg , vitePkg ) ) {
41
42
differences . push ( { field, differences : { pkg, vitePkg } } ) ;
42
43
}
43
44
}
@@ -67,6 +68,28 @@ function fixBuild(path) {
67
68
fs . writeFileSync ( path , fixedBuild , 'utf-8' ) ;
68
69
}
69
70
71
+ /**
72
+ * Amplify rollup to add 10 more kbs to the limit
73
+ * @param {string } file
74
+ */
75
+ function fixRollup ( path ) {
76
+ const file = fs . readFileSync ( path , 'utf-8' ) ;
77
+
78
+ const buildCondition = / b u n d l e S i z e L i m i t \( ( \d + ) \) / ;
79
+
80
+ if ( ! file . match ( buildCondition ) ) {
81
+ throw new Error (
82
+ 'Source code does not match expectations for automatic replacement of rollup limit'
83
+ ) ;
84
+ }
85
+
86
+ const fixedBuild = file . replace ( buildCondition , ( match , limit ) =>
87
+ match . replace ( limit , Number ( limit ) + 10 )
88
+ ) ;
89
+
90
+ fs . writeFileSync ( path , fixedBuild , 'utf-8' ) ;
91
+ }
92
+
70
93
async function main ( ) {
71
94
rmDir ( './bin' ) ;
72
95
rmDir ( './dist' ) ;
@@ -88,6 +111,7 @@ async function main() {
88
111
89
112
console . log ( 'Building' ) ;
90
113
fixBuild ( './vite/packages/vite/src/node/plugins/asset.ts' ) ;
114
+ fixRollup ( './vite/packages/vite/rollup.config.ts' ) ;
91
115
await exec ( 'pnpm build' , { cwd : './vite/packages/vite' } ) ;
92
116
93
117
console . log ( 'Moving folders' ) ;
0 commit comments