From f240efb36df501f363333890a00af0664c6d3cb7 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 18 Feb 2019 16:13:24 +0100 Subject: [PATCH 1/5] get cache-busted url for languages.json through file-loader requiring it --- src/languageHandler.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/languageHandler.js b/src/languageHandler.js index 8735150d20..e462f05eda 100644 --- a/src/languageHandler.js +++ b/src/languageHandler.js @@ -338,8 +338,9 @@ export function getCurrentLanguage() { function getLangsJson() { return new Promise((resolve, reject) => { + const url = require("../../riot-web/webapp/i18n/languages.json"); request( - { method: "GET", url: i18nFolder + 'languages.json' }, + { method: "GET", url }, (err, response, body) => { if (err || response.status < 200 || response.status >= 300) { reject({err: err, response: response}); From 33858c8aff26f4198fed488be3e7a6d43d80d005 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 18 Feb 2019 16:26:04 +0100 Subject: [PATCH 2/5] move this path to webpack config file otherwise react-sdk wouldn't be able to build anymore without riot-web in a specific location --- src/languageHandler.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/languageHandler.js b/src/languageHandler.js index e462f05eda..33f703c204 100644 --- a/src/languageHandler.js +++ b/src/languageHandler.js @@ -338,9 +338,9 @@ export function getCurrentLanguage() { function getLangsJson() { return new Promise((resolve, reject) => { - const url = require("../../riot-web/webapp/i18n/languages.json"); + // LANGUAGES_FILE is a webpack compile-time define, see webpack config request( - { method: "GET", url }, + { method: "GET", url: require(LANGUAGES_FILE) }, (err, response, body) => { if (err || response.status < 200 || response.status >= 300) { reject({err: err, response: response}); From f51d25c394b04458e9ff4b0a02dd0907d11ea74d Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 18 Feb 2019 16:36:11 +0100 Subject: [PATCH 3/5] declare LANGUAGES_FILE as global in eslint config --- .eslintrc.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.eslintrc.js b/.eslintrc.js index 8474cd86d7..fdf0bb351e 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -15,6 +15,9 @@ module.exports = { "flowtype", "babel" ], + globals: { + LANGUAGES_FILE: "readonly", + }, env: { es6: true, }, From 6bf8269bcd03f26b2cc33910939f5cf6d972601a Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 18 Feb 2019 17:26:09 +0100 Subject: [PATCH 4/5] riot-web is a subdirectory when running the tests --- scripts/travis/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/travis/build.sh b/scripts/travis/build.sh index a353e38a06..df192d70b2 100755 --- a/scripts/travis/build.sh +++ b/scripts/travis/build.sh @@ -23,5 +23,5 @@ ln -s "$REACT_SDK_DIR/node_modules/matrix-js-sdk" node_modules/matrix-js-sdk rm -r node_modules/matrix-react-sdk ln -s "$REACT_SDK_DIR" node_modules/matrix-react-sdk -npm run build +RIOT_LANGUAGES_FILE="../riot-web/webapp/i18n/languages.json" npm run build popd From 44bedb208426b643244e2cc6e0a3f2c93b41695d Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Wed, 20 Feb 2019 09:36:18 +0100 Subject: [PATCH 5/5] fix unit tests without breaking the build --- src/languageHandler.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/languageHandler.js b/src/languageHandler.js index 33f703c204..7c1a47fed9 100644 --- a/src/languageHandler.js +++ b/src/languageHandler.js @@ -339,8 +339,9 @@ export function getCurrentLanguage() { function getLangsJson() { return new Promise((resolve, reject) => { // LANGUAGES_FILE is a webpack compile-time define, see webpack config + const url = (typeof LANGUAGES_FILE === "string") ? require(LANGUAGES_FILE) : (i18nFolder + 'languages.json'); request( - { method: "GET", url: require(LANGUAGES_FILE) }, + { method: "GET", url }, (err, response, body) => { if (err || response.status < 200 || response.status >= 300) { reject({err: err, response: response});