@@ -37,6 +37,18 @@ const functions = [
37
37
{ name : 'constructPresenceMessage' , transitiveImports : [ ] } ,
38
38
] ;
39
39
40
+ // List of all buildable plugins available as a separate export
41
+ interface PluginInfo {
42
+ description : string ;
43
+ path : string ;
44
+ external ?: string [ ] ;
45
+ }
46
+
47
+ const buildablePlugins : Record < 'push' | 'liveObjects' , PluginInfo > = {
48
+ push : { description : 'Push' , path : './build/push.js' , external : [ 'ulid' ] } ,
49
+ liveObjects : { description : 'LiveObjects' , path : './build/liveobjects.js' , external : [ 'deep-equal' ] } ,
50
+ } ;
51
+
40
52
function formatBytes ( bytes : number ) {
41
53
const kibibytes = bytes / 1024 ;
42
54
const formatted = kibibytes . toFixed ( 2 ) ;
@@ -70,7 +82,7 @@ function getModularBundleInfo(exports: string[]): BundleInfo {
70
82
}
71
83
72
84
// Uses esbuild to create a bundle containing the named exports from a given module
73
- function getBundleInfo ( modulePath : string , exports ?: string [ ] ) : BundleInfo {
85
+ function getBundleInfo ( modulePath : string , exports ?: string [ ] , external ?: string [ ] ) : BundleInfo {
74
86
const outfile = exports ? exports . join ( '' ) : 'all' ;
75
87
const exportTarget = exports ? `{ ${ exports . join ( ', ' ) } }` : '*' ;
76
88
const result = esbuild . buildSync ( {
@@ -84,7 +96,7 @@ function getBundleInfo(modulePath: string, exports?: string[]): BundleInfo {
84
96
outfile,
85
97
write : false ,
86
98
sourcemap : 'external' ,
87
- external : [ 'ulid' ] ,
99
+ external,
88
100
} ) ;
89
101
90
102
const pathHasBase = ( component : string ) => {
@@ -183,9 +195,9 @@ async function calculateAndCheckFunctionSizes(): Promise<Output> {
183
195
return output ;
184
196
}
185
197
186
- async function calculatePluginSize ( options : { path : string ; description : string } ) : Promise < Output > {
198
+ async function calculatePluginSize ( options : PluginInfo ) : Promise < Output > {
187
199
const output : Output = { tableRows : [ ] , errors : [ ] } ;
188
- const pluginBundleInfo = getBundleInfo ( options . path ) ;
200
+ const pluginBundleInfo = getBundleInfo ( options . path , undefined , options . external ) ;
189
201
const sizes = {
190
202
rawByteSize : pluginBundleInfo . byteSize ,
191
203
gzipEncodedByteSize : ( await promisify ( gzip ) ( pluginBundleInfo . code ) ) . byteLength ,
@@ -200,11 +212,11 @@ async function calculatePluginSize(options: { path: string; description: string
200
212
}
201
213
202
214
async function calculatePushPluginSize ( ) : Promise < Output > {
203
- return calculatePluginSize ( { path : './build/ push.js' , description : 'Push' } ) ;
215
+ return calculatePluginSize ( buildablePlugins . push ) ;
204
216
}
205
217
206
218
async function calculateLiveObjectsPluginSize ( ) : Promise < Output > {
207
- return calculatePluginSize ( { path : './build/liveobjects.js' , description : 'LiveObjects' } ) ;
219
+ return calculatePluginSize ( buildablePlugins . liveObjects ) ;
208
220
}
209
221
210
222
async function calculateAndCheckMinimalUsefulRealtimeBundleSize ( ) : Promise < Output > {
@@ -291,7 +303,8 @@ async function checkBaseRealtimeFiles() {
291
303
}
292
304
293
305
async function checkPushPluginFiles ( ) {
294
- const pushPluginBundleInfo = getBundleInfo ( './build/push.js' ) ;
306
+ const { path, external } = buildablePlugins . push ;
307
+ const pushPluginBundleInfo = getBundleInfo ( path , undefined , external ) ;
295
308
296
309
// These are the files that are allowed to contribute >= `threshold` bytes to the Push bundle.
297
310
const allowedFiles = new Set ( [
@@ -305,7 +318,8 @@ async function checkPushPluginFiles() {
305
318
}
306
319
307
320
async function checkLiveObjectsPluginFiles ( ) {
308
- const pluginBundleInfo = getBundleInfo ( './build/liveobjects.js' ) ;
321
+ const { path, external } = buildablePlugins . liveObjects ;
322
+ const pluginBundleInfo = getBundleInfo ( path , undefined , external ) ;
309
323
310
324
// These are the files that are allowed to contribute >= `threshold` bytes to the LiveObjects bundle.
311
325
const allowedFiles = new Set ( [
0 commit comments