Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

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

Saúl Ibarra Corretgéc27ca779ab49
diff --git a/app.js b/app.js
index 1f3d4ea823..a1053d7e9d 100644
--- a/app.js
+++ b/app.js
@@ -1,9 +1,5 @@
/* Jitsi Meet app main entrypoint. */
-// Polyfill Promise.withReolvers.
-// FIXME(saghul) webpack + core-js v3 should polyfill this.
-import 'promise.withresolvers/auto';
-
// Re-export jQuery
// FIXME: Remove this requirement from torture tests.
import $ from 'jquery';
diff --git a/package-lock.json b/package-lock.json
index 41b0574ee8..f749b7f356 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -168,6 +168,7 @@
"babel-plugin-optional-require": "0.3.1",
"circular-dependency-plugin": "5.2.0",
"clean-css-cli": "4.3.0",
+ "core-js": "3.40.0",
"css-loader": "6.8.1",
"eslint": "8.57.0",
"eslint-plugin-import": "2.31.0",
@@ -11091,6 +11092,18 @@
"toggle-selection": "^1.0.6"
}
},
+ "node_modules/core-js": {
+ "version": "3.40.0",
+ "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.40.0.tgz",
+ "integrity": "sha512-7vsMc/Lty6AGnn7uFpYT56QesI5D2Y/UkgKounk87OP9Z2H9Z8kj6jzcSGAxFmUtDOS0ntK6lbQz+Nsa0Jj6mQ==",
+ "dev": true,
+ "hasInstallScript": true,
+ "license": "MIT",
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/core-js"
+ }
+ },
"node_modules/core-js-compat": {
"version": "3.38.1",
"resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.38.1.tgz",
@@ -33571,6 +33584,12 @@
"toggle-selection": "^1.0.6"
}
},
+ "core-js": {
+ "version": "3.40.0",
+ "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.40.0.tgz",
+ "integrity": "sha512-7vsMc/Lty6AGnn7uFpYT56QesI5D2Y/UkgKounk87OP9Z2H9Z8kj6jzcSGAxFmUtDOS0ntK6lbQz+Nsa0Jj6mQ==",
+ "dev": true
+ },
"core-js-compat": {
"version": "3.38.1",
"resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.38.1.tgz",
diff --git a/package.json b/package.json
index 21ef93f7aa..9a0c15c14c 100644
--- a/package.json
+++ b/package.json
@@ -174,6 +174,7 @@
"babel-plugin-optional-require": "0.3.1",
"circular-dependency-plugin": "5.2.0",
"clean-css-cli": "4.3.0",
+ "core-js": "3.40.0",
"css-loader": "6.8.1",
"eslint": "8.57.0",
"eslint-plugin-import": "2.31.0",
diff --git a/react/features/stream-effects/virtual-background/index.ts b/react/features/stream-effects/virtual-background/index.ts
index 08dc4a6d32..04cbd270a3 100644
--- a/react/features/stream-effects/virtual-background/index.ts
+++ b/react/features/stream-effects/virtual-background/index.ts
@@ -6,9 +6,9 @@ import { timeout } from '../../virtual-background/functions';
import logger from '../../virtual-background/logger';
import JitsiStreamBackgroundEffect, { IBackgroundEffectOptions } from './JitsiStreamBackgroundEffect';
-// @ts-expect-error
+// @ts-ignore
import createTFLiteModule from './vendor/tflite/tflite';
-// @ts-expect-error
+// @ts-ignore
import createTFLiteSIMDModule from './vendor/tflite/tflite-simd';
const models = {
modelLandscape: 'libs/selfie_segmentation_landscape.tflite'
diff --git a/react/features/stream-effects/virtual-background/vendor/tflite/tflite-simd.js b/react/features/stream-effects/virtual-background/vendor/tflite/tflite-simd.js
index 56bb011cb0..2b29891605 100644
--- a/react/features/stream-effects/virtual-background/vendor/tflite/tflite-simd.js
+++ b/react/features/stream-effects/virtual-background/vendor/tflite/tflite-simd.js
@@ -13,9 +13,5 @@ var Module=typeof createTFLiteSIMDModule!=="undefined"?createTFLiteSIMDModule:{}
}
);
})();
-if (typeof exports === 'object' && typeof module === 'object')
- module.exports = createTFLiteSIMDModule;
-else if (typeof define === 'function' && define['amd'])
- define([], function() { return createTFLiteSIMDModule; });
-else if (typeof exports === 'object')
- exports["createTFLiteSIMDModule"] = createTFLiteSIMDModule;
+
+export default createTFLiteSIMDModule;
diff --git a/react/features/stream-effects/virtual-background/vendor/tflite/tflite.js b/react/features/stream-effects/virtual-background/vendor/tflite/tflite.js
index 38454c827a..33e3b9cb46 100644
--- a/react/features/stream-effects/virtual-background/vendor/tflite/tflite.js
+++ b/react/features/stream-effects/virtual-background/vendor/tflite/tflite.js
@@ -13,9 +13,5 @@ var Module=typeof createTFLiteModule!=="undefined"?createTFLiteModule:{};var rea
}
);
})();
-if (typeof exports === 'object' && typeof module === 'object')
- module.exports = createTFLiteModule;
-else if (typeof define === 'function' && define['amd'])
- define([], function() { return createTFLiteModule; });
-else if (typeof exports === 'object')
- exports["createTFLiteModule"] = createTFLiteModule;
+
+export default createTFLiteModule;
diff --git a/webpack.config.js b/webpack.config.js
index 5a754c2efb..6cb770434b 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -126,8 +126,17 @@ function getConfig(options = {}) {
electron: 10,
firefox: 68,
safari: 14
- }
+ },
+ // Consider stage 3 proposals which are implemented by some browsers already.
+ shippedProposals: true,
+
+ // Detect usage of modern JavaScript features and automatically polyfill them
+ // with core-js.
+ useBuiltIns: 'usage',
+
+ // core-js version to use, must be in sync with the version in package.json.
+ corejs: '3.40'
}
],
require.resolve('@babel/preset-react')
@@ -338,7 +347,7 @@ module.exports = (_env, argv) => {
...config.plugins,
...getBundleAnalyzerPlugin(analyzeBundle, 'external_api')
],
- performance: getPerformanceHints(perfHintOptions, 40 * 1024)
+ performance: getPerformanceHints(perfHintOptions, 85 * 1024)
}),
Object.assign({}, config, {
entry: {