Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Use webpack alias to resolve the languages file #2730

Merged
merged 4 commits into from
Mar 1, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/travis/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

RIOT_LANGUAGES_FILE="../riot-web/webapp/i18n/languages.json" npm run build
npm run build
popd
4 changes: 2 additions & 2 deletions src/languageHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,8 @@ 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');
// Webapp is a webpack resolve alias pointing to the output directory, see webpack config
const url = require('Webapp/i18n/languages.json');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means the SDK now depends on Riot's Webpack config, which seems unfortunate. Maybe we can wrap this in a try and fallback to the i18nFolder version for non-Webpack/non-Riot usage?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point - this also makes the unit tests work without extra config

request(
{ method: "GET", url },
(err, response, body) => {
Expand Down