From 8e754765e2d754dcc3eaa08e23c5a8be8839c5a0 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Thu, 19 Dec 2019 18:47:11 -0700 Subject: [PATCH 1/2] Convert components to ES6 exports --- electron_app/src/updater.js | 3 +-- src/components/views/auth/VectorAuthFooter.js | 7 +++++-- src/components/views/auth/VectorCustomServerDialog.js | 7 +++++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/electron_app/src/updater.js b/electron_app/src/updater.js index 49fa4e04..bd173a90 100644 --- a/electron_app/src/updater.js +++ b/electron_app/src/updater.js @@ -18,8 +18,7 @@ function pollForUpdates() { } } -module.exports = {}; -module.exports.start = function startAutoUpdate(updateBaseUrl) { +export function start(updateBaseUrl) { if (updateBaseUrl.slice(-1) !== '/') { updateBaseUrl = updateBaseUrl + '/'; } diff --git a/src/components/views/auth/VectorAuthFooter.js b/src/components/views/auth/VectorAuthFooter.js index 574d7104..9cebecf9 100644 --- a/src/components/views/auth/VectorAuthFooter.js +++ b/src/components/views/auth/VectorAuthFooter.js @@ -20,7 +20,7 @@ import SdkConfig from 'matrix-react-sdk/lib/SdkConfig'; import { _t } from 'matrix-react-sdk/lib/languageHandler'; -module.exports = () => { +const VectorAuthFooter = () => { const brandingConfig = SdkConfig.get().branding; let links = [ {"text": "blog", "url": "https://medium.com/@RiotChat"}, @@ -48,4 +48,7 @@ module.exports = () => { ); }; -module.exports.replaces = 'AuthFooter'; + +VectorAuthFooter.replaces = 'AuthFooter'; + +export default VectorAuthFooter; diff --git a/src/components/views/auth/VectorCustomServerDialog.js b/src/components/views/auth/VectorCustomServerDialog.js index 8843ce6f..297caca6 100644 --- a/src/components/views/auth/VectorCustomServerDialog.js +++ b/src/components/views/auth/VectorCustomServerDialog.js @@ -22,7 +22,7 @@ import { _t } from 'matrix-react-sdk/lib/languageHandler'; * This is identical to `CustomServerDialog` except for replacing "this app" * with "Riot". */ -module.exports = ({onFinished}) => { +const VectorCustomServerDialog = ({onFinished}) => { return (
@@ -44,4 +44,7 @@ module.exports = ({onFinished}) => {
); }; -module.exports.replaces = 'CustomServerDialog'; + +VectorCustomServerDialog.replaces = 'CustomServerDialog'; + +export default VectorCustomServerDialog; From 17e332bb4860087abc7ba5d94e12636a6aa480ca Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Thu, 19 Dec 2019 18:47:40 -0700 Subject: [PATCH 2/2] Import from src/ for the react-sdk and js-sdk We compile directly for accuracy of sourcemaps. --- .../structures/VectorEmbeddedPage.js | 4 +-- src/components/views/auth/VectorAuthFooter.js | 5 ++-- .../views/auth/VectorAuthHeaderLogo.js | 2 +- src/components/views/auth/VectorAuthPage.js | 4 +-- .../views/auth/VectorCustomServerDialog.js | 2 +- src/vector/index.js | 26 +++++++++---------- src/vector/indexeddb-worker.js | 2 +- src/vector/platform/ElectronPlatform.js | 8 +++--- src/vector/platform/VectorBasePlatform.js | 6 ++--- src/vector/platform/WebPlatform.js | 4 +-- src/vector/rageshakesetup.js | 6 ++--- test/app-tests/joining.js | 6 ++--- test/app-tests/loading.js | 14 +++++----- 13 files changed, 44 insertions(+), 45 deletions(-) diff --git a/src/components/structures/VectorEmbeddedPage.js b/src/components/structures/VectorEmbeddedPage.js index ab093135..1c3a1067 100644 --- a/src/components/structures/VectorEmbeddedPage.js +++ b/src/components/structures/VectorEmbeddedPage.js @@ -18,9 +18,9 @@ limitations under the License. 'use strict'; -import EmbeddedPage from 'matrix-react-sdk/lib/components/structures/EmbeddedPage'; +import EmbeddedPage from 'matrix-react-sdk/src/components/structures/EmbeddedPage'; import sanitizeHtml from 'sanitize-html'; -import { _t } from 'matrix-react-sdk/lib/languageHandler'; +import { _t } from 'matrix-react-sdk/src/languageHandler'; export default class VectorEmbeddedPage extends EmbeddedPage { static replaces = 'EmbeddedPage'; diff --git a/src/components/views/auth/VectorAuthFooter.js b/src/components/views/auth/VectorAuthFooter.js index 574d7104..49c3a46b 100644 --- a/src/components/views/auth/VectorAuthFooter.js +++ b/src/components/views/auth/VectorAuthFooter.js @@ -16,9 +16,8 @@ limitations under the License. */ import React from 'react'; -import SdkConfig from 'matrix-react-sdk/lib/SdkConfig'; - -import { _t } from 'matrix-react-sdk/lib/languageHandler'; +import SdkConfig from 'matrix-react-sdk/src/SdkConfig'; +import { _t } from 'matrix-react-sdk/src/languageHandler'; module.exports = () => { const brandingConfig = SdkConfig.get().branding; diff --git a/src/components/views/auth/VectorAuthHeaderLogo.js b/src/components/views/auth/VectorAuthHeaderLogo.js index 0161fc3f..04973fe2 100644 --- a/src/components/views/auth/VectorAuthHeaderLogo.js +++ b/src/components/views/auth/VectorAuthHeaderLogo.js @@ -19,7 +19,7 @@ limitations under the License. import React from 'react'; import PropTypes from 'prop-types'; -import SdkConfig from 'matrix-react-sdk/lib/SdkConfig'; +import SdkConfig from 'matrix-react-sdk/src/SdkConfig'; export default class VectorAuthHeaderLogo extends React.PureComponent { static replaces = 'AuthHeaderLogo' diff --git a/src/components/views/auth/VectorAuthPage.js b/src/components/views/auth/VectorAuthPage.js index bae685b9..98ddb8ba 100644 --- a/src/components/views/auth/VectorAuthPage.js +++ b/src/components/views/auth/VectorAuthPage.js @@ -17,8 +17,8 @@ limitations under the License. 'use strict'; import React from 'react'; -import sdk from 'matrix-react-sdk/lib/index'; -import SdkConfig from 'matrix-react-sdk/lib/SdkConfig'; +import * as sdk from 'matrix-react-sdk/src/index'; +import SdkConfig from 'matrix-react-sdk/src/SdkConfig'; export default class VectorAuthPage extends React.PureComponent { static replaces = 'AuthPage' diff --git a/src/components/views/auth/VectorCustomServerDialog.js b/src/components/views/auth/VectorCustomServerDialog.js index 8843ce6f..bac9a4ad 100644 --- a/src/components/views/auth/VectorCustomServerDialog.js +++ b/src/components/views/auth/VectorCustomServerDialog.js @@ -16,7 +16,7 @@ limitations under the License. */ import React from "react"; -import { _t } from 'matrix-react-sdk/lib/languageHandler'; +import { _t } from 'matrix-react-sdk/src/languageHandler'; /** * This is identical to `CustomServerDialog` except for replacing "this app" diff --git a/src/vector/index.js b/src/vector/index.js index 12c0cfe8..aa7bf3c1 100644 --- a/src/vector/index.js +++ b/src/vector/index.js @@ -35,15 +35,15 @@ global.React = React; import './modernizr'; import ReactDOM from 'react-dom'; -import sdk from 'matrix-react-sdk'; -import PlatformPeg from 'matrix-react-sdk/lib/PlatformPeg'; +import * as sdk from 'matrix-react-sdk'; +import PlatformPeg from 'matrix-react-sdk/src/PlatformPeg'; sdk.loadSkin(require('../component-index')); -import VectorConferenceHandler from 'matrix-react-sdk/lib/VectorConferenceHandler'; -import * as languageHandler from 'matrix-react-sdk/lib/languageHandler'; -import {_t, _td, newTranslatableError} from 'matrix-react-sdk/lib/languageHandler'; -import AutoDiscoveryUtils from 'matrix-react-sdk/lib/utils/AutoDiscoveryUtils'; -import {AutoDiscovery} from "matrix-js-sdk/lib/autodiscovery"; -import * as Lifecycle from "matrix-react-sdk/lib/Lifecycle"; +import * as VectorConferenceHandler from 'matrix-react-sdk/src/VectorConferenceHandler'; +import * as languageHandler from 'matrix-react-sdk/src/languageHandler'; +import {_t, _td, newTranslatableError} from 'matrix-react-sdk/src/languageHandler'; +import AutoDiscoveryUtils from 'matrix-react-sdk/src/utils/AutoDiscoveryUtils'; +import {AutoDiscovery} from "matrix-js-sdk/src/autodiscovery"; +import * as Lifecycle from "matrix-react-sdk/src/Lifecycle"; import url from 'url'; @@ -52,14 +52,14 @@ import {parseQs, parseQsFromFragment} from './url_utils'; import ElectronPlatform from './platform/ElectronPlatform'; import WebPlatform from './platform/WebPlatform'; -import MatrixClientPeg from 'matrix-react-sdk/lib/MatrixClientPeg'; -import SettingsStore from "matrix-react-sdk/lib/settings/SettingsStore"; -import SdkConfig from "matrix-react-sdk/lib/SdkConfig"; -import {setTheme} from "matrix-react-sdk/lib/theme"; +import {MatrixClientPeg} from 'matrix-react-sdk/src/MatrixClientPeg'; +import SettingsStore from "matrix-react-sdk/src/settings/SettingsStore"; +import SdkConfig from "matrix-react-sdk/src/SdkConfig"; +import {setTheme} from "matrix-react-sdk/src/theme"; import Olm from 'olm'; -import CallHandler from 'matrix-react-sdk/lib/CallHandler'; +import CallHandler from 'matrix-react-sdk/src/CallHandler'; let lastLocationHashSet = null; diff --git a/src/vector/indexeddb-worker.js b/src/vector/indexeddb-worker.js index 3e1fe35c..3cb2cb9f 100644 --- a/src/vector/indexeddb-worker.js +++ b/src/vector/indexeddb-worker.js @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -import {IndexedDBStoreWorker} from 'matrix-js-sdk/lib/indexeddb-worker.js'; +import {IndexedDBStoreWorker} from 'matrix-js-sdk/src/indexeddb-worker.js'; const remoteWorker = new IndexedDBStoreWorker(postMessage); diff --git a/src/vector/platform/ElectronPlatform.js b/src/vector/platform/ElectronPlatform.js index 1128c33f..9968504a 100644 --- a/src/vector/platform/ElectronPlatform.js +++ b/src/vector/platform/ElectronPlatform.js @@ -20,10 +20,10 @@ limitations under the License. */ import VectorBasePlatform, {updateCheckStatusEnum} from './VectorBasePlatform'; -import BaseEventIndexManager from 'matrix-react-sdk/lib/indexing/BaseEventIndexManager'; -import dis from 'matrix-react-sdk/lib/dispatcher'; -import { _t } from 'matrix-react-sdk/lib/languageHandler'; -import rageshake from 'matrix-react-sdk/lib/rageshake/rageshake'; +import BaseEventIndexManager from 'matrix-react-sdk/src/indexing/BaseEventIndexManager'; +import dis from 'matrix-react-sdk/src/dispatcher'; +import { _t } from 'matrix-react-sdk/src/languageHandler'; +import * as rageshake from 'matrix-react-sdk/src/rageshake/rageshake'; const ipcRenderer = window.ipcRenderer; diff --git a/src/vector/platform/VectorBasePlatform.js b/src/vector/platform/VectorBasePlatform.js index 376b0a0e..3b8d3c2c 100644 --- a/src/vector/platform/VectorBasePlatform.js +++ b/src/vector/platform/VectorBasePlatform.js @@ -19,9 +19,9 @@ See the License for the specific language governing permissions and limitations under the License. */ -import BasePlatform from 'matrix-react-sdk/lib/BasePlatform'; -import { _t } from 'matrix-react-sdk/lib/languageHandler'; -import dis from 'matrix-react-sdk/lib/dispatcher'; +import BasePlatform from 'matrix-react-sdk/src/BasePlatform'; +import { _t } from 'matrix-react-sdk/src/languageHandler'; +import dis from 'matrix-react-sdk/src/dispatcher'; import {getVectorConfig} from "../getconfig"; import Favico from 'favico.js'; diff --git a/src/vector/platform/WebPlatform.js b/src/vector/platform/WebPlatform.js index c9ccef5b..4ad96dec 100644 --- a/src/vector/platform/WebPlatform.js +++ b/src/vector/platform/WebPlatform.js @@ -19,8 +19,8 @@ limitations under the License. import VectorBasePlatform, {updateCheckStatusEnum} from './VectorBasePlatform'; import request from 'browser-request'; -import dis from 'matrix-react-sdk/lib/dispatcher.js'; -import { _t } from 'matrix-react-sdk/lib/languageHandler'; +import dis from 'matrix-react-sdk/src/dispatcher.js'; +import { _t } from 'matrix-react-sdk/src/languageHandler'; import url from 'url'; import UAParser from 'ua-parser-js'; diff --git a/src/vector/rageshakesetup.js b/src/vector/rageshakesetup.js index e1dc5e24..0369a443 100644 --- a/src/vector/rageshakesetup.js +++ b/src/vector/rageshakesetup.js @@ -25,8 +25,8 @@ limitations under the License. * from the rageshake.) */ -import rageshake from "matrix-react-sdk/lib/rageshake/rageshake"; -import SdkConfig from "matrix-react-sdk/lib/SdkConfig"; +import * as rageshake from "matrix-react-sdk/src/rageshake/rageshake"; +import SdkConfig from "matrix-react-sdk/src/SdkConfig"; function initRageshake() { rageshake.init().then(() => { @@ -54,7 +54,7 @@ global.mxSendRageshake = function(text, withLogs) { console.error("Cannot send a rageshake without a message - please tell us what went wrong"); return; } - require(['matrix-react-sdk/lib/rageshake/submit-rageshake'], (s) => { + require(['matrix-react-sdk/src/rageshake/submit-rageshake'], (s) => { s(SdkConfig.get().bug_report_endpoint_url, { userText: text, sendLogs: withLogs, diff --git a/test/app-tests/joining.js b/test/app-tests/joining.js index 95a917e3..e201cc68 100644 --- a/test/app-tests/joining.js +++ b/test/app-tests/joining.js @@ -16,7 +16,7 @@ limitations under the License. /* joining.js: tests for the various paths when joining a room */ -import PlatformPeg from 'matrix-react-sdk/lib/PlatformPeg'; +import PlatformPeg from 'matrix-react-sdk/src/PlatformPeg'; import WebPlatform from '../../src/vector/platform/WebPlatform'; require('skin-sdk'); @@ -33,8 +33,8 @@ const React = require('react'); const ReactDOM = require('react-dom'); const ReactTestUtils = require('react-dom/test-utils'); const expect = require('expect'); -import {makeType} from "matrix-react-sdk/lib/utils/TypeUtils"; -import {ValidatedServerConfig} from "matrix-react-sdk/lib/utils/AutoDiscoveryUtils"; +import {makeType} from "matrix-react-sdk/src/utils/TypeUtils"; +import {ValidatedServerConfig} from "matrix-react-sdk/src/utils/AutoDiscoveryUtils"; import {sleep} from "../test-utils"; const test_utils = require('../test-utils'); diff --git a/test/app-tests/loading.js b/test/app-tests/loading.js index a65383bc..836e3514 100644 --- a/test/app-tests/loading.js +++ b/test/app-tests/loading.js @@ -16,7 +16,7 @@ limitations under the License. /* loading.js: test the myriad paths we have for loading the application */ -import PlatformPeg from 'matrix-react-sdk/lib/PlatformPeg'; +import PlatformPeg from 'matrix-react-sdk/src/PlatformPeg'; import WebPlatform from '../../src/vector/platform/WebPlatform'; import 'skin-sdk'; @@ -30,16 +30,16 @@ import MatrixReactTestUtils from 'matrix-react-test-utils'; import jssdk from 'matrix-js-sdk'; import sdk from 'matrix-react-sdk'; -import MatrixClientPeg from 'matrix-react-sdk/lib/MatrixClientPeg'; -import * as languageHandler from 'matrix-react-sdk/lib/languageHandler'; -import {VIEWS} from 'matrix-react-sdk/lib/components/structures/MatrixChat'; -import dis from 'matrix-react-sdk/lib/dispatcher'; +import {MatrixClientPeg} from 'matrix-react-sdk/src/MatrixClientPeg'; +import * as languageHandler from 'matrix-react-sdk/src/languageHandler'; +import {VIEWS} from 'matrix-react-sdk/src/components/structures/MatrixChat'; +import dis from 'matrix-react-sdk/src/dispatcher'; import * as test_utils from '../test-utils'; import MockHttpBackend from 'matrix-mock-request'; import {parseQs, parseQsFromFragment} from '../../src/vector/url_utils'; -import {makeType} from "matrix-react-sdk/lib/utils/TypeUtils"; -import {ValidatedServerConfig} from "matrix-react-sdk/lib/utils/AutoDiscoveryUtils"; +import {makeType} from "matrix-react-sdk/src/utils/TypeUtils"; +import {ValidatedServerConfig} from "matrix-react-sdk/src/utils/AutoDiscoveryUtils"; import {sleep} from "../test-utils"; const DEFAULT_HS_URL='http://my_server';