From 9b055171abd19df03547bfdd4ad39a3233d98df8 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Fri, 27 Apr 2018 13:32:09 +0100 Subject: [PATCH 1/2] Enforce loading babel-polyfill first This is to avoid loading anything before loading the polyfill, otherwise we risk loading dependencies (such as React) before it. This was causing the compatibility page to fail somehow. See https://github.com/facebook/react/issues/8379 Fixes https://github.com/vector-im/riot-web/issues/6562 --- src/vector/index.js | 12 ------------ webpack.config.js | 5 +++++ 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/vector/index.js b/src/vector/index.js index 63affadde9..0b14c6a1d7 100644 --- a/src/vector/index.js +++ b/src/vector/index.js @@ -17,18 +17,6 @@ limitations under the License. 'use strict'; -// for ES6 stuff like startsWith() that Safari doesn't handle -// and babel doesn't do by default -// Note we use this, as well as the babel transform-runtime plugin -// since transform-runtime does not cover instance methods -// such as "foobar".includes("foo") which bits of our library -// code use, but the babel transform-runtime plugin allows the -// regenerator runtime to be injected early enough in the process -// (it can't be here as it's too late: the alternative is to put -// the babel-polyfill as the first 'entry' in the webpack config). -// https://babeljs.io/docs/plugins/transform-runtime/ -require('babel-polyfill'); - // Require common CSS here; this will make webpack process it into bundle.css. // Our own CSS (which is themed) is imported via separate webpack entry points // in webpack.config.js diff --git a/webpack.config.js b/webpack.config.js index d82d4bcc89..81e0c1794d 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -8,6 +8,11 @@ if (!og_image_url) og_image_url = 'https://riot.im/app/themes/riot/img/logos/rio module.exports = { entry: { + main: [ + // Load this first to avoid issues where some imports (namely react) + // potentially before babel-polyfill. + 'babel-polyfill', + ], "bundle": "./src/vector/index.js", "indexeddb-worker": "./src/vector/indexeddb-worker.js", From c56b54eddddd75f1eabfccda5166165d6b44cd82 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Fri, 27 Apr 2018 15:12:16 +0100 Subject: [PATCH 2/2] Load babel-polyfill in the bundle entry, before index.js --- webpack.config.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/webpack.config.js b/webpack.config.js index 81e0c1794d..2a116f5777 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -8,12 +8,9 @@ if (!og_image_url) og_image_url = 'https://riot.im/app/themes/riot/img/logos/rio module.exports = { entry: { - main: [ - // Load this first to avoid issues where some imports (namely react) - // potentially before babel-polyfill. - 'babel-polyfill', - ], - "bundle": "./src/vector/index.js", + // Load babel-polyfill first to avoid issues where some imports (namely react) + // are potentially loaded before babel-polyfill. + "bundle": ["babel-polyfill", "./src/vector/index.js"], "indexeddb-worker": "./src/vector/indexeddb-worker.js", // We ship olm.js as a separate lump of javascript. This makes it get