Ver código fonte

build: exit with an error if bundle sizes increase too much

The currently selected values are a bit above the actual sizes, so if a PR
increases the bundle size enough to trigger the failure, it should bump it.
It better have a good reason for it though!
master
Saúl Ibarra Corretgé 5 anos atrás
pai
commit
f6fb859531
1 arquivos alterados com 55 adições e 25 exclusões
  1. 55
    25
      webpack.config.js

+ 55
- 25
webpack.config.js Ver arquivo

@@ -16,6 +16,18 @@ const minimize
16 16
     = process.argv.indexOf('-p') !== -1
17 17
         || process.argv.indexOf('--optimize-minimize') !== -1;
18 18
 
19
+/**
20
+ * Build a Performance configuration object for the given size.
21
+ * See: https://webpack.js.org/configuration/performance/
22
+ */
23
+function getPerformanceHints(size) {
24
+    return {
25
+        hints: minimize ? 'error' : false,
26
+        maxAssetSize: size,
27
+        maxEntrypointSize: size
28
+    };
29
+}
30
+
19 31
 // The base Webpack configuration to bundle the JavaScript artifacts of
20 32
 // jitsi-meet such as app.bundle.js and external_api.js.
21 33
 const config = {
@@ -153,26 +165,45 @@ const config = {
153 165
 module.exports = [
154 166
     Object.assign({}, config, {
155 167
         entry: {
156
-            'app.bundle': './app.js',
157
-
158
-            'device_selection_popup_bundle':
159
-                './react/features/settings/popup.js',
160
-
161
-            'alwaysontop':
162
-                './react/features/always-on-top/index.js',
163
-
164
-            'dial_in_info_bundle':
165
-                './react/features/invite/components/dial-in-info-page',
166
-
167
-            'do_external_connect':
168
-                './connection_optimization/do_external_connect.js',
169
-
170
-            'flacEncodeWorker':
171
-                './react/features/local-recording/recording/flac/flacEncodeWorker.js',
172
-
173
-            'analytics-ga':
174
-                './react/features/analytics/handlers/GoogleAnalyticsHandler.js'
175
-        }
168
+            'app.bundle': './app.js'
169
+        },
170
+        performance: getPerformanceHints(3 * 1024 * 1024)
171
+    }),
172
+    Object.assign({}, config, {
173
+        entry: {
174
+            'device_selection_popup_bundle': './react/features/settings/popup.js'
175
+        },
176
+        performance: getPerformanceHints(2.5 * 1024 * 1024)
177
+    }),
178
+    Object.assign({}, config, {
179
+        entry: {
180
+            'alwaysontop': './react/features/always-on-top/index.js'
181
+        },
182
+        performance: getPerformanceHints(400 * 1024)
183
+    }),
184
+    Object.assign({}, config, {
185
+        entry: {
186
+            'dial_in_info_bundle': './react/features/invite/components/dial-in-info-page'
187
+        },
188
+        performance: getPerformanceHints(500 * 1024)
189
+    }),
190
+    Object.assign({}, config, {
191
+        entry: {
192
+            'do_external_connect': './connection_optimization/do_external_connect.js'
193
+        },
194
+        performance: getPerformanceHints(5 * 1024)
195
+    }),
196
+    Object.assign({}, config, {
197
+        entry: {
198
+            'flacEncodeWorker': './react/features/local-recording/recording/flac/flacEncodeWorker.js'
199
+        },
200
+        performance: getPerformanceHints(5 * 1024)
201
+    }),
202
+    Object.assign({}, config, {
203
+        entry: {
204
+            'analytics-ga': './react/features/analytics/handlers/GoogleAnalyticsHandler.js'
205
+        },
206
+        performance: getPerformanceHints(5 * 1024)
176 207
     }),
177 208
     Object.assign({}, config, {
178 209
         entry: {
@@ -181,11 +212,9 @@ module.exports = [
181 212
         output: Object.assign({}, config.output, {
182 213
             library: [ 'JitsiMeetJS', 'app', 'effects' ],
183 214
             libraryTarget: 'window'
184
-        })
215
+        }),
216
+        performance: getPerformanceHints(1 * 1024 * 1024)
185 217
     }),
186
-
187
-    // The Webpack configuration to bundle external_api.js (aka
188
-    // JitsiMeetExternalAPI).
189 218
     Object.assign({}, config, {
190 219
         entry: {
191 220
             'external_api': './modules/API/external/index.js'
@@ -193,7 +222,8 @@ module.exports = [
193 222
         output: Object.assign({}, config.output, {
194 223
             library: 'JitsiMeetExternalAPI',
195 224
             libraryTarget: 'umd'
196
-        })
225
+        }),
226
+        performance: getPerformanceHints(30 * 1024)
197 227
     })
198 228
 ];
199 229
 

Carregando…
Cancelar
Salvar