Skip to content

Commit 599b263

Browse files
authored
Merge pull request element-hq#11843 from vector-im/travis/sourcemaps
Fix sourcemaps by refactoring the build system
2 parents ab758d2 + f2da98b commit 599b263

26 files changed

Lines changed: 3997 additions & 1689 deletions

‎.babelrc‎

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
11
{
2-
"presets": [
3-
"react",
4-
"es2015",
5-
"es2016"
6-
],
7-
"plugins": [
8-
[
9-
"transform-builtin-extend",
10-
{
11-
"globals": ["Error"]
12-
}
13-
],
14-
"transform-class-properties",
15-
"transform-object-rest-spread",
16-
"transform-runtime",
17-
"add-module-exports",
18-
"syntax-dynamic-import"
19-
]
2+
"sourceMaps": true,
3+
"presets": [
4+
["@babel/preset-env", {
5+
"targets": {
6+
"browsers": [
7+
"last 2 versions"
8+
]
9+
}
10+
}],
11+
"@babel/preset-typescript",
12+
"@babel/preset-flow",
13+
"@babel/preset-react"
14+
],
15+
"plugins": [
16+
["@babel/plugin-proposal-decorators", {"legacy": true}],
17+
"@babel/plugin-proposal-export-default-from",
18+
"@babel/plugin-proposal-numeric-separator",
19+
"@babel/plugin-proposal-class-properties",
20+
"@babel/plugin-proposal-object-rest-spread",
21+
"@babel/plugin-transform-flow-comments",
22+
"@babel/plugin-syntax-dynamic-import",
23+
"@babel/plugin-transform-runtime"
24+
]
2025
}

‎.buildkite/pipeline.yaml‎

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,40 @@
11
steps:
2-
- label: ":eslint: Lint"
2+
- label: ":eslint: JS Lint"
33
command:
44
- "yarn install"
5-
- "yarn lint"
5+
- "yarn lint:js"
66
plugins:
77
- docker#v3.0.1:
8-
image: "node:10"
8+
image: "node:12"
9+
10+
# This layer doesn't have a TypeScript linter. This comment is to remind TravisR to fix that.
11+
# - label: ":eslint: TS Lint"
12+
# command:
13+
# - "echo '--- Install js-sdk'"
14+
# - "./scripts/ci/install-deps.sh"
15+
# - "yarn lint:ts"
16+
# plugins:
17+
# - docker#v3.0.1:
18+
# image: "node:12"
19+
20+
- label: ":eslint: Types Lint"
21+
command:
22+
- "yarn install"
23+
- "yarn lint:types"
24+
plugins:
25+
- docker#v3.0.1:
26+
image: "node:12"
27+
28+
- label: "🛠 Build"
29+
command:
30+
- "echo '--- Fetching Dependencies'"
31+
- "./scripts/fetch-develop.deps.sh --depth 1"
32+
- "yarn install"
33+
- "echo '+++ Building Project'"
34+
- "yarn build"
35+
plugins:
36+
- docker#v3.0.1:
37+
image: "node:12"
938

1039
- label: ":karma: Tests"
1140
agents:
@@ -54,4 +83,4 @@ steps:
5483
- "yarn diff-i18n"
5584
plugins:
5685
- docker#v3.0.1:
57-
image: "node:10"
86+
image: "node:10"

‎.stylelintrc.js‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copied from react-sdk
2+
// TODO: Only keep one copy of this for synchronization purposes
3+
module.exports = {
4+
"extends": "stylelint-config-standard",
5+
"plugins": [
6+
"stylelint-scss",
7+
],
8+
"rules": {
9+
"indentation": 4,
10+
"comment-empty-line-before": null,
11+
"declaration-empty-line-before": null,
12+
"length-zero-no-unit": null,
13+
"rule-empty-line-before": null,
14+
"color-hex-length": null,
15+
"max-empty-lines": null,
16+
"number-no-trailing-zeros": null,
17+
"number-leading-zero": null,
18+
"selector-list-comma-newline-after": null,
19+
"at-rule-no-unknown": null,
20+
"no-descending-specificity": null,
21+
"scss/at-rule-no-unknown": [true, {
22+
// https://github.com/vector-im/riot-web/issues/10544
23+
"ignoreAtRules": ["define-mixin"],
24+
}],
25+
}
26+
};

‎karma.conf.js‎

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
var path = require('path');
44
var webpack = require('webpack');
5-
var webpack_config = require('./webpack.config');
5+
var wp_config = require('./webpack.config');
66

77
/*
88
* We use webpack to build our tests. It's a pain to have to wait for webpack
@@ -20,6 +20,8 @@ var testFile = process.env.KARMA_TEST_FILE || 'test/all-tests.js';
2020
process.env.PHANTOMJS_BIN = 'node_modules/.bin/phantomjs';
2121
process.env.Q_DEBUG = 1;
2222

23+
const webpack_config = wp_config({}, {mode: "development"});
24+
2325
/* the webpack config is based on the real one, to (a) try to simulate the
2426
* deployed environment as closely as possible, and (b) to avoid a shedload of
2527
* cut-and-paste.
@@ -35,12 +37,6 @@ delete webpack_config['entry'];
3537
// make sure we're flagged as development to avoid wasting time optimising
3638
webpack_config.mode = 'development';
3739

38-
// add ./test as a search path for js
39-
webpack_config.module.rules.unshift({
40-
test: /\.js$/, use: "babel-loader",
41-
include: [path.resolve('./src'), path.resolve('./test')],
42-
});
43-
4440
// disable parsing for sinon, because it
4541
// tries to do voodoo with 'require' which upsets
4642
// webpack (https://github.com/webpack/webpack/issues/304)
@@ -54,8 +50,6 @@ webpack_config.resolve.modules = [
5450
"node_modules"
5551
];
5652

57-
webpack_config.devtool = 'inline-source-map';
58-
5953
module.exports = function (config) {
6054
const myconfig = {
6155
// frameworks to use
@@ -64,7 +58,6 @@ module.exports = function (config) {
6458

6559
// list of files / patterns to load in the browser
6660
files: [
67-
'node_modules/babel-polyfill/browser.js',
6861
testFile,
6962

7063
// make the images available via our httpd. They will be avaliable

‎package.json‎

Lines changed: 70 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -11,62 +11,56 @@
1111
},
1212
"license": "Apache-2.0",
1313
"files": [
14-
"AUTHORS.rst",
15-
"CONTRIBUTING.rst",
16-
"deploy",
17-
"docs",
18-
"karma.conf.js",
1914
"lib",
20-
"release.sh",
21-
"scripts",
15+
"res",
2216
"src",
23-
"test",
24-
"webpack.config.js"
17+
"webpack.config.js",
18+
"scripts",
19+
"docs",
20+
"release.sh",
21+
"karma.conf.js",
22+
"deploy",
23+
"CHANGELOG.md",
24+
"CONTRIBUTING.rst",
25+
"LICENSE",
26+
"README.md",
27+
"AUTHORS.rst",
28+
"package.json"
2529
],
2630
"style": "bundle.css",
27-
"matrix-react-parent": "matrix-react-sdk",
2831
"scripts": {
29-
"reskindex": "reskindex -h src/header",
30-
"reskindex:watch": "reskindex -h src/header -w",
3132
"i18n": "matrix-gen-i18n",
3233
"prunei18n": "matrix-prune-i18n",
3334
"diff-i18n": "cp src/i18n/strings/en_EN.json src/i18n/strings/en_EN_orig.json && yarn i18n && node scripts/compare-file.js src/i18n/strings/en_EN_orig.json src/i18n/strings/en_EN.json",
34-
"postinstall": "node scripts/yarn-sub.js matrix-js-sdk install && node scripts/yarn-sub.js matrix-react-sdk install",
35+
"reskindex": "reskindex -h src/header",
36+
"reskindex:watch": "reskindex -h src/header -w",
37+
"clean": "rimraf lib webapp electron_app/dist",
38+
"build": "yarn clean && yarn build:genfiles && yarn build:compile && yarn build:types && yarn build:bundle",
3539
"build:res": "node scripts/copy-res.js",
40+
"build:genfiles": "yarn reskindex && yarn build:res",
3641
"build:modernizr": "modernizr -c .modernizr.json -d src/vector/modernizr.js",
37-
"build:compile": "yarn reskindex && babel --source-maps -d lib src",
42+
"build:compile": "babel -d lib --verbose --extensions \".ts,.js\" src",
3843
"build:bundle": "cross-env NODE_ENV=production webpack -p --progress --bail --mode production",
39-
"build:bundle:dev": "webpack --progress --bail --mode development",
40-
"build:electron": "yarn clean && yarn build && yarn install:electron && electron-builder -wml --ia32 --x64",
44+
"build:electron": "yarn build && yarn install:electron && electron-builder -wml --ia32 --x64",
4145
"build:electron:linux": "yarn build && electron-builder -l --x64",
4246
"build:electron:macos": "yarn build && electron-builder -m --x64",
4347
"build:electron:windows": "yarn build && electron-builder -w --ia32 --x64",
44-
"build:react-sdk": "node scripts/yarn-sub.js matrix-react-sdk build",
45-
"build:js-sdk": "node scripts/yarn-sub.js matrix-js-sdk start:init",
46-
"build": "yarn build:js-sdk && yarn build:react-sdk && yarn reskindex && yarn build:res && yarn build:bundle",
47-
"build:dev": "yarn build:js-sdk && yarn build:react-sdk && yarn reskindex && yarn build:res && yarn build:bundle:dev",
48-
"dist": "scripts/package.sh",
48+
"build:types": "tsc --emitDeclarationOnly",
4949
"install:electron": "electron-builder install-app-deps",
50-
"electron": "yarn install:electron && electron .",
50+
"dist": "scripts/package.sh",
51+
"start": "concurrently --kill-others-on-fail --prefix \"{time} [{name}]\" -n reskindex,res,riot-js \"yarn reskindex:watch\" \"yarn start:res\" \"yarn start:js\"",
5152
"start:res": "node scripts/copy-res.js -w",
5253
"start:js": "webpack-dev-server --host=0.0.0.0 --output-filename=bundles/_dev_/[name].js --output-chunk-filename=bundles/_dev_/[name].js -w --progress --mode development",
53-
"start:js:prod": "cross-env NODE_ENV=production webpack-dev-server -w --progress --mode production",
54-
"start:js-sdk": "node scripts/yarn-sub.js matrix-js-sdk start:watch",
55-
"start:js-sdk:prod": "cross-env NODE_ENV=production node scripts/yarn-sub.js matrix-js-sdk start:watch",
56-
"start:react-sdk": "node scripts/yarn-sub.js matrix-react-sdk start:all",
57-
"start:react-sdk:prod": "cross-env NODE_ENV=production node scripts/yarn-sub.js matrix-react-sdk start:all",
58-
"start": "yarn build:js-sdk && yarn build:react-sdk && concurrently --kill-others-on-fail --prefix \"{time} [{name}]\" -n js-sdk,react-sdk,reskindex,res,riot-js \"yarn start:js-sdk\" \"yarn start:react-sdk\" \"yarn reskindex:watch\" \"yarn start:res\" \"yarn start:js\"",
59-
"start:prod": "yarn build:js-sdk && yarn build:react-sdk && concurrently --kill-others-on-fail --prefix \"{time} [{name}]\" -n js-sdk,react-sdk,reskindex,res,riot-js \"yarn start:js-sdk:prod\" \"yarn start:react-sdk:prod\" \"yarn reskindex:watch\" \"yarn start:res\" \"yarn start:js:prod\"",
60-
"lint": "eslint src/",
61-
"lintall": "eslint src/ test/",
62-
"clean": "rimraf lib webapp electron_app/dist",
63-
"prepare": "yarn clean && yarn build:compile",
64-
"test": "karma start --single-run=true --autoWatch=false --browsers VectorChromeHeadless",
65-
"test-multi": "karma start"
54+
"electron": "yarn build && yarn install:electron && electron .",
55+
"lint": "yarn lint:types && yarn lint:ts && yarn lint:js && yarn lint:style",
56+
"lint:js": "eslint src",
57+
"lint:ts": "echo 'We don't actually have a typescript linter at this layer because tslint is being removed from our stack. Presumably your TS is fine.'",
58+
"lint:types": "tsc --noEmit",
59+
"lint:style": "stylelint 'res/css/**/*.scss'",
60+
"test": "yarn build:genfiles && karma start --single-run=true --autoWatch=false --browsers VectorChromeHeadless",
61+
"test:multi": "yarn build:genfiles && karma start"
6662
},
6763
"dependencies": {
68-
"babel-polyfill": "^6.26.0",
69-
"babel-runtime": "^6.26.0",
7064
"browser-request": "^0.3.3",
7165
"favico.js": "^0.3.10",
7266
"gemini-scrollbar": "github:matrix-org/gemini-scrollbar#91e1e566",
@@ -85,27 +79,32 @@
8579
"url": "^0.11.0"
8680
},
8781
"devDependencies": {
88-
"autoprefixer": "^6.6.0",
89-
"babel-cli": "^6.26.0",
90-
"babel-core": "^6.26.3",
91-
"babel-eslint": "^8.1.1",
92-
"babel-loader": "^7.1.5",
93-
"babel-plugin-add-module-exports": "^0.2.1",
94-
"babel-plugin-syntax-dynamic-import": "^6.18.0",
95-
"babel-plugin-transform-builtin-extend": "^1.1.2",
96-
"babel-plugin-transform-class-properties": "^6.24.1",
97-
"babel-plugin-transform-object-rest-spread": "^6.26.0",
98-
"babel-plugin-transform-runtime": "^6.23.0",
99-
"babel-preset-es2015": "^6.24.1",
100-
"babel-preset-es2016": "^6.24.1",
101-
"babel-preset-es2017": "^6.24.1",
102-
"babel-preset-react": "^6.24.1",
103-
"babel-preset-stage-2": "^6.24.1",
82+
"@babel/cli": "^7.7.5",
83+
"@babel/core": "^7.7.5",
84+
"@babel/plugin-proposal-class-properties": "^7.7.4",
85+
"@babel/plugin-proposal-decorators": "^7.7.4",
86+
"@babel/plugin-proposal-export-default-from": "^7.7.4",
87+
"@babel/plugin-proposal-numeric-separator": "^7.7.4",
88+
"@babel/plugin-proposal-object-rest-spread": "^7.7.4",
89+
"@babel/plugin-syntax-dynamic-import": "^7.7.4",
90+
"@babel/plugin-transform-flow-comments": "^7.7.4",
91+
"@babel/plugin-transform-runtime": "^7.7.6",
92+
"@babel/preset-env": "^7.7.6",
93+
"@babel/preset-flow": "^7.7.4",
94+
"@babel/preset-react": "^7.7.4",
95+
"@babel/preset-typescript": "^7.7.4",
96+
"@babel/register": "^7.7.4",
97+
"@babel/runtime": "^7.7.6",
98+
"@types/react": "^16.9.17",
99+
"@types/react-dom": "^16.9.4",
100+
"autoprefixer": "^9.7.3",
101+
"babel-eslint": "^10.0.3",
102+
"babel-loader": "^8.0.6",
104103
"chokidar": "^2.0.4",
105104
"concurrently": "^4.0.1",
106105
"cpx": "^1.3.2",
107-
"cross-env": "^4.0.0",
108-
"css-loader": "^2.1.0",
106+
"cross-env": "^6.0.3",
107+
"css-loader": "^3.3.2",
109108
"electron-builder": "^21.2.0",
110109
"electron-builder-squirrel-windows": "^21.2.0",
111110
"electron-devtools-installer": "^2.2.4",
@@ -119,7 +118,7 @@
119118
"eslint-plugin-react-hooks": "^2.2.0",
120119
"expect": "^1.16.0",
121120
"extract-text-webpack-plugin": "^4.0.0-beta.0",
122-
"file-loader": "^3.0.1",
121+
"file-loader": "^5.0.2",
123122
"fs-extra": "^0.30.0",
124123
"html-webpack-plugin": "^3.2.0",
125124
"json-loader": "^0.5.3",
@@ -135,23 +134,28 @@
135134
"loader-utils": "^1.2.3",
136135
"matrix-mock-request": "^1.2.3",
137136
"matrix-react-test-utils": "^0.2.2",
137+
"mini-css-extract-plugin": "^0.8.0",
138138
"minimist": "^1.2.0",
139139
"mkdirp": "^0.5.1",
140140
"mocha": "^5.2.0",
141+
"optimize-css-assets-webpack-plugin": "^5.0.3",
141142
"postcss-extend": "^1.0.5",
142-
"postcss-import": "^11.1.0",
143-
"postcss-loader": "^2.1.6",
144-
"postcss-mixins": "^6.2.0",
145-
"postcss-nested": "^3.0.0",
146-
"postcss-scss": "^1.0.6",
147-
"postcss-simple-vars": "^4.1.0",
143+
"postcss-import": "^12.0.1",
144+
"postcss-loader": "^3.0.0",
145+
"postcss-mixins": "^6.2.3",
146+
"postcss-nested": "^4.2.1",
147+
"postcss-preset-env": "^6.7.0",
148+
"postcss-scss": "^2.0.0",
149+
"postcss-simple-vars": "^5.0.2",
148150
"postcss-strip-inline-comments": "^0.1.5",
149151
"rimraf": "^2.4.3",
150152
"shell-escape": "^0.2.0",
151-
"source-map-loader": "^0.2.4",
152-
"webpack": "^4.23.1",
153-
"webpack-cli": "^3.1.2",
154-
"webpack-dev-server": "^3.1.11"
153+
"stylelint": "^12.0.1",
154+
"terser-webpack-plugin": "^2.3.0",
155+
"typescript": "^3.7.3",
156+
"webpack": "^4.41.2",
157+
"webpack-cli": "^3.3.10",
158+
"webpack-dev-server": "^3.9.0"
155159
},
156160
"build": {
157161
"appId": "im.riot.app",

‎postcss.config.js‎

Lines changed: 0 additions & 14 deletions
This file was deleted.

‎scripts/fetch-develop.deps.sh‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ dodep matrix-org matrix-js-sdk
7878
pushd matrix-js-sdk
7979
yarn link
8080
yarn install
81+
yarn build
8182
popd
8283

8384
yarn link matrix-js-sdk
@@ -95,6 +96,7 @@ pushd matrix-react-sdk
9596
yarn link
9697
yarn link matrix-js-sdk
9798
yarn install
99+
yarn build
98100
popd
99101

100102
yarn link matrix-react-sdk

0 commit comments

Comments
 (0)