Bug 1533872 - Separate matrix-js-sdk files from other Node packages. rs=florian
authorPatrick Cloke <clokep@gmail.com>
Tue, 22 Oct 2019 12:07:03 -0400
changeset 37319 64c4bc07ed19f7f358fc2e8a8805977d6c0d73e8
parent 37318 7c4a9a0edb69615ac1e336874ac7e0befb7942c0
child 37320 d296be7570aebc76856d3539c51a698ce199b1ef
push id396
push userclokep@gmail.com
push dateMon, 06 Jan 2020 23:11:57 +0000
reviewersflorian
bugs1533872
Bug 1533872 - Separate matrix-js-sdk files from other Node packages. rs=florian
.eslintignore
chat/protocols/matrix/lib/README.txt
chat/protocols/matrix/lib/another-json/another-json.js
chat/protocols/matrix/lib/browser-request/index.js
chat/protocols/matrix/lib/events/events.js
chat/protocols/matrix/lib/matrix-sdk/base-apis.js
chat/protocols/matrix/lib/matrix-sdk/client.js
chat/protocols/matrix/lib/matrix-sdk/content-repo.js
chat/protocols/matrix/lib/matrix-sdk/crypto/OlmDevice.js
chat/protocols/matrix/lib/matrix-sdk/crypto/algorithms/base.js
chat/protocols/matrix/lib/matrix-sdk/crypto/algorithms/index.js
chat/protocols/matrix/lib/matrix-sdk/crypto/algorithms/megolm.js
chat/protocols/matrix/lib/matrix-sdk/crypto/algorithms/olm.js
chat/protocols/matrix/lib/matrix-sdk/crypto/deviceinfo.js
chat/protocols/matrix/lib/matrix-sdk/crypto/index.js
chat/protocols/matrix/lib/matrix-sdk/crypto/olmlib.js
chat/protocols/matrix/lib/matrix-sdk/filter-component.js
chat/protocols/matrix/lib/matrix-sdk/filter.js
chat/protocols/matrix/lib/matrix-sdk/http-api.js
chat/protocols/matrix/lib/matrix-sdk/interactive-auth.js
chat/protocols/matrix/lib/matrix-sdk/matrix.js
chat/protocols/matrix/lib/matrix-sdk/models/event-context.js
chat/protocols/matrix/lib/matrix-sdk/models/event-timeline-set.js
chat/protocols/matrix/lib/matrix-sdk/models/event-timeline.js
chat/protocols/matrix/lib/matrix-sdk/models/event.js
chat/protocols/matrix/lib/matrix-sdk/models/room-member.js
chat/protocols/matrix/lib/matrix-sdk/models/room-state.js
chat/protocols/matrix/lib/matrix-sdk/models/room-summary.js
chat/protocols/matrix/lib/matrix-sdk/models/room.js
chat/protocols/matrix/lib/matrix-sdk/models/search-result.js
chat/protocols/matrix/lib/matrix-sdk/models/user.js
chat/protocols/matrix/lib/matrix-sdk/pushprocessor.js
chat/protocols/matrix/lib/matrix-sdk/realtime-callbacks.js
chat/protocols/matrix/lib/matrix-sdk/scheduler.js
chat/protocols/matrix/lib/matrix-sdk/store/memory.js
chat/protocols/matrix/lib/matrix-sdk/store/session/webstorage.js
chat/protocols/matrix/lib/matrix-sdk/store/stub.js
chat/protocols/matrix/lib/matrix-sdk/store/webstorage.js
chat/protocols/matrix/lib/matrix-sdk/sync.js
chat/protocols/matrix/lib/matrix-sdk/timeline-window.js
chat/protocols/matrix/lib/matrix-sdk/utils.js
chat/protocols/matrix/lib/matrix-sdk/webrtc/call.js
chat/protocols/matrix/lib/moz.build
chat/protocols/matrix/lib/punycode/punycode.js
chat/protocols/matrix/lib/q/q.js
chat/protocols/matrix/lib/q/queue.js
chat/protocols/matrix/lib/querystring/decode.js
chat/protocols/matrix/lib/querystring/encode.js
chat/protocols/matrix/lib/querystring/index.js
chat/protocols/matrix/lib/url/url.js
chat/protocols/matrix/matrix-sdk.jsm
chat/protocols/matrix/matrix-sdk/README.txt
chat/protocols/matrix/matrix-sdk/another-json/another-json.js
chat/protocols/matrix/matrix-sdk/base-apis.js
chat/protocols/matrix/matrix-sdk/browser-request/index.js
chat/protocols/matrix/matrix-sdk/browserify/events.js
chat/protocols/matrix/matrix-sdk/browserify/punycode.js
chat/protocols/matrix/matrix-sdk/browserify/querystring/decode.js
chat/protocols/matrix/matrix-sdk/browserify/querystring/encode.js
chat/protocols/matrix/matrix-sdk/browserify/querystring/index.js
chat/protocols/matrix/matrix-sdk/browserify/url.js
chat/protocols/matrix/matrix-sdk/client.js
chat/protocols/matrix/matrix-sdk/content-repo.js
chat/protocols/matrix/matrix-sdk/crypto/OlmDevice.js
chat/protocols/matrix/matrix-sdk/crypto/algorithms/base.js
chat/protocols/matrix/matrix-sdk/crypto/algorithms/index.js
chat/protocols/matrix/matrix-sdk/crypto/algorithms/megolm.js
chat/protocols/matrix/matrix-sdk/crypto/algorithms/olm.js
chat/protocols/matrix/matrix-sdk/crypto/deviceinfo.js
chat/protocols/matrix/matrix-sdk/crypto/index.js
chat/protocols/matrix/matrix-sdk/crypto/olmlib.js
chat/protocols/matrix/matrix-sdk/filter-component.js
chat/protocols/matrix/matrix-sdk/filter.js
chat/protocols/matrix/matrix-sdk/http-api.js
chat/protocols/matrix/matrix-sdk/interactive-auth.js
chat/protocols/matrix/matrix-sdk/matrix.js
chat/protocols/matrix/matrix-sdk/models/event-context.js
chat/protocols/matrix/matrix-sdk/models/event-timeline-set.js
chat/protocols/matrix/matrix-sdk/models/event-timeline.js
chat/protocols/matrix/matrix-sdk/models/event.js
chat/protocols/matrix/matrix-sdk/models/room-member.js
chat/protocols/matrix/matrix-sdk/models/room-state.js
chat/protocols/matrix/matrix-sdk/models/room-summary.js
chat/protocols/matrix/matrix-sdk/models/room.js
chat/protocols/matrix/matrix-sdk/models/search-result.js
chat/protocols/matrix/matrix-sdk/models/user.js
chat/protocols/matrix/matrix-sdk/moz.build
chat/protocols/matrix/matrix-sdk/pushprocessor.js
chat/protocols/matrix/matrix-sdk/q/q.js
chat/protocols/matrix/matrix-sdk/q/queue.js
chat/protocols/matrix/matrix-sdk/realtime-callbacks.js
chat/protocols/matrix/matrix-sdk/scheduler.js
chat/protocols/matrix/matrix-sdk/store/memory.js
chat/protocols/matrix/matrix-sdk/store/session/webstorage.js
chat/protocols/matrix/matrix-sdk/store/stub.js
chat/protocols/matrix/matrix-sdk/store/webstorage.js
chat/protocols/matrix/matrix-sdk/sync.js
chat/protocols/matrix/matrix-sdk/timeline-window.js
chat/protocols/matrix/matrix-sdk/utils.js
chat/protocols/matrix/matrix-sdk/webrtc/call.js
chat/protocols/matrix/moz.build
--- a/.eslintignore
+++ b/.eslintignore
@@ -24,17 +24,17 @@ common/src/viewSource.xul
 # below.
 build/**
 suite/**
 
 # chat exclusions
 chat/chat-prefs.js
 # third-party code
 chat/modules/BigInteger.jsm
-chat/protocols/matrix/matrix-sdk/**
+chat/protocols/matrix/lib/**
 chat/protocols/twitter/twitter-text.jsm
 # preprocessed files
 chat/content/imtooltip.xml
 
 # editor exclusions (most files not shipped with Thunderbird)
 editor/ui/composer.js
 editor/ui/composer/content/**
 !editor/ui/composer/content/editor.js
rename from chat/protocols/matrix/matrix-sdk/README.txt
rename to chat/protocols/matrix/lib/README.txt
--- a/chat/protocols/matrix/matrix-sdk/README.txt
+++ b/chat/protocols/matrix/lib/README.txt
@@ -1,20 +1,19 @@
 This directory contains the Matrix Client-Server SDK for Javascript available
 at https://github.com/matrix-org/matrix-js-sdk/. Current version is v0.7.0.
 
 In addition, the following npm dependencies are included:
 
 * another-json/: https://www.npmjs.com/package/another-json/
 * browser-request/: https://www.npmjs.com/package/browser-request
-* browserify/: https://www.npmjs.com/package/browserify
-  * browserify/events.js: https://www.npmjs.com/package/events
-  * browserify/punycode.js: https://github.com/bestiejs/punycode.js
-  * browserify/querystring/: https://www.npmjs.com/package/querystring-es3
-  * browserify/url/: https://www.npmjs.com/package/url
+* events: https://www.npmjs.com/package/events
+* punycode: https://github.com/bestiejs/punycode.js
+* querystring: https://www.npmjs.com/package/querystring-es3
+* url: https://www.npmjs.com/package/url
 * q/: https://www.npmjs.com/package/q
 
 There is not any automated way to update the libraries. Files have been obtained
 by downloading the matrix-js-sdk release, compiling it with npm (to obtain the
 dependencies), excluding some unneeded files from the dependencies and
 optionally adding copyright notices from the original repository mentioned on
 the npm page.
 
rename from chat/protocols/matrix/matrix-sdk/another-json/another-json.js
rename to chat/protocols/matrix/lib/another-json/another-json.js
rename from chat/protocols/matrix/matrix-sdk/browser-request/index.js
rename to chat/protocols/matrix/lib/browser-request/index.js
rename from chat/protocols/matrix/matrix-sdk/browserify/events.js
rename to chat/protocols/matrix/lib/events/events.js
rename from chat/protocols/matrix/matrix-sdk/base-apis.js
rename to chat/protocols/matrix/lib/matrix-sdk/base-apis.js
rename from chat/protocols/matrix/matrix-sdk/client.js
rename to chat/protocols/matrix/lib/matrix-sdk/client.js
rename from chat/protocols/matrix/matrix-sdk/content-repo.js
rename to chat/protocols/matrix/lib/matrix-sdk/content-repo.js
rename from chat/protocols/matrix/matrix-sdk/crypto/OlmDevice.js
rename to chat/protocols/matrix/lib/matrix-sdk/crypto/OlmDevice.js
rename from chat/protocols/matrix/matrix-sdk/crypto/algorithms/base.js
rename to chat/protocols/matrix/lib/matrix-sdk/crypto/algorithms/base.js
rename from chat/protocols/matrix/matrix-sdk/crypto/algorithms/index.js
rename to chat/protocols/matrix/lib/matrix-sdk/crypto/algorithms/index.js
rename from chat/protocols/matrix/matrix-sdk/crypto/algorithms/megolm.js
rename to chat/protocols/matrix/lib/matrix-sdk/crypto/algorithms/megolm.js
rename from chat/protocols/matrix/matrix-sdk/crypto/algorithms/olm.js
rename to chat/protocols/matrix/lib/matrix-sdk/crypto/algorithms/olm.js
rename from chat/protocols/matrix/matrix-sdk/crypto/deviceinfo.js
rename to chat/protocols/matrix/lib/matrix-sdk/crypto/deviceinfo.js
rename from chat/protocols/matrix/matrix-sdk/crypto/index.js
rename to chat/protocols/matrix/lib/matrix-sdk/crypto/index.js
rename from chat/protocols/matrix/matrix-sdk/crypto/olmlib.js
rename to chat/protocols/matrix/lib/matrix-sdk/crypto/olmlib.js
rename from chat/protocols/matrix/matrix-sdk/filter-component.js
rename to chat/protocols/matrix/lib/matrix-sdk/filter-component.js
rename from chat/protocols/matrix/matrix-sdk/filter.js
rename to chat/protocols/matrix/lib/matrix-sdk/filter.js
rename from chat/protocols/matrix/matrix-sdk/http-api.js
rename to chat/protocols/matrix/lib/matrix-sdk/http-api.js
rename from chat/protocols/matrix/matrix-sdk/interactive-auth.js
rename to chat/protocols/matrix/lib/matrix-sdk/interactive-auth.js
rename from chat/protocols/matrix/matrix-sdk/matrix.js
rename to chat/protocols/matrix/lib/matrix-sdk/matrix.js
rename from chat/protocols/matrix/matrix-sdk/models/event-context.js
rename to chat/protocols/matrix/lib/matrix-sdk/models/event-context.js
rename from chat/protocols/matrix/matrix-sdk/models/event-timeline-set.js
rename to chat/protocols/matrix/lib/matrix-sdk/models/event-timeline-set.js
rename from chat/protocols/matrix/matrix-sdk/models/event-timeline.js
rename to chat/protocols/matrix/lib/matrix-sdk/models/event-timeline.js
rename from chat/protocols/matrix/matrix-sdk/models/event.js
rename to chat/protocols/matrix/lib/matrix-sdk/models/event.js
rename from chat/protocols/matrix/matrix-sdk/models/room-member.js
rename to chat/protocols/matrix/lib/matrix-sdk/models/room-member.js
rename from chat/protocols/matrix/matrix-sdk/models/room-state.js
rename to chat/protocols/matrix/lib/matrix-sdk/models/room-state.js
rename from chat/protocols/matrix/matrix-sdk/models/room-summary.js
rename to chat/protocols/matrix/lib/matrix-sdk/models/room-summary.js
rename from chat/protocols/matrix/matrix-sdk/models/room.js
rename to chat/protocols/matrix/lib/matrix-sdk/models/room.js
rename from chat/protocols/matrix/matrix-sdk/models/search-result.js
rename to chat/protocols/matrix/lib/matrix-sdk/models/search-result.js
rename from chat/protocols/matrix/matrix-sdk/models/user.js
rename to chat/protocols/matrix/lib/matrix-sdk/models/user.js
rename from chat/protocols/matrix/matrix-sdk/pushprocessor.js
rename to chat/protocols/matrix/lib/matrix-sdk/pushprocessor.js
rename from chat/protocols/matrix/matrix-sdk/realtime-callbacks.js
rename to chat/protocols/matrix/lib/matrix-sdk/realtime-callbacks.js
rename from chat/protocols/matrix/matrix-sdk/scheduler.js
rename to chat/protocols/matrix/lib/matrix-sdk/scheduler.js
rename from chat/protocols/matrix/matrix-sdk/store/memory.js
rename to chat/protocols/matrix/lib/matrix-sdk/store/memory.js
rename from chat/protocols/matrix/matrix-sdk/store/session/webstorage.js
rename to chat/protocols/matrix/lib/matrix-sdk/store/session/webstorage.js
rename from chat/protocols/matrix/matrix-sdk/store/stub.js
rename to chat/protocols/matrix/lib/matrix-sdk/store/stub.js
rename from chat/protocols/matrix/matrix-sdk/store/webstorage.js
rename to chat/protocols/matrix/lib/matrix-sdk/store/webstorage.js
rename from chat/protocols/matrix/matrix-sdk/sync.js
rename to chat/protocols/matrix/lib/matrix-sdk/sync.js
rename from chat/protocols/matrix/matrix-sdk/timeline-window.js
rename to chat/protocols/matrix/lib/matrix-sdk/timeline-window.js
rename from chat/protocols/matrix/matrix-sdk/utils.js
rename to chat/protocols/matrix/lib/matrix-sdk/utils.js
rename from chat/protocols/matrix/matrix-sdk/webrtc/call.js
rename to chat/protocols/matrix/lib/matrix-sdk/webrtc/call.js
rename from chat/protocols/matrix/matrix-sdk/moz.build
rename to chat/protocols/matrix/lib/moz.build
--- a/chat/protocols/matrix/matrix-sdk/moz.build
+++ b/chat/protocols/matrix/lib/moz.build
@@ -1,87 +1,89 @@
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-EXTRA_JS_MODULES.matrix += [
-    'base-apis.js',
-    'client.js',
-    'content-repo.js',
-    'filter-component.js',
-    'filter.js',
-    'http-api.js',
-    'interactive-auth.js',
-    'matrix.js',
-    'pushprocessor.js',
-    'realtime-callbacks.js',
-    'scheduler.js',
-    'sync.js',
-    'timeline-window.js',
-    'utils.js',
+# The Matrix SDK.
+EXTRA_JS_MODULES.matrix.matrix_sdk += [
+    'matrix-sdk/base-apis.js',
+    'matrix-sdk/client.js',
+    'matrix-sdk/content-repo.js',
+    'matrix-sdk/filter-component.js',
+    'matrix-sdk/filter.js',
+    'matrix-sdk/http-api.js',
+    'matrix-sdk/interactive-auth.js',
+    'matrix-sdk/matrix.js',
+    'matrix-sdk/pushprocessor.js',
+    'matrix-sdk/realtime-callbacks.js',
+    'matrix-sdk/scheduler.js',
+    'matrix-sdk/sync.js',
+    'matrix-sdk/timeline-window.js',
+    'matrix-sdk/utils.js',
+]
+
+EXTRA_JS_MODULES.matrix.matrix_sdk.crypto += [
+    'matrix-sdk/crypto/deviceinfo.js',
+    'matrix-sdk/crypto/index.js',
+    'matrix-sdk/crypto/OlmDevice.js',
+    'matrix-sdk/crypto/olmlib.js',
+]
+
+EXTRA_JS_MODULES.matrix.matrix_sdk.crypto.algorithms += [
+    'matrix-sdk/crypto/algorithms/base.js',
+    'matrix-sdk/crypto/algorithms/index.js',
+    'matrix-sdk/crypto/algorithms/megolm.js',
+    'matrix-sdk/crypto/algorithms/olm.js',
 ]
 
-EXTRA_JS_MODULES.matrix.another_json += [
-    'another-json/another-json.js',
+EXTRA_JS_MODULES.matrix.matrix_sdk.models += [
+    'matrix-sdk/models/event-context.js',
+    'matrix-sdk/models/event-timeline-set.js',
+    'matrix-sdk/models/event-timeline.js',
+    'matrix-sdk/models/event.js',
+    'matrix-sdk/models/room-member.js',
+    'matrix-sdk/models/room-state.js',
+    'matrix-sdk/models/room-summary.js',
+    'matrix-sdk/models/room.js',
+    'matrix-sdk/models/search-result.js',
+    'matrix-sdk/models/user.js',
+]
+
+EXTRA_JS_MODULES.matrix.matrix_sdk.store += [
+    'matrix-sdk/store/memory.js',
+    'matrix-sdk/store/stub.js',
+    'matrix-sdk/store/webstorage.js',
 ]
 
-EXTRA_JS_MODULES.matrix.browserify += [
-    'browserify/events.js',
-    'browserify/punycode.js',
-    'browserify/url.js',
+EXTRA_JS_MODULES.matrix.matrix_sdk.store.session += [
+    'matrix-sdk/store/session/webstorage.js',
+]
+
+EXTRA_JS_MODULES.matrix.matrix_sdk.webrtc += [
+    'matrix-sdk/webrtc/call.js',
 ]
 
-EXTRA_JS_MODULES.matrix.browserify.querystring += [
-    'browserify/querystring/decode.js',
-    'browserify/querystring/encode.js',
-    'browserify/querystring/index.js',
+# Dependencies of the Matrix SDK.
+
+# Single file dependencies (with good names) are just added to the top-level
+# matrix module.
+EXTRA_JS_MODULES.matrix += [
+    'another-json/another-json.js',
+    'events/events.js',
+    'punycode/punycode.js',
+    'url/url.js',
+]
+
+EXTRA_JS_MODULES.matrix.querystring += [
+    'querystring/decode.js',
+    'querystring/encode.js',
+    'querystring/index.js',
 ]
 
 EXTRA_JS_MODULES.matrix.browser_request += [
     'browser-request/index.js',
 ]
 
-EXTRA_JS_MODULES.matrix.crypto += [
-    'crypto/deviceinfo.js',
-    'crypto/index.js',
-    'crypto/OlmDevice.js',
-    'crypto/olmlib.js',
-]
-
-EXTRA_JS_MODULES.matrix.crypto.algorithms += [
-    'crypto/algorithms/base.js',
-    'crypto/algorithms/index.js',
-    'crypto/algorithms/megolm.js',
-    'crypto/algorithms/olm.js',
-]
-
-EXTRA_JS_MODULES.matrix.models += [
-    'models/event-context.js',
-    'models/event-timeline-set.js',
-    'models/event-timeline.js',
-    'models/event.js',
-    'models/room-member.js',
-    'models/room-state.js',
-    'models/room-summary.js',
-    'models/room.js',
-    'models/search-result.js',
-    'models/user.js',
-]
-
 EXTRA_JS_MODULES.matrix.q += [
     'q/q.js',
     'q/queue.js',
 ]
-
-EXTRA_JS_MODULES.matrix.store += [
-    'store/memory.js',
-    'store/stub.js',
-    'store/webstorage.js',
-]
-
-EXTRA_JS_MODULES.matrix.store.session += [
-    'store/session/webstorage.js',
-]
-
-EXTRA_JS_MODULES.matrix.webrtc += [
-    'webrtc/call.js',
-]
rename from chat/protocols/matrix/matrix-sdk/browserify/punycode.js
rename to chat/protocols/matrix/lib/punycode/punycode.js
rename from chat/protocols/matrix/matrix-sdk/q/q.js
rename to chat/protocols/matrix/lib/q/q.js
rename from chat/protocols/matrix/matrix-sdk/q/queue.js
rename to chat/protocols/matrix/lib/q/queue.js
rename from chat/protocols/matrix/matrix-sdk/browserify/querystring/decode.js
rename to chat/protocols/matrix/lib/querystring/decode.js
rename from chat/protocols/matrix/matrix-sdk/browserify/querystring/encode.js
rename to chat/protocols/matrix/lib/querystring/encode.js
rename from chat/protocols/matrix/matrix-sdk/browserify/querystring/index.js
rename to chat/protocols/matrix/lib/querystring/index.js
rename from chat/protocols/matrix/matrix-sdk/browserify/url.js
rename to chat/protocols/matrix/lib/url/url.js
--- a/chat/protocols/matrix/matrix-sdk.jsm
+++ b/chat/protocols/matrix/matrix-sdk.jsm
@@ -12,90 +12,114 @@ const {
 
 const { Loader, Require, Module } = ChromeUtils.import(
   "resource://devtools/shared/base-loader.js"
 );
 
 this.EXPORTED_SYMBOLS = ["MatrixSDK"];
 
 // Set-up loading so require works properly in CommonJS modules.
+//
+// These are organized in a somewhat funky way:
+// * First they're ordered by module.
+// * Then they're ordered alphabetically by the destination file (e.g. this
+//   keeps all references to utils.js next to each other).
+// * They're then ordered by source, with the bare name first, then prefixed by
+//   ., then prefixed by .., etc.
 let matrixPath = "resource:///modules/matrix/";
 let loader = Loader({
   paths: {
-    "": matrixPath,
-    "../../utils": matrixPath + "utils.js",
-    "../content-repo": matrixPath + "content-repo.js",
-    "../deviceinfo": matrixPath + "crypto/deviceinfo.js",
-    "../models/event": matrixPath + "models/event.js",
-    "../models/room": matrixPath + "models/room.js",
-    "../models/user": matrixPath + "models/user.js",
-    "../olmlib": matrixPath + "crypto/olmlib.js",
-    "../utils": matrixPath + "utils.js",
-    "./../../utils": matrixPath + "utils.js",
-    "./OlmDevice": matrixPath + "crypto/OlmDevice.js",
-    "./algorithms": matrixPath + "crypto/algorithms/index.js",
-    "./base": matrixPath + "crypto/algorithms/base.js",
-    "./base-apis": matrixPath + "base-apis.js",
-    "./client": matrixPath + "client.js",
-    "./content-repo": matrixPath + "content-repo.js",
-    "./crypto": matrixPath + "crypto/index.js",
-    "./decode": matrixPath + "browserify/querystring/decode.js",
-    "./deviceinfo": matrixPath + "crypto/deviceinfo.js",
-    "./encode": matrixPath + "browserify/querystring/encode.js",
-    "./event": matrixPath + "models/event.js",
-    "./event-context": matrixPath + "models/event-content.js",
-    "./event-timeline": matrixPath + "models/event-timeline.js",
-    "./event-timeline-set": matrixPath + "models/event-timeline-set.js",
-    "./filter": matrixPath + "filter.js",
-    "./filter-component": matrixPath + "filter-component.js",
-    "./http-api": matrixPath + "http-api.js",
-    "./interactive-auth": matrixPath + "interactive-auth.js",
-    "./megolm": matrixPath + "crypto/algorithms/megolm.js",
-    "./models/event": matrixPath + "models/event.js",
-    "./models/event-timeline": matrixPath + "models/event-timeline.js",
-    "./models/event-timeline-set": matrixPath + "models/event-timeline-set.js",
-    "./models/room": matrixPath + "models/room.js",
-    "./models/room-member": matrixPath + "models/room-member.js",
-    "./models/room-state": matrixPath + "models/room-state.js",
-    "./models/search-result": matrixPath + "models/search-result.js",
-    "./models/user": matrixPath + "models/user.js",
-    "./olm": matrixPath + "crypto/algorithms/olm.js",
-    "./olmlib": matrixPath + "crypto/olmlib.js",
-    "./pushprocessor": matrixPath + "pushprocessor.js",
+    // Matrix SDK files.
+    "": matrixPath + "matrix_sdk/",
+    "./base-apis": matrixPath + "matrix_sdk/base-apis.js",
+    "./client": matrixPath + "matrix_sdk/client.js",
+    "./content-repo": matrixPath + "matrix_sdk/content-repo.js",
+    "../content-repo": matrixPath + "matrix_sdk/content-repo.js",
+    "./filter": matrixPath + "matrix_sdk/filter.js",
+    "./filter-component": matrixPath + "matrix_sdk/filter-component.js",
+    "./http-api": matrixPath + "matrix_sdk/http-api.js",
+    "./interactive-auth": matrixPath + "matrix_sdk/interactive-auth.js",
+    "./pushprocessor": matrixPath + "matrix_sdk/pushprocessor.js",
+    "./realtime-callbacks": matrixPath + "matrix_sdk/realtime-callbacks.js",
+    "./scheduler": matrixPath + "matrix_sdk/scheduler.js",
+    "./sync": matrixPath + "matrix_sdk/sync.js",
+    "./timeline-window": matrixPath + "matrix_sdk/timeline-window.js",
+    "./utils": matrixPath + "matrix_sdk/utils.js",
+    "../utils": matrixPath + "matrix_sdk/utils.js",
+    "../../utils": matrixPath + "matrix_sdk/utils.js",
+    "./../../utils": matrixPath + "matrix_sdk/utils.js",
+
+    // crypto
+    base: matrixPath + "matrix_sdk/crypto/algorithms/base.js",
+    "./base": matrixPath + "matrix_sdk/crypto/algorithms/base.js",
+    algorithms: matrixPath + "matrix_sdk/crypto/algorithms/index.js",
+    "./algorithms": matrixPath + "matrix_sdk/crypto/algorithms/index.js",
+    megolm: matrixPath + "matrix_sdk/crypto/algorithms/megolm.js",
+    "./megolm": matrixPath + "matrix_sdk/crypto/algorithms/megolm.js",
+    olm: matrixPath + "matrix_sdk/crypto/algorithms/olm.js",
+    "./olm": matrixPath + "matrix_sdk/crypto/algorithms/olm.js",
+    deviceinfo: matrixPath + "matrix_sdk/crypto/deviceinfo.js",
+    "./deviceinfo": matrixPath + "matrix_sdk/crypto/deviceinfo.js",
+    "../deviceinfo": matrixPath + "matrix_sdk/crypto/deviceinfo.js",
+    crypto: matrixPath + "matrix_sdk/crypto/index.js",
+    "./crypto": matrixPath + "matrix_sdk/crypto/index.js",
+    olmlib: matrixPath + "matrix_sdk/crypto/olmlib.js",
+    "./olmlib": matrixPath + "matrix_sdk/crypto/olmlib.js",
+    "../olmlib": matrixPath + "matrix_sdk/crypto/olmlib.js",
+    OlmDevice: matrixPath + "matrix_sdk/crypto/OlmDevice.js",
+    "./OlmDevice": matrixPath + "matrix_sdk/crypto/OlmDevice.js",
+
+    // models
+    "./event": matrixPath + "matrix_sdk/models/event.js",
+    "./models/event": matrixPath + "matrix_sdk/models/event.js",
+    "../models/event": matrixPath + "matrix_sdk/models/event.js",
+    "./event-context": matrixPath + "matrix_sdk/models/event-content.js",
+    "./event-timeline": matrixPath + "matrix_sdk/models/event-timeline.js",
+    "./models/event-timeline": matrixPath + "matrix_sdk/models/event-timeline.js",
+    "./event-timeline-set": matrixPath + "matrix_sdk/models/event-timeline-set.js",
+    "./models/event-timeline-set": matrixPath + "matrix_sdk/models/event-timeline-set.js",
+    "./models/room": matrixPath + "matrix_sdk/models/room.js",
+    "../models/room": matrixPath + "matrix_sdk/models/room.js",
+    "./room-member": matrixPath + "matrix_sdk/models/room-member.js",
+    "./models/room-member": matrixPath + "matrix_sdk/models/room-member.js",
+    "./room-state": matrixPath + "matrix_sdk/models/room-state.js",
+    "./models/room-state": matrixPath + "matrix_sdk/models/room-state.js",
+    "./room-summary": matrixPath + "matrix_sdk/models/room-summary.js",
+    "./models/search-result": matrixPath + "matrix_sdk/models/search-result.js",
+    "./models/user": matrixPath + "matrix_sdk/models/user.js",
+    "../models/user": matrixPath + "matrix_sdk/models/user.js",
+
+    // store
+    "./store/memory": matrixPath + "matrix_sdk/store/memory.js",
+    "./store/session/webstorage": matrixPath + "matrix_sdk/store/session/webstorage.js",
+    "./store/stub": matrixPath + "matrix_sdk/store/stub.js",
+    "./store/webstorage": matrixPath + "matrix_sdk/store/webstorage.js",
+
+    // webrtc
+    "./webrtc/call": matrixPath + "matrix_sdk/webrtc/call.js",
+
+    // Simple (one-file) dependencies.
+    "another-json": matrixPath + "another-json.js",
+    events: matrixPath + "events.js",
+    punycode: matrixPath + "punycode.js",
+    url: matrixPath + "url.js",
+
+    // Browser Request.
+    "browser-request": matrixPath + "browser_request/index.js",
+
+    // q
+    q: matrixPath + "q/q.js",
     "./q": matrixPath + "q/q.js",
-    "./realtime-callbacks": matrixPath + "realtime-callbacks.js",
-    "./room-member": matrixPath + "models/room-member.js",
-    "./room-state": matrixPath + "models/room-state.js",
-    "./room-summary": matrixPath + "models/room-summary.js",
-    "./scheduler": matrixPath + "scheduler.js",
-    "./store/memory": matrixPath + "store/memory.js",
-    "./store/session/webstorage": matrixPath + "store/session/webstorage.js",
-    "./store/stub": matrixPath + "store/stub.js",
-    "./store/webstorage": matrixPath + "store/webstorage.js",
-    "./sync": matrixPath + "sync.js",
-    "./timeline-window": matrixPath + "timeline-window.js",
-    "./utils": matrixPath + "utils.js",
-    "./webrtc/call": matrixPath + "webrtc/call.js",
-    OlmDevice: matrixPath + "crypto/OlmDevice.js",
-    algorithms: matrixPath + "crypto/algorithms/index.js",
-    "another-json": matrixPath + "another_json/another-json.js",
-    base: matrixPath + "crypto/algorithms/base.js",
-    "browser-request": matrixPath + "browser_request/index.js",
-    crypto: matrixPath + "crypto/index.js",
-    decode: matrixPath + "browserify/querystring/decode.js",
-    deviceinfo: matrixPath + "crypto/deviceinfo.js",
-    encode: matrixPath + "browserify/querystring/encode.js",
-    events: matrixPath + "browserify/events.js",
-    megolm: matrixPath + "crypto/algorithms/megolm.js",
-    olm: matrixPath + "crypto/algorithms/olm.js",
-    olmlib: matrixPath + "crypto/olmlib.js",
-    punycode: matrixPath + "browserify/punycode.js",
-    q: matrixPath + "q/q.js",
-    querystring: matrixPath + "browserify/querystring/index.js",
-    url: matrixPath + "browserify/url.js",
+
+    // querystring
+    decode: matrixPath + "querystring/decode.js",
+    "./decode": matrixPath + "querystring/decode.js",
+    encode: matrixPath + "querystring/encode.js",
+    "./encode": matrixPath + "querystring/encode.js",
+    querystring: matrixPath + "querystring/index.js",
   },
   globals: {
     global: {
       setInterval,
       clearInterval,
       setTimeout,
       clearTimeout,
     },
--- a/chat/protocols/matrix/moz.build
+++ b/chat/protocols/matrix/moz.build
@@ -1,17 +1,17 @@
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 # XPCSHELL_TESTS_MANIFESTS += []
 
 DIRS += [
-    'matrix-sdk',
+    'lib',
 ]
 
 EXTRA_COMPONENTS += [
     'matrix.js',
     'matrix.manifest',
 ]
 
 EXTRA_JS_MODULES += [