From 3e7561f5c3a746ed00cda622e389e87824e1c64e Mon Sep 17 00:00:00 2001 From: MTRNord Date: Tue, 15 Aug 2017 22:56:30 +0200 Subject: [PATCH 01/10] Update to webpack3 --- karma.conf.js | 7 ++++--- package.json | 17 ++++++++--------- webpack.config.js | 22 ++++++++++++++-------- 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/karma.conf.js b/karma.conf.js index 3b415b1ae6b..f717387809f 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -33,8 +33,8 @@ const olm_entry = webpack_config.entry['olm']; delete webpack_config['entry']; // add ./test as a search path for js -webpack_config.module.loaders.unshift({ - test: /\.js$/, loader: "babel", +webpack_config.module.rules.unshift({ + test: /\.js$/, use: "babel-loader", include: [path.resolve('./src'), path.resolve('./test')], }); @@ -46,8 +46,9 @@ webpack_config.module.noParse.push(/sinon\/pkg\/sinon\.js$/); // ? webpack_config.resolve.alias['sinon'] = 'sinon/pkg/sinon.js'; -webpack_config.resolve.root = [ +webpack_config.resolve.modules = [ path.resolve('./test'), + "node_modules" ]; webpack_config.devtool = 'inline-source-map'; diff --git a/package.json b/package.json index bb35ce89904..21f0f1a9a8f 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "build:modernizr": "modernizr -c .modernizr.json -d src/vector/modernizr.js", "build:compile": "npm run reskindex && babel --source-maps -d lib src", "build:bundle": "cross-env NODE_ENV=production webpack -p --progress --bail", - "build:bundle:dev": "webpack --optimize-occurence-order --progress --bail", + "build:bundle:dev": "webpack --progress --bail", "build:electron": "npm run clean && npm run build && npm run install:electron && build -wml --ia32 --x64", "build": "npm run reskindex && npm run build:res && npm run build:bundle", "build:dev": "npm run reskindex && npm run build:res && npm run build:bundle:dev", @@ -40,7 +40,7 @@ "install:electron": "install-app-deps", "electron": "npm run install:electron && electron .", "start:res": "node scripts/copy-res.js -w", - "start:js": "webpack-dev-server --output-filename=bundles/_dev_/[name].js --output-chunk-file=bundles/_dev_/[name].js -w --progress", + "start:js": "webpack-dev-server --output-filename=bundles/_dev_/[name].js --output-chunk-filename=bundles/_dev_/[name].js -w --progress", "start:js:prod": "cross-env NODE_ENV=production webpack-dev-server -w --progress", "start": "parallelshell \"npm run reskindex:watch\" \"npm run start:res\" \"npm run start:js\"", "start:prod": "parallelshell \"npm run reskindex:watch\" \"npm run start:res\" \"npm run start:js:prod\"", @@ -58,7 +58,7 @@ "browser-request": "^0.3.3", "classnames": "^2.1.2", "draft-js": "^0.11.0-alpha", - "extract-text-webpack-plugin": "^0.9.1", + "extract-text-webpack-plugin": "^3.0.0", "favico.js": "^0.3.10", "filesize": "3.5.6", "flux": "2.1.1", @@ -112,8 +112,7 @@ "eslint-plugin-react": "^6.9.0", "expect": "^1.16.0", "fs-extra": "^0.30.0", - "html-webpack-plugin": "^2.24.0", - "json-loader": "^0.5.3", + "html-webpack-plugin": "^2.30.1", "karma": "^1.7.0", "karma-chrome-launcher": "^0.2.3", "karma-cli": "^0.1.2", @@ -123,7 +122,7 @@ "karma-sourcemap-loader": "^0.3.7", "karma-spec-reporter": "0.0.31", "karma-summary-reporter": "^1.3.3", - "karma-webpack": "^1.7.0", + "karma-webpack": "^2.0.4", "matrix-mock-request": "^1.2.0", "matrix-react-test-utils": "^0.2.0", "minimist": "^1.2.0", @@ -141,9 +140,9 @@ "react-addons-perf": "^15.4.0", "react-addons-test-utils": "^15.6.0", "rimraf": "^2.4.3", - "source-map-loader": "^0.1.5", - "webpack": "^1.12.14", - "webpack-dev-server": "^1.16.2" + "source-map-loader": "^0.2.1", + "webpack": "^3.5.2", + "webpack-dev-server": "^2.7.1" }, "optionalDependencies": { "olm": "https://matrix.org/packages/npm/olm/olm-2.2.1.tgz" diff --git a/webpack.config.js b/webpack.config.js index 5d4fef72a9c..d1aa3828494 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -22,14 +22,12 @@ module.exports = { "theme-dark": "./src/skins/vector/css/themes/dark.scss", }, module: { - preLoaders: [ - { test: /\.js$/, loader: "source-map-loader" }, - ], - loaders: [ - { test: /\.json$/, loader: "json" }, - { test: /\.js$/, loader: "babel", include: path.resolve('./src') }, + rules: [ + { enforce: 'pre', test: /\.js$/, use: "source-map-loader", exclude: /node_modules/, }, + { test: /\.js$/, use: "babel-loader", include: path.resolve('./src') }, { test: /\.scss$/, + exclude: /node_modules/, // 1. postcss-loader turns the SCSS into normal CSS. // 2. css-raw-loader turns the CSS into a javascript module @@ -38,13 +36,21 @@ module.exports = { // would also drag in the imgs and fonts that our CSS refers to // as webpack inputs.) // 3. ExtractTextPlugin turns that string into a separate asset. - loader: ExtractTextPlugin.extract("css-raw-loader!postcss-loader?config=postcss.config.js"), + use: ExtractTextPlugin.extract({ + use: [ + "css-raw-loader", + "postcss-loader" + ], + }), }, { // this works similarly to the scss case, without postcss. test: /\.css$/, - loader: ExtractTextPlugin.extract("css-raw-loader"), + use: ExtractTextPlugin.extract({ + use: "css-raw-loader" + }), }, + ], noParse: [ // for cross platform compatibility use [\\\/] as the path separator From 7ae2548f060185c2083dffa29bd6df32cdd0ed6b Mon Sep 17 00:00:00 2001 From: MTRNord Date: Wed, 16 Aug 2017 00:26:45 +0200 Subject: [PATCH 02/10] Force olm to be loaded before all other .js files. --- src/vector/index.html | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/vector/index.html b/src/vector/index.html index 49c2979ed1d..f4a31bd861e 100644 --- a/src/vector/index.html +++ b/src/vector/index.html @@ -38,6 +38,13 @@
<% for (var i=0; i < htmlWebpackPlugin.files.js.length; i++) { + if (_.endsWith(htmlWebpackPlugin.files.js[i], 'olm.js')) { + var array = htmlWebpackPlugin.files.js; + htmlWebpackPlugin.files.js.unshift(htmlWebpackPlugin.files.js[i]); + htmlWebpackPlugin.files.js.splice(i, 1); + } + } + for (var i=0; i < htmlWebpackPlugin.files.js.length; i++) { // Not a particularly graceful way of not putting the indexeddb worker script // into the main page if (_.endsWith(htmlWebpackPlugin.files.js[i], 'indexeddb-worker.js')) { From 809cb331cdab1e4ca156162ac7e7a36740358bd9 Mon Sep 17 00:00:00 2001 From: MTRNord Date: Wed, 16 Aug 2017 01:23:40 +0200 Subject: [PATCH 03/10] Change install order in tests to prevent NPM fail --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 94ed745cd82..bb3e5512b90 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,4 +29,4 @@ addons: install: # clone the deps with depth 1: we know we will only ever need that one # commit. - - scripts/fetch-develop.deps.sh --depth 1 && npm install + - npm install && scripts/fetch-develop.deps.sh --depth 1 From 46b784b098366c4576a6dcb07c47071d2ba3dd7a Mon Sep 17 00:00:00 2001 From: MTRNord Date: Wed, 16 Aug 2017 21:17:08 +0200 Subject: [PATCH 04/10] Fix Modal lacking needed functions --- src/components/views/context_menus/MessageContextMenu.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/views/context_menus/MessageContextMenu.js b/src/components/views/context_menus/MessageContextMenu.js index d6d9302fde2..62287f8a6c7 100644 --- a/src/components/views/context_menus/MessageContextMenu.js +++ b/src/components/views/context_menus/MessageContextMenu.js @@ -22,7 +22,7 @@ const MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg'); const dis = require('matrix-react-sdk/lib/dispatcher'); const sdk = require('matrix-react-sdk'); import { _t } from 'matrix-react-sdk/lib/languageHandler'; -const Modal = require('matrix-react-sdk/lib/Modal'); +import Modal = from 'matrix-react-sdk/lib/Modal'; const Resend = require("matrix-react-sdk/lib/Resend"); import * as UserSettingsStore from 'matrix-react-sdk/lib/UserSettingsStore'; From 6a2960f2947548736dbd43f0a9fb3e258271036a Mon Sep 17 00:00:00 2001 From: MTRNord Date: Wed, 16 Aug 2017 21:21:01 +0200 Subject: [PATCH 05/10] Fix typo on import --- src/components/views/context_menus/MessageContextMenu.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/views/context_menus/MessageContextMenu.js b/src/components/views/context_menus/MessageContextMenu.js index 62287f8a6c7..1c336831777 100644 --- a/src/components/views/context_menus/MessageContextMenu.js +++ b/src/components/views/context_menus/MessageContextMenu.js @@ -22,7 +22,7 @@ const MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg'); const dis = require('matrix-react-sdk/lib/dispatcher'); const sdk = require('matrix-react-sdk'); import { _t } from 'matrix-react-sdk/lib/languageHandler'; -import Modal = from 'matrix-react-sdk/lib/Modal'; +import Modal from 'matrix-react-sdk/lib/Modal'; const Resend = require("matrix-react-sdk/lib/Resend"); import * as UserSettingsStore from 'matrix-react-sdk/lib/UserSettingsStore'; From ddee08be5cebb8d7f70c1ca264ff51ac141f62ac Mon Sep 17 00:00:00 2001 From: Marcel Date: Mon, 9 Apr 2018 16:00:27 +0200 Subject: [PATCH 06/10] Update babel-loader version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index df7edd81f9a..07358c970c0 100644 --- a/package.json +++ b/package.json @@ -88,7 +88,7 @@ "babel-cli": "^6.5.2", "babel-core": "^6.14.0", "babel-eslint": "^6.1.0", - "babel-loader": "^6.2.5", + "babel-loader": "^7.1.4", "babel-plugin-add-module-exports": "^0.2.1", "babel-plugin-transform-async-to-bluebird": "^1.1.1", "babel-plugin-transform-class-properties": "^6.16.0", From 68c2c5cea6c733f36d99aca71be5ade70309ea83 Mon Sep 17 00:00:00 2001 From: Marcel Date: Fri, 20 Apr 2018 18:16:43 +0200 Subject: [PATCH 07/10] Fix wrongly resolved merge conflict --- package.json | 2 -- 1 file changed, 2 deletions(-) diff --git a/package.json b/package.json index fa81a301fe7..89d4d6c964a 100644 --- a/package.json +++ b/package.json @@ -58,8 +58,6 @@ "babel-runtime": "^6.11.6", "bluebird": "^3.5.0", "browser-request": "^0.3.3", - "classnames": "^2.1.2", - "draft-js": "^0.11.0-alpha", "extract-text-webpack-plugin": "^3.0.0", "favico.js": "^0.3.10", "matrix-js-sdk": "0.10.1", From 16707030867bf0365aa602ddf270b2b5594ce1d7 Mon Sep 17 00:00:00 2001 From: Marcel Date: Fri, 20 Apr 2018 20:44:11 +0200 Subject: [PATCH 08/10] Update postcss and its dependencies for webpack3 --- package.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 89d4d6c964a..9dfbab7ec9c 100644 --- a/package.json +++ b/package.json @@ -119,12 +119,12 @@ "mocha": "^2.4.5", "parallelshell": "^3.0.2", "postcss-extend": "^1.0.5", - "postcss-import": "^9.0.0", - "postcss-loader": "^1.2.2", - "postcss-mixins": "^5.4.1", - "postcss-nested": "^1.0.0", - "postcss-scss": "^0.4.0", - "postcss-simple-vars": "^3.0.0", + "postcss-import": "^11.1.0", + "postcss-loader": "^2.1.4", + "postcss-mixins": "^6.2.0", + "postcss-nested": "^3.0.0", + "postcss-scss": "^1.0.5", + "postcss-simple-vars": "^4.1.0", "postcss-strip-inline-comments": "^0.1.5", "react-addons-perf": "^15.4.0", "react-addons-test-utils": "^15.6.0", From 07a8505c88324ce256caf8cc6f22b28bcc45a098 Mon Sep 17 00:00:00 2001 From: MTRNord Date: Thu, 26 Apr 2018 22:10:01 +0200 Subject: [PATCH 09/10] Fix webpack to fail with @imports --- webpack.config.js | 1 - 1 file changed, 1 deletion(-) diff --git a/webpack.config.js b/webpack.config.js index f05460bf8df..5a35e8f95a2 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -31,7 +31,6 @@ module.exports = { { test: /\.js$/, use: "babel-loader", include: path.resolve('./src') }, { test: /\.scss$/, - exclude: /node_modules/, // 1. postcss-loader turns the SCSS into normal CSS. // 2. css-raw-loader turns the CSS into a javascript module From f8e426383215dcd4a142d3fa382d6cf5420ee648 Mon Sep 17 00:00:00 2001 From: MTRNord Date: Thu, 26 Apr 2018 22:20:44 +0200 Subject: [PATCH 10/10] Use include instead including all scss of node_modules --- webpack.config.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/webpack.config.js b/webpack.config.js index 5a35e8f95a2..bc3515d2ae0 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -28,10 +28,14 @@ module.exports = { module: { rules: [ { enforce: 'pre', test: /\.js$/, use: "source-map-loader", exclude: /node_modules/, }, - { test: /\.js$/, use: "babel-loader", include: path.resolve('./src') }, + { test: /\.js$/, use: "babel-loader", include: path.resolve(__dirname, 'src') }, { test: /\.scss$/, - + include: [ + path.resolve(__dirname, 'res/themes/status/css/'), + path.resolve(__dirname, 'node_modules/matrix-react-sdk/res/themes/light/css/'), + path.resolve(__dirname, 'node_modules/matrix-react-sdk/res/themes/dark/css/'), + ], // 1. postcss-loader turns the SCSS into normal CSS. // 2. css-raw-loader turns the CSS into a javascript module // whose default export is a string containing the CSS.