Parcourir la source

feat(build) use core-js to polyfill modern JavaScript features

This should prevent us accidentally breaking compatibility with older
browsers because polyfilling happens automatically based on usage
detection.
factor2
Saúl Ibarra Corretgé il y a 4 mois
Parent
révision
c27ca779ab

+ 0
- 4
app.js Voir le fichier

@@ -1,9 +1,5 @@
1 1
 /* Jitsi Meet app main entrypoint. */
2 2
 
3
-// Polyfill Promise.withReolvers.
4
-// FIXME(saghul) webpack + core-js v3 should polyfill this.
5
-import 'promise.withresolvers/auto';
6
-
7 3
 // Re-export jQuery
8 4
 // FIXME: Remove this requirement from torture tests.
9 5
 import $ from 'jquery';

+ 19
- 0
package-lock.json Voir le fichier

@@ -168,6 +168,7 @@
168 168
         "babel-plugin-optional-require": "0.3.1",
169 169
         "circular-dependency-plugin": "5.2.0",
170 170
         "clean-css-cli": "4.3.0",
171
+        "core-js": "3.40.0",
171 172
         "css-loader": "6.8.1",
172 173
         "eslint": "8.57.0",
173 174
         "eslint-plugin-import": "2.31.0",
@@ -11091,6 +11092,18 @@
11091 11092
         "toggle-selection": "^1.0.6"
11092 11093
       }
11093 11094
     },
11095
+    "node_modules/core-js": {
11096
+      "version": "3.40.0",
11097
+      "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.40.0.tgz",
11098
+      "integrity": "sha512-7vsMc/Lty6AGnn7uFpYT56QesI5D2Y/UkgKounk87OP9Z2H9Z8kj6jzcSGAxFmUtDOS0ntK6lbQz+Nsa0Jj6mQ==",
11099
+      "dev": true,
11100
+      "hasInstallScript": true,
11101
+      "license": "MIT",
11102
+      "funding": {
11103
+        "type": "opencollective",
11104
+        "url": "https://opencollective.com/core-js"
11105
+      }
11106
+    },
11094 11107
     "node_modules/core-js-compat": {
11095 11108
       "version": "3.38.1",
11096 11109
       "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.38.1.tgz",
@@ -33571,6 +33584,12 @@
33571 33584
         "toggle-selection": "^1.0.6"
33572 33585
       }
33573 33586
     },
33587
+    "core-js": {
33588
+      "version": "3.40.0",
33589
+      "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.40.0.tgz",
33590
+      "integrity": "sha512-7vsMc/Lty6AGnn7uFpYT56QesI5D2Y/UkgKounk87OP9Z2H9Z8kj6jzcSGAxFmUtDOS0ntK6lbQz+Nsa0Jj6mQ==",
33591
+      "dev": true
33592
+    },
33574 33593
     "core-js-compat": {
33575 33594
       "version": "3.38.1",
33576 33595
       "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.38.1.tgz",

+ 1
- 0
package.json Voir le fichier

@@ -174,6 +174,7 @@
174 174
     "babel-plugin-optional-require": "0.3.1",
175 175
     "circular-dependency-plugin": "5.2.0",
176 176
     "clean-css-cli": "4.3.0",
177
+    "core-js": "3.40.0",
177 178
     "css-loader": "6.8.1",
178 179
     "eslint": "8.57.0",
179 180
     "eslint-plugin-import": "2.31.0",

+ 2
- 2
react/features/stream-effects/virtual-background/index.ts Voir le fichier

@@ -6,9 +6,9 @@ import { timeout } from '../../virtual-background/functions';
6 6
 import logger from '../../virtual-background/logger';
7 7
 
8 8
 import JitsiStreamBackgroundEffect, { IBackgroundEffectOptions } from './JitsiStreamBackgroundEffect';
9
-// @ts-expect-error
9
+// @ts-ignore
10 10
 import createTFLiteModule from './vendor/tflite/tflite';
11
-// @ts-expect-error
11
+// @ts-ignore
12 12
 import createTFLiteSIMDModule from './vendor/tflite/tflite-simd';
13 13
 const models = {
14 14
     modelLandscape: 'libs/selfie_segmentation_landscape.tflite'

+ 2
- 6
react/features/stream-effects/virtual-background/vendor/tflite/tflite-simd.js Voir le fichier

@@ -13,9 +13,5 @@ var Module=typeof createTFLiteSIMDModule!=="undefined"?createTFLiteSIMDModule:{}
13 13
 }
14 14
 );
15 15
 })();
16
-if (typeof exports === 'object' && typeof module === 'object')
17
-  module.exports = createTFLiteSIMDModule;
18
-else if (typeof define === 'function' && define['amd'])
19
-  define([], function() { return createTFLiteSIMDModule; });
20
-else if (typeof exports === 'object')
21
-  exports["createTFLiteSIMDModule"] = createTFLiteSIMDModule;
16
+
17
+export default createTFLiteSIMDModule;

+ 2
- 6
react/features/stream-effects/virtual-background/vendor/tflite/tflite.js Voir le fichier

@@ -13,9 +13,5 @@ var Module=typeof createTFLiteModule!=="undefined"?createTFLiteModule:{};var rea
13 13
 }
14 14
 );
15 15
 })();
16
-if (typeof exports === 'object' && typeof module === 'object')
17
-  module.exports = createTFLiteModule;
18
-else if (typeof define === 'function' && define['amd'])
19
-  define([], function() { return createTFLiteModule; });
20
-else if (typeof exports === 'object')
21
-  exports["createTFLiteModule"] = createTFLiteModule;
16
+
17
+export default createTFLiteModule;

+ 11
- 2
webpack.config.js Voir le fichier

@@ -126,8 +126,17 @@ function getConfig(options = {}) {
126 126
                                     electron: 10,
127 127
                                     firefox: 68,
128 128
                                     safari: 14
129
-                                }
129
+                                },
130 130
 
131
+                                // Consider stage 3 proposals which are implemented by some browsers already.
132
+                                shippedProposals: true,
133
+
134
+                                // Detect usage of modern JavaScript features and automatically polyfill them
135
+                                // with core-js.
136
+                                useBuiltIns: 'usage',
137
+
138
+                                // core-js version to use, must be in sync with the version in package.json.
139
+                                corejs: '3.40'
131 140
                             }
132 141
                         ],
133 142
                         require.resolve('@babel/preset-react')
@@ -338,7 +347,7 @@ module.exports = (_env, argv) => {
338 347
                 ...config.plugins,
339 348
                 ...getBundleAnalyzerPlugin(analyzeBundle, 'external_api')
340 349
             ],
341
-            performance: getPerformanceHints(perfHintOptions, 40 * 1024)
350
+            performance: getPerformanceHints(perfHintOptions, 85 * 1024)
342 351
         }),
343 352
         Object.assign({}, config, {
344 353
             entry: {

Chargement…
Annuler
Enregistrer