From a7126bf58b1b8d856ab6568e5475f3ad507af0d3 Mon Sep 17 00:00:00 2001 From: Tobias Schmidt Date: Wed, 26 Feb 2020 12:45:55 +0100 Subject: [PATCH 1/7] move configuration files to corresponding package --- development.configuration.ts | 9 --------- .../configuration/src/development.configuration.ts | 10 +++++++++- packages/configuration/src/production.configuration.ts | 10 +++++++++- production.configuration.ts | 9 --------- 4 files changed, 18 insertions(+), 20 deletions(-) delete mode 100644 development.configuration.ts mode change 120000 => 100644 packages/configuration/src/development.configuration.ts mode change 120000 => 100644 packages/configuration/src/production.configuration.ts delete mode 100644 production.configuration.ts diff --git a/development.configuration.ts b/development.configuration.ts deleted file mode 100644 index eeeb40b..0000000 --- a/development.configuration.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { Configuration } from 'elite-types'; - -const configuration: Configuration = { - featureMap: { - 'under-construction-message': true, - }, -}; - -export default configuration; diff --git a/packages/configuration/src/development.configuration.ts b/packages/configuration/src/development.configuration.ts deleted file mode 120000 index 5d97350..0000000 --- a/packages/configuration/src/development.configuration.ts +++ /dev/null @@ -1 +0,0 @@ -../../../development.configuration.ts \ No newline at end of file diff --git a/packages/configuration/src/development.configuration.ts b/packages/configuration/src/development.configuration.ts new file mode 100644 index 0000000..eeeb40b --- /dev/null +++ b/packages/configuration/src/development.configuration.ts @@ -0,0 +1,9 @@ +import { Configuration } from 'elite-types'; + +const configuration: Configuration = { + featureMap: { + 'under-construction-message': true, + }, +}; + +export default configuration; diff --git a/packages/configuration/src/production.configuration.ts b/packages/configuration/src/production.configuration.ts deleted file mode 120000 index d31b870..0000000 --- a/packages/configuration/src/production.configuration.ts +++ /dev/null @@ -1 +0,0 @@ -../../../production.configuration.ts \ No newline at end of file diff --git a/packages/configuration/src/production.configuration.ts b/packages/configuration/src/production.configuration.ts new file mode 100644 index 0000000..a21f371 --- /dev/null +++ b/packages/configuration/src/production.configuration.ts @@ -0,0 +1,9 @@ +import { Configuration } from 'elite-types'; + +const configuration: Configuration = { + featureMap: { + 'under-construction-message': false, + }, +}; + +export default configuration; diff --git a/production.configuration.ts b/production.configuration.ts deleted file mode 100644 index a21f371..0000000 --- a/production.configuration.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { Configuration } from 'elite-types'; - -const configuration: Configuration = { - featureMap: { - 'under-construction-message': false, - }, -}; - -export default configuration; From f73ef730d0b28dc39d46e0a7b736f3b34abc9191 Mon Sep 17 00:00:00 2001 From: Tobias Schmidt Date: Wed, 26 Feb 2020 12:53:56 +0100 Subject: [PATCH 2/7] add development webpack configuration and enable project references for ts-loader --- .../{webpack.config.js => development.webpack.config.js} | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) rename packages/frontend/{webpack.config.js => development.webpack.config.js} (96%) diff --git a/packages/frontend/webpack.config.js b/packages/frontend/development.webpack.config.js similarity index 96% rename from packages/frontend/webpack.config.js rename to packages/frontend/development.webpack.config.js index 14ea36e..c0bfeed 100644 --- a/packages/frontend/webpack.config.js +++ b/packages/frontend/development.webpack.config.js @@ -6,13 +6,15 @@ module.exports = { entry: { app: ['react-hot-loader/patch', './src/index.tsx'], }, - devtool: 'source-map', module: { rules: [ { test: /\.tsx?$/, use: { loader: require.resolve('ts-loader'), + options: { + projectReferences: true, + }, }, exclude: /node_modules/, }, From 56207c0f48c96eee268eafc006509bf6be6b7160 Mon Sep 17 00:00:00 2001 From: Tobias Schmidt Date: Wed, 26 Feb 2020 12:58:27 +0100 Subject: [PATCH 3/7] watch typescript files with webpack-dev-server --- packages/configuration/package.json | 3 +-- packages/feature-flags/package.json | 3 +-- packages/types/package.json | 9 +++------ 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/packages/configuration/package.json b/packages/configuration/package.json index dafe845..912f77c 100644 --- a/packages/configuration/package.json +++ b/packages/configuration/package.json @@ -5,8 +5,7 @@ "publishConfig": { "access": "public" }, - "types": "dist/index.d.ts", - "main": "dist/index.js", + "main": "src/index.ts", "scripts": { "clean": "rm -rf dist/ node_modules/ tsconfig.tsbuildinfo" }, diff --git a/packages/feature-flags/package.json b/packages/feature-flags/package.json index 209bd94..68f70a5 100644 --- a/packages/feature-flags/package.json +++ b/packages/feature-flags/package.json @@ -5,8 +5,7 @@ "publishConfig": { "access": "public" }, - "types": "dist/index.d.ts", - "main": "dist/index.js", + "main": "src/index.ts", "scripts": { "clean": "rm -rf dist/ node_modules/ tsconfig.tsbuildinfo" }, diff --git a/packages/types/package.json b/packages/types/package.json index 444a0b3..2f5cf4b 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -5,13 +5,10 @@ "publishConfig": { "access": "public" }, - "types": "dist/index.d.ts", - "main": "dist/index.js", + "main": "src/index.ts", "scripts": { "clean": "rm -rf dist/ node_modules/ tsconfig.tsbuildinfo" }, - "devDependencies": { - }, - "dependencies": { - } + "devDependencies": {}, + "dependencies": {} } From 9ac730577eabf17dd75ad41ca2b1b892566f1a01 Mon Sep 17 00:00:00 2001 From: Tobias Schmidt Date: Wed, 26 Feb 2020 12:59:54 +0100 Subject: [PATCH 4/7] add production webpack configuration --- .../frontend/production.webpack.config.js | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 packages/frontend/production.webpack.config.js diff --git a/packages/frontend/production.webpack.config.js b/packages/frontend/production.webpack.config.js new file mode 100644 index 0000000..7468be2 --- /dev/null +++ b/packages/frontend/production.webpack.config.js @@ -0,0 +1,72 @@ +const path = require('path'); +const HtmlWebpackPlugin = require('html-webpack-plugin'); + +module.exports = { + entry: { + app: ['./src/index.tsx'], + }, + module: { + rules: [ + { + test: /\.tsx?$/, + use: { + loader: require.resolve('ts-loader'), + options: { + projectReferences: true, + }, + }, + exclude: /node_modules/, + }, + { + test: /\.css$/, + use: ['style-loader', 'css-loader'], + }, + { + test: /\.html$/, + use: [ + { + loader: 'html-loader', + options: { minimize: true }, + }, + ], + }, + { + test: /\.(png|svg|jpg|gif|pdf)$/, + use: [ + { + loader: 'file-loader', + options: { + name: '[name].[ext]', + }, + }, + ], + }, + ], + }, + resolve: { + modules: ['node_modules'], + extensions: ['.ts', '.tsx', '.js', '.jsx'], + symlinks: true, + }, + output: { + publicPath: '/', + filename: 'frontend.bundle.js', + path: path.resolve(__dirname, 'dist'), + }, + plugins: [ + new HtmlWebpackPlugin({ + template: path.resolve(__dirname, 'src/index.html'), + inject: 'body', + }), + ], + node: { + module: 'empty', + dgram: 'empty', + dns: 'mock', + fs: 'empty', + http2: 'empty', + net: 'empty', + tls: 'empty', + child_process: 'empty', + }, +}; From 003bce00589fdd9f5777c0a6ef8b8b3086aa4b0a Mon Sep 17 00:00:00 2001 From: Tobias Schmidt Date: Wed, 26 Feb 2020 13:00:28 +0100 Subject: [PATCH 5/7] adapt npm scripts --- package.json | 7 +++---- packages/frontend/package.json | 6 +++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index ad1b985..b3ac0dc 100644 --- a/package.json +++ b/package.json @@ -8,11 +8,11 @@ "packages/*" ], "scripts": { - "clean": "lerna run clean --stream && rm -rfv node_modules tsconfig.tsbuildinfo", + "clean": "lerna run clean --stream && rm -rfv tsconfig.tsbuildinfo", "postinstall": "patch-package", "lint": "eslint './packages/*/src/**/*.{ts,d.ts}' --max-warnings 0", "lint:fix": "eslint './packages/*/src/**/*.{ts,d.ts}' --fix", - "build": "tsc -b && lerna run webpack:build --stream", + "build": "lerna run webpack:build --stream", "frontend:start": "lerna run frontend:start --stream", "frontend:watch": "lerna run frontend:watch --stream", "watch": "tsc -b -w" @@ -37,7 +37,6 @@ "react": "^16.12.0", "react-dom": "^16.12.0", "react-hot-loader": "^4.12.18", - "source-map-loader": "^0.2.4", "style-loader": "^1.0.1", "ts-loader": "^6.2.1", "typescript": "^3.7.2", @@ -47,4 +46,4 @@ }, "resolutions": {}, "dependencies": {} -} \ No newline at end of file +} diff --git a/packages/frontend/package.json b/packages/frontend/package.json index 5468a6f..6fec32b 100644 --- a/packages/frontend/package.json +++ b/packages/frontend/package.json @@ -6,9 +6,9 @@ "access": "public" }, "scripts": { - "frontend:watch": "webpack-dev-server --mode development --color --hot --progress", - "frontend:start": "webpack-dev-server --mode production --color --progress", - "webpack:build": "webpack --mode production", + "frontend:watch": "webpack-dev-server --mode development --color --hot --progress --config development.webpack.config.js", + "frontend:start": "webpack-dev-server --mode production --color --hot --progress --config development.webpack.config.js", + "webpack:build": "webpack --mode production --config production.webpack.config.js", "clean": "rm -rf dist/ node_modules/ tsconfig.tsbuildinfo" }, "devDependencies": { From b75539d5d18a8ce7890e1af5090173b61e462e2d Mon Sep 17 00:00:00 2001 From: Tobias Schmidt Date: Wed, 26 Feb 2020 13:02:47 +0100 Subject: [PATCH 6/7] do not build source map files --- tsconfig.base.json | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/tsconfig.base.json b/tsconfig.base.json index 6e7a660..c544db9 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -20,22 +20,15 @@ "moduleResolution": "node", "strict": true, "importHelpers": true, - "sourceMap": true, - "declarationMap": true, + "sourceMap": false, + "declarationMap": false, "declaration": true, "composite": true, "allowSyntheticDefaultImports": true, "jsx": "react", - "lib": [ - "esnext", - "dom" - ], + "lib": ["esnext", "dom"], "resolveJsonModule": true, "esModuleInterop": true }, - "exclude": [ - "./node_modules", - "./packages/*/node_modules", - "./packages/*/dist" - ] -} \ No newline at end of file + "exclude": ["./node_modules", "./packages/*/node_modules", "./packages/*/dist"] +} From 11fe2ddb75eda26b6b85d8d775f42f320ed8e101 Mon Sep 17 00:00:00 2001 From: Tobias Schmidt Date: Wed, 26 Feb 2020 13:03:21 +0100 Subject: [PATCH 7/7] update yarn lock file --- yarn.lock | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/yarn.lock b/yarn.lock index 5ce0359..40fd992 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1564,7 +1564,7 @@ async-limiter@~1.0.0: resolved "https://registry.yarnpkg.com/async-limiter/-/async-limiter-1.0.1.tgz#dd379e94f0db8310b08291f9d64c3209766617fd" integrity sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ== -async@^2.5.0, async@^2.6.2: +async@^2.6.2: version "2.6.3" resolved "https://registry.yarnpkg.com/async/-/async-2.6.3.tgz#d72625e2344a3656e3a3ad4fa749fa83299d82ff" integrity sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg== @@ -7568,14 +7568,6 @@ source-list-map@^2.0.0: resolved "https://registry.yarnpkg.com/source-list-map/-/source-list-map-2.0.1.tgz#3993bd873bfc48479cca9ea3a547835c7c154b34" integrity sha512-qnQ7gVMxGNxsiL4lEuJwe/To8UnK7fAnmbGEEH8RpLouuKbeEm0lhbQVFIrNSuB+G7tVrAlVsZgETT5nljf+Iw== -source-map-loader@^0.2.4: - version "0.2.4" - resolved "https://registry.yarnpkg.com/source-map-loader/-/source-map-loader-0.2.4.tgz#c18b0dc6e23bf66f6792437557c569a11e072271" - integrity sha512-OU6UJUty+i2JDpTItnizPrlpOIBLmQbWMuBg9q5bVtnHACqw1tn9nNwqJLbv0/00JjnJb/Ee5g5WS5vrRv7zIQ== - dependencies: - async "^2.5.0" - loader-utils "^1.1.0" - source-map-resolve@^0.5.0: version "0.5.3" resolved "https://registry.yarnpkg.com/source-map-resolve/-/source-map-resolve-0.5.3.tgz#190866bece7553e1f8f267a2ee82c606b5509a1a"