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

Fix sourcemaps by refactoring the build system #3839

Merged
merged 100 commits into from
Jan 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
25f5cca
Remove unused jenkins.sh
turt2live Dec 12, 2019
c02beb9
Copy typescript configs from js-sdk
turt2live Dec 12, 2019
97af040
Upgrade to babel@7 and support typescript
turt2live Dec 12, 2019
a5dadda
Convert SdkConfig to TypeScript as a proof of concept
turt2live Dec 12, 2019
ff584d1
yarn.lock changes for upgrade
turt2live Dec 12, 2019
59ddefd
Disable tests for new TypeScript build
turt2live Dec 12, 2019
f5264db
Disable end-to-end tests too
turt2live Dec 12, 2019
225695a
Fix exports for rate limited functions and MatrixClientPeg
turt2live Dec 13, 2019
20a6153
Implementation of new potential skinning mechanism
turt2live Dec 13, 2019
18f81d8
Initial jest stuff. Blocked on Babel 7
t3chguy Dec 13, 2019
ffa2ac1
delint
t3chguy Dec 15, 2019
6ad31fe
30 test failures to go :D
t3chguy Dec 16, 2019
0041dae
26 test failures to go :D
t3chguy Dec 16, 2019
b8faaa2
Remove irrelevant targets
turt2live Dec 16, 2019
434570e
Explain why MatrixClientPeg is the way it is
turt2live Dec 16, 2019
0a9985f
Rename decorator for clarity
turt2live Dec 16, 2019
9865ce8
Add a bunch of docs
turt2live Dec 16, 2019
ab3fb65
Down to 7 test failures
t3chguy Dec 17, 2019
e6d8487
Fix more tests
t3chguy Dec 17, 2019
802092b
All tests passing locally. We no longer need Chrome in buildkite
t3chguy Dec 17, 2019
c3415d2
delint
t3chguy Dec 17, 2019
386d6ec
we don't need to install riot-web for react-sdk unit tests
t3chguy Dec 17, 2019
f06a943
fix yarn test for bashy things
t3chguy Dec 17, 2019
bcba9a3
fix yarn test for bashy things v2
t3chguy Dec 17, 2019
409a111
wait additional tick
t3chguy Dec 17, 2019
a224637
correct testMatch so it doesn't try run js-sdk tests
t3chguy Dec 17, 2019
b9e22f8
add delay
t3chguy Dec 17, 2019
d06f476
Merge pull request #3723 from matrix-org/travis/babel7-reskindex
turt2live Dec 17, 2019
38e75aa
Merge pull request #3722 from matrix-org/travis/babel7
turt2live Dec 17, 2019
affc8b8
Merge branches 'develop' and 't3chguy/jest' of https://github.com/mat…
t3chguy Dec 19, 2019
4fe0150
Regen yarn.lock
t3chguy Dec 19, 2019
e7928e8
Use `flex-start` instead of `start` for postcss
turt2live Dec 23, 2019
0b0fe92
Convert resizer to ES6
turt2live Dec 17, 2019
344dac4
Convert CommonJS exports to ES6-compatible exports
turt2live Dec 20, 2019
4aec432
Convert the more complicated CommonJS exports to ES6-style
turt2live Dec 20, 2019
d56f0f2
Convert many imports to handle ES6 exports
turt2live Dec 20, 2019
7993515
Merge branch 'travis/babel7-wp-es6-imports' into travis/babel7-wp-es6…
turt2live Dec 23, 2019
be4eeb5
Fix js-sdk imports for new module
turt2live Dec 20, 2019
806d728
Import from the js-sdk's src/ directory
turt2live Dec 20, 2019
5a17406
Merge branch 'travis/babel7-wp-es6-js-sdk' into travis/babel7-wp-es6-mcp
turt2live Dec 23, 2019
042bd35
Fix MatrixClientPeg imports
turt2live Dec 20, 2019
f1ac3d2
Convert imports to ES6 from CommonJS
turt2live Dec 20, 2019
0c11e03
Merge branch 'travis/babel7-wp-es6-imports-2' into travis/sourcemaps-es6
turt2live Dec 23, 2019
d002c2c
Merge branch 'travis/babel7-wp-es6-export' into travis/sourcemaps-es6
turt2live Dec 23, 2019
2461993
Merge branch 'travis/sourcemaps-es6' into travis/babel7-wp-es6-fixes
turt2live Dec 23, 2019
0d2cb6e
Import haveTileForEvent() from the right place
turt2live Dec 20, 2019
615648a
Fix tabbed view export for component index
turt2live Dec 23, 2019
18ac2db
Fix Notifier imports in NotificationControllers
turt2live Dec 20, 2019
539a33c
Fix naming conflict in VectorConferenceHandler
turt2live Dec 20, 2019
d8da634
Cosmetic updates to package.json
turt2live Dec 20, 2019
69424f4
Add package.json fields for riot-web's webpack
turt2live Dec 20, 2019
23e5333
Introduce babel's export-default-from plugin to fix build errors
turt2live Dec 20, 2019
cfa21cb
Define getLanguageFromBrowser() for LanguageDropdown
turt2live Dec 20, 2019
56adb82
Add a bit of debugging to incorrect components in the Skinner
turt2live Dec 20, 2019
3eb3be4
Fix import of language index
turt2live Dec 20, 2019
8a8b23e
Merge pull request #3770 from matrix-org/travis/babel7-wp-skin-dbg
turt2live Dec 25, 2019
9cb810e
Merge pull request #3768 from matrix-org/travis/babel7-wp-bbl-pl
turt2live Dec 25, 2019
58f169b
Merge pull request #3769 from matrix-org/travis/babel7-wp-lang-dropdown
turt2live Dec 25, 2019
3a7c5dc
Merge pull request #3760 from matrix-org/travis/babel7-wp-flex
turt2live Dec 27, 2019
9edc361
Use new imports for js-sdk's ContentRepo
turt2live Jan 3, 2020
206d4c7
Fix references to 'this' in Avatar and Unread
turt2live Jan 3, 2020
f11f8db
Merge pull request #3762 from matrix-org/travis/babel7-wp-es6-imports
turt2live Jan 7, 2020
284a69f
Merge pull request #3763 from matrix-org/travis/babel7-wp-es6-js-sdk
turt2live Jan 7, 2020
9213f88
Re-add docs
turt2live Jan 7, 2020
9aab150
Merge pull request #3764 from matrix-org/travis/babel7-wp-es6-imports-2
turt2live Jan 8, 2020
59f608f
Merge pull request #3761 from matrix-org/travis/babel7-wp-es6-export
turt2live Jan 8, 2020
85c4c72
Merge pull request #3767 from matrix-org/travis/babel7-wp-package
turt2live Jan 8, 2020
36b7be9
Merge branch 'travis/sourcemaps' into travis/babel7-wp-es6-fixes
turt2live Jan 8, 2020
4e4871c
Move lang import to the top of the file
turt2live Jan 9, 2020
6ca9a7c
Merge pull request #3766 from matrix-org/travis/babel7-wp-es6-fixes
turt2live Jan 9, 2020
fde32f1
[CONFLICT CHUNKS] Merge branch 'develop' into travis/sourcemaps-develop
turt2live Jan 9, 2020
a0da132
Fix conflicts in package.json
turt2live Jan 7, 2020
3e5cc95
Fix import merge conflicts, removing any that aren't needed anymore
turt2live Jan 9, 2020
727ce89
Fix remaining RoomView conflict
turt2live Jan 7, 2020
19f78d4
Fix class construction in MemberList
turt2live Jan 7, 2020
a637646
Use yarn's updated lockfile
turt2live Jan 7, 2020
dc91477
Delete files that were conflicting in the merge and deleted on develop
turt2live Jan 7, 2020
135c842
Fix more imports post-merge
turt2live Jan 9, 2020
a27f2d8
Merge pull request #3817 from matrix-org/travis/sourcemaps-develop
turt2live Jan 9, 2020
a8c8406
Merge remote-tracking branch 'origin/t3chguy/jest' into travis/source…
turt2live Jan 9, 2020
23eb6cb
Upgrade Jest and babel-jest to match js-sdk
turt2live Jan 9, 2020
5f51432
Convert babel config to a different babel config
turt2live Jan 10, 2020
0e8af15
Add webcrypto dep back
turt2live Jan 10, 2020
ffd037d
Fix resolution of files for Jest
turt2live Jan 10, 2020
4dfbce3
Fix languageHandler's use of $webapp languages.json for Jest
turt2live Jan 10, 2020
54f3288
Fix imports for tests
turt2live Jan 10, 2020
4bc5ada
Fix test bootstrap for new skinning approach
turt2live Jan 10, 2020
aa38946
Actually define some tests in TextualBody's test
turt2live Jan 10, 2020
d7dd67f
Remove subtly irrelevant package
turt2live Jan 10, 2020
4c3703a
Merge pull request #3823 from matrix-org/travis/sm-fix-tests
turt2live Jan 10, 2020
4b65cdf
Regenerate i18n
turt2live Jan 10, 2020
3591f80
Merge pull request #3824 from matrix-org/travis/sm-misc
turt2live Jan 10, 2020
9f04f94
Enable e2e and Riot tests, removing Karma
turt2live Jan 10, 2020
e66f2a6
Revert ES6ification of end-to-end tests and add instructions for Windows
turt2live Jan 10, 2020
5287770
Merge pull request #3827 from matrix-org/travis/sm-e2e-tests
turt2live Jan 13, 2020
5fd27a1
Merge branch 'develop' into travis/sourcemaps
turt2live Jan 13, 2020
bf6798e
Appease the linter
turt2live Jan 13, 2020
813b140
Fix CI build steps for new environment.
turt2live Jan 13, 2020
1e70af0
Fix GroupView test
turt2live Jan 14, 2020
90c7535
Export VIEWS from MatrixChat for riot-web tests
turt2live Jan 14, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
20 changes: 0 additions & 20 deletions .babelrc

This file was deleted.

82 changes: 53 additions & 29 deletions .buildkite/pipeline.yaml
Original file line number Diff line number Diff line change
@@ -1,57 +1,80 @@
steps:
- label: ":eslint: Lint"
- label: ":eslint: JS Lint"
command:
- "echo '--- Install js-sdk'"
- "./scripts/ci/install-deps.sh"
- "yarn lintwithexclusions"
- "yarn stylelint"
- "yarn lint:js"
plugins:
- docker#v3.0.1:
image: "node:10"
image: "node:12"

- label: ":chains: End-to-End Tests"
agents:
# We use a xlarge sized instance instead of the normal small ones because
# e2e tests otherwise take +-8min
queue: "xlarge"
- label: ":eslint: TS Lint"
command:
# TODO: Remove hacky chmod for BuildKite
- "echo '--- Setup'"
- "chmod +x ./scripts/ci/*.sh"
- "chmod +x ./scripts/*"
- "echo '--- Install js-sdk'"
- "./scripts/ci/install-deps.sh"
- "./scripts/ci/end-to-end-tests.sh"
- "yarn lint:ts"
plugins:
- docker#v3.0.1:
image: "matrixdotorg/riotweb-ci-e2etests-env:latest"
propagate-environment: true
image: "node:12"

- label: ":karma: Tests"
- label: ":eslint: Types Lint"
command:
- "echo '--- Install js-sdk'"
- "./scripts/ci/install-deps.sh"
- "yarn lint:types"
plugins:
- docker#v3.0.1:
image: "node:12"

- label: ":jest: Tests"
agents:
# We use a medium sized instance instead of the normal small ones because
# webpack loves to gorge itself on resources.
queue: "medium"
command:
# Install chrome
- "echo '--- Installing Chrome'"
- "wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -"
- "sh -c 'echo \"deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main\" >> /etc/apt/sources.list.d/google.list'"
- "apt-get update"
- "apt-get install -y google-chrome-stable"
# Run tests
- "echo '--- Install js-sdk'"
# TODO: Remove hacky chmod for BuildKite
- "chmod +x ./scripts/ci/*.sh"
- "chmod +x ./scripts/*"
- "echo '--- Installing Dependencies'"
- "./scripts/ci/install-deps.sh"
- "echo '--- Running initial build steps'"
- "yarn build"
- "echo '+++ Running Tests'"
- "./scripts/ci/unit-tests.sh"
env:
CHROME_BIN: "/usr/bin/google-chrome-stable"
- "yarn test"
plugins:
- docker#v3.0.1:
image: "node:10"
image: "node:12"

- label: "🛠 Build"
command:
- "echo '--- Install js-sdk'"
- "./scripts/ci/install-deps.sh"
- "echo '+++ Building Project'"
- "yarn build"
plugins:
- docker#v3.0.1:
image: "node:12"

- label: ":chains: End-to-End Tests"
agents:
# We use a xlarge sized instance instead of the normal small ones because
# e2e tests otherwise take +-8min
queue: "xlarge"
command:
# TODO: Remove hacky chmod for BuildKite
- "echo '--- Setup'"
- "chmod +x ./scripts/ci/*.sh"
- "chmod +x ./scripts/*"
- "echo '--- Install js-sdk'"
- "./scripts/ci/install-deps.sh"
- "echo '--- Running initial build steps'"
- "yarn build"
- "echo '+++ Running Tests'"
- "./scripts/ci/end-to-end-tests.sh"
plugins:
- docker#v3.0.1:
image: "matrixdotorg/riotweb-ci-e2etests-env:latest"
propagate-environment: true

- label: "🔧 Riot Tests"
Expand All @@ -66,12 +89,13 @@ steps:
- "sh -c 'echo \"deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main\" >> /etc/apt/sources.list.d/google.list'"
- "apt-get update"
- "apt-get install -y google-chrome-stable"
# Run tests
# TODO: Remove hacky chmod for BuildKite
- "chmod +x ./scripts/ci/*.sh"
- "chmod +x ./scripts/*"
- "echo '--- Installing Dependencies'"
- "./scripts/ci/install-deps.sh"
- "echo '--- Running initial build steps'"
- "yarn build"
- "echo '+++ Running Tests'"
- "./scripts/ci/riot-unit-tests.sh"
env:
Expand Down
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ module.exports = {
parserOptions: {
ecmaFeatures: {
jsx: true,
legacyDecorators: true,
}
},
rules: {
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ practices that anyone working with the SDK needs to be be aware of and uphold:

* After creating a new component you must run `yarn reskindex` to regenerate
the `component-index.js` for the SDK (used in future for skinning)
<!-- TODO: Remove this once this approach to skinning is replaced -->

* The view's CSS file MUST have the same name (e.g. view/rooms/MessageTile.css).
CSS for matrix-react-sdk currently resides in
Expand Down
16 changes: 16 additions & 0 deletions __mocks__/browser-request.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const en = require("../src/i18n/strings/en_EN");

module.exports = jest.fn((opts, cb) => {
if (opts.url.endsWith("languages.json")) {
cb(undefined, {status: 200}, JSON.stringify({
"en": {
"fileName": "en_EN.json",
"label": "English",
},
}));
} else if (opts.url.endsWith("en_EN.json")) {
cb(undefined, {status: 200}, JSON.stringify(en));
} else {
cb(undefined, {status: 404}, "");
}
});
1 change: 1 addition & 0 deletions __mocks__/imageMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = "image-file-stub";
10 changes: 10 additions & 0 deletions __mocks__/languages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"en": {
"fileName": "en_EN.json",
"label": "English"
},
"en-us": {
"fileName": "en_US.json",
"label": "English (US)"
}
}
26 changes: 26 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module.exports = {
"sourceMaps": "inline",
"presets": [
["@babel/preset-env", {
"targets": {
"browsers": [
"last 2 versions"
]
},
"modules": "commonjs"
}],
"@babel/preset-typescript",
"@babel/preset-flow",
"@babel/preset-react"
],
"plugins": [
["@babel/plugin-proposal-decorators", { "legacy": true }],
"@babel/plugin-proposal-export-default-from",
"@babel/plugin-proposal-numeric-separator",
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-object-rest-spread",
"@babel/plugin-transform-flow-comments",
"@babel/plugin-syntax-dynamic-import",
"@babel/plugin-transform-runtime"
]
};
71 changes: 71 additions & 0 deletions docs/skinning.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Skinning

The react-sdk can be skinned to replace presentation components, CSS, or
other relevant parts of the SDK. Typically consumers will replace entire
components and get the ability for custom CSS as a result.

This doc isn't exhaustive on how skinning works, though it should cover
some of the more complicated parts such as component replacement.

## Loading a skin

1. Generate a `component-index.js` (preferably using the tools that the react-sdk
exposes). This can typically be done with a npm script like `"reskindex -h src/header"`.
2. In your app's entry point, add something like this code:
```javascript
import {loadSkin} from "matrix-react-sdk";
loadSkin(import("component-index").components);
// The rest of your imports go under this.
```
3. Import the remainder of the SDK and bootstrap your app.

It is extremely important that you **do not** import anything else from the
SDK prior to loading your skin as otherwise the skin might not work. Loading
the skin should be one of the first things your app does, if not the very
first thing.

Additionally, **do not** provide `loadSkin` with the react-sdk components
themselves otherwise the app might explode. The SDK is already aware of its
components and doesn't need to be told.

## Replacing components

Components that replace the react-sdk ones MUST have a `replaces` static
key on the component's class to describe which component it overrides. For
example, if your `VectorAuthPage` component is meant to replace the react-sdk
`AuthPage` component then you'd add `static replaces = 'views.auth.AuthPage';`
to the `VectorAuthPage` class.

Other than that, the skin just needs to be loaded normally as mentioned above.
Consumers of the SDK likely will not be interested in the rest of this section.

### SDK developer notes

Components in the react-sdk MUST be decorated with the `@replaceableComponent`
function. For components that can't use the decorator, they must use a
variation that provides similar functionality. The decorator gives consumers
an opportunity to load skinned components by abusing import ordering and
behaviour.

Decorators are executed at import time which is why we can abuse the import
ordering behaviour: importing `loadSkin` doesn't trigger any components to
be imported, allowing the consumer to specify a skin. When the consumer does
import a component (for example, `MatrixChat`), it starts to pull in all the
components via `import` statements. When the components get pulled in the
decorator checks with the skinned components to see if it should be replacing
the component being imported. The decorator then effectively replaces the
components when needed by specifying the skinned component as an override for
the SDK's component, which should in theory override critical functions like
`render()` and lifecycle event handlers.

The decorator also means that older usage of `getComponent()` is no longer
required because components should be replaced by the decorator. Eventually
the react-sdk should only have one usage of `getComponent()`: the decorator.

The decorator assumes that if `getComponent()` returns null that there is
no skinned version of the component and continues on using the SDK's component.
In previous versions of the SDK, the function would throw an error instead
because it also expected the skin to list the SDK's components as well, however
that is no longer possible due to the above.

In short, components should always be `import`ed.
39 changes: 0 additions & 39 deletions jenkins.sh

This file was deleted.

Loading