Skip to content

Commit c982924

Browse files
committed
Upgraded webpack to version 4
1 parent dacebb7 commit c982924

File tree

10 files changed

+1487
-1135
lines changed

10 files changed

+1487
-1135
lines changed

Makefile

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ node_modules:
3535
# Build theme for distribution with Webpack
3636
dist/adapter/index.js: $(shell find src/adapter) \
3737
.babelrc webpack.config.ts dist/index.js
38-
$(shell npm bin)/webpack --env.prod
38+
$(shell npm bin)/webpack --mode production
3939

4040
# Create directories
4141
dist/config dist/static:
@@ -78,16 +78,19 @@ lint: node_modules
7878

7979
# Execute integration tests
8080
test-integration: node_modules build
81-
$(shell npm bin)/karma start tests/karma.integration.conf.ts \
82-
--single-run
81+
TS_NODE_PROJECT=tests/tsconfig.json TS_NODE_FILES=1 \
82+
$(shell npm bin)/karma start tests/karma.integration.conf.ts \
83+
--single-run
8384

8485
# Execute unit tests
8586
test: node_modules
86-
$(shell npm bin)/karma start tests/karma.conf.ts --single-run
87+
TS_NODE_PROJECT=tests/tsconfig.json TS_NODE_FILES=1 \
88+
$(shell npm bin)/karma start tests/karma.conf.ts --single-run
8789

8890
# Execute unit tests in watch mode
8991
watch: node_modules
90-
$(shell npm bin)/karma start tests/karma.conf.ts
92+
TS_NODE_PROJECT=tests/tsconfig.json TS_NODE_FILES=1 \
93+
$(shell npm bin)/karma start tests/karma.conf.ts
9194

9295
# -----------------------------------------------------------------------------
9396

package-lock.json

Lines changed: 1436 additions & 949 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -30,52 +30,52 @@
3030
"main": "dist/index.js",
3131
"types": "dist/index.d.ts",
3232
"scripts": {
33-
"build": "make -j clean build",
33+
"build": "make build",
3434
"clean": "make clean",
3535
"lint": "make lint",
3636
"test": "make test",
3737
"test:integration": "make test-integration",
3838
"watch": "make watch"
3939
},
4040
"dependencies": {
41-
"@types/karma": "^1.7.3",
42-
"jsonschema": "^1.1.1"
41+
"@types/karma": "^1.7.7",
42+
"jsonschema": "^1.2.4"
4343
},
4444
"devDependencies": {
45-
"@types/chance": "^1.0.0",
46-
"@types/jasmine": "^2.8.6",
45+
"@types/chance": "^1.0.1",
46+
"@types/jasmine": "^2.8.14",
4747
"@types/jsonschema": "^1.1.1",
48-
"@types/karma-fixture": "^0.2.3",
49-
"@types/node": "^9.4.7",
48+
"@types/karma-fixture": "^0.2.5",
49+
"@types/node": "^9.6.41",
5050
"@types/webpack": "^4.4.22",
5151
"array-findindex-polyfill": "^0.1.0",
52-
"babel-core": "^6.25.0",
53-
"babel-loader": "^7.1.1",
54-
"babel-preset-env": "^1.6.1",
55-
"chance": "^1.0.13",
52+
"babel-core": "^6.26.3",
53+
"babel-loader": "^7.1.5",
54+
"babel-preset-env": "^1.7.0",
55+
"chance": "^1.0.18",
5656
"codecov": "^3.1.0",
57-
"es6-promise": "^4.2.4",
58-
"event-hooks-webpack-plugin": "^1.0.0",
57+
"es6-promise": "^4.2.5",
5958
"git-hooks": "^1.1.8",
60-
"istanbul-instrumenter-loader": "^3.0.0",
59+
"istanbul-instrumenter-loader": "^3.0.1",
6160
"jasmine-core": "^2.7.0",
6261
"karma": "^3.1.4",
6362
"karma-chrome-launcher": "^2.2.0",
6463
"karma-clear-screen-reporter": "^1.0.0",
65-
"karma-coverage-istanbul-reporter": "^1.4.1",
64+
"karma-coverage-istanbul-reporter": "^1.4.3",
6665
"karma-fixture": "^0.2.6",
6766
"karma-html2js-preprocessor": "^1.1.0",
68-
"karma-jasmine": "^1.1.1",
67+
"karma-jasmine": "^1.1.2",
6968
"karma-sauce-launcher": "^2.0.2",
7069
"karma-sourcemap-loader": "^0.3.7",
7170
"karma-spec-reporter": "^0.0.32",
72-
"karma-summary-reporter": "^1.3.3",
71+
"karma-summary-reporter": "^1.5.2",
7372
"karma-webpack": "^2.0.13",
7473
"moniker": "^0.1.2",
75-
"ts-loader": "^3.5.0",
76-
"ts-node": "^6.2.0",
77-
"tslint": "^5.9.1",
78-
"typescript": "^2.8.1",
79-
"webpack": "^3.4.1"
74+
"ts-loader": "^4.4.2",
75+
"ts-node": "^7.0.1",
76+
"tslint": "^5.12.0",
77+
"typescript": "^3.2.2",
78+
"webpack": "^4.28.2",
79+
"webpack-cli": "^3.1.2"
8080
}
8181
}

tests/karma/common.ts

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,6 @@ import {
3333
RuleSetRule as WebpackRuleSetRule
3434
} from "webpack"
3535

36-
/* ----------------------------------------------------------------------------
37-
* Plugins
38-
* ------------------------------------------------------------------------- */
39-
40-
import EventHooksPlugin = require("event-hooks-webpack-plugin")
41-
4236
/* ----------------------------------------------------------------------------
4337
* Functions
4438
* ------------------------------------------------------------------------- */
@@ -88,19 +82,6 @@ export function webpack(
8882
/* Polyfills */
8983
new ProvidePlugin({
9084
Promise: "es6-promise"
91-
}),
92-
93-
/* Hack: The webpack development middleware sometimes goes into a loop
94-
on macOS when starting for the first time. This is a quick fix until
95-
this issue is resolved. See: http://bit.ly/2AsizEn */
96-
new EventHooksPlugin({
97-
"watch-run": (compiler: any, done: () => {}) => {
98-
compiler.startTime += 10000
99-
done()
100-
},
101-
"done": (stats: any) => {
102-
stats.startTime -= 10000
103-
}
10485
})
10586
],
10687
devtool: "source-map"
@@ -122,7 +103,7 @@ export function saucelabs(
122103

123104
/* Define browsers to run tests on, see http://bit.ly/2pl96u1 */
124105
browsers: Object.keys(browsers),
125-
customLaunchers: browsers,
106+
customLaunchers: browsers as any,
126107

127108
/* Configure SauceLabs integration */
128109
concurrency: 5,

tests/tsconfig.json

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,11 @@
11
{
2+
"extends": "../tsconfig.json",
23
"compilerOptions": {
3-
"allowJs": true,
4-
"alwaysStrict": true,
5-
"baseUrl": ".",
6-
"lib": [
7-
"dom",
8-
"es2015",
9-
"esnext"
10-
],
11-
"moduleResolution": "node",
12-
"noFallthroughCasesInSwitch": true,
13-
"noImplicitAny": true,
14-
"noImplicitReturns": true,
15-
"noImplicitThis": true,
16-
"noUnusedLocals": true,
17-
"noUnusedParameters": true,
18-
"outDir": "dist",
19-
"paths": {
20-
"~/*": ["../src/*"],
21-
"_/*": ["./*"]
22-
},
23-
"preserveConstEnums": true,
24-
"removeComments": true,
25-
"sourceMap": true,
26-
"strict": true,
27-
"stripInternal": true,
28-
"target": "es5"
4+
"removeComments": false
295
},
306
"include": [
31-
".",
7+
"../src",
8+
"../tests",
329
"../typings"
33-
],
34-
"exclude": [
35-
"node_modules"
3610
]
3711
}

tsconfig.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"es2015",
88
"esnext"
99
],
10+
"module": "commonjs",
1011
"moduleResolution": "node",
1112
"noFallthroughCasesInSwitch": true,
1213
"noImplicitAny": true,
@@ -17,6 +18,7 @@
1718
"outDir": "dist",
1819
"preserveConstEnums": true,
1920
"removeComments": true,
21+
"resolveJsonModule": true,
2022
"sourceMap": true,
2123
"strict": true,
2224
"stripInternal": true,

typings/event-hooks-webpack-plugin.d.ts

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

typings/global.d.ts

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

typings/karma.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ declare module "karma" {
3636
coverageIstanbulReporter?: { /* karma-coverage */
3737
reports: string[]
3838
}
39-
customLaunchers?: any /* karma-sauce-launcher */
4039
sauceLabs?: {
4140
build?: string,
4241
testName: string,

webpack.config.ts

Lines changed: 14 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -24,32 +24,27 @@ import * as path from "path"
2424
import {
2525
Configuration,
2626
NoEmitOnErrorsPlugin,
27-
optimize,
2827
ProvidePlugin
2928
} from "webpack"
3029

31-
/* Webpack plugins */
32-
const {
33-
UglifyJsPlugin
34-
} = optimize
35-
36-
/* ----------------------------------------------------------------------------
37-
* Plugins
38-
* ------------------------------------------------------------------------- */
39-
40-
import EventHooksPlugin = require("event-hooks-webpack-plugin")
41-
4230
/* ----------------------------------------------------------------------------
4331
* Configuration
4432
* ------------------------------------------------------------------------- */
4533

46-
export default (env?: { prod?: boolean }) => {
34+
/**
35+
* Webpack configuration
36+
*
37+
* @param env - Webpack environment arguments
38+
* @param args - Command-line arguments
39+
*
40+
* @return Webpack configuration
41+
*/
42+
export default (_env: never, args: Configuration) => {
4743
const config: Configuration = {
44+
mode: args.mode,
4845

4946
/* Entrypoint */
50-
entry: [
51-
path.resolve(__dirname, "src/adapter/index.ts")
52-
],
47+
entry: ["src/adapter"],
5348

5449
/* Loaders */
5550
module: {
@@ -66,6 +61,8 @@ export default (env?: { prod?: boolean }) => {
6661
compilerOptions: {
6762
declaration: true,
6863
declarationDir: "..",
64+
noUnusedLocals: args.mode === "production",
65+
noUnusedParameters: args.mode === "production",
6966
removeComments: false,
7067
target: "es2015" /* Use ES modules for tree-shaking */
7168
}
@@ -80,7 +77,7 @@ export default (env?: { prod?: boolean }) => {
8077
/* Export class constructor as entrypoint */
8178
output: {
8279
path: path.resolve(__dirname, "dist/adapter"),
83-
pathinfo: true,
80+
pathinfo: false,
8481
filename: "index.js",
8582
libraryTarget: "window"
8683
},
@@ -94,19 +91,6 @@ export default (env?: { prod?: boolean }) => {
9491
/* Polyfills */
9592
new ProvidePlugin({
9693
Promise: "es6-promise"
97-
}),
98-
99-
/* Hack: The webpack development middleware sometimes goes into a loop
100-
on macOS when starting for the first time. This is a quick fix until
101-
this issue is resolved. See: http://bit.ly/2AsizEn */
102-
new EventHooksPlugin({
103-
"watch-run": (compiler: any, done: () => {}) => {
104-
compiler.startTime += 10000
105-
done()
106-
},
107-
"done": (stats: any) => {
108-
stats.startTime -= 10000
109-
}
11094
})
11195
],
11296

@@ -123,29 +107,6 @@ export default (env?: { prod?: boolean }) => {
123107
devtool: "source-map"
124108
}
125109

126-
/* Build for production environment */
127-
if (env && env.prod) {
128-
129-
/* Uglify sources */
130-
config.plugins!.push(
131-
new UglifyJsPlugin({
132-
comments: false,
133-
compress: {
134-
warnings: false,
135-
screw_ie8: true,
136-
conditionals: true,
137-
unused: true,
138-
comparisons: true,
139-
sequences: true,
140-
dead_code: true,
141-
evaluate: true,
142-
if_return: true,
143-
join_vars: true
144-
},
145-
sourceMap: true
146-
}))
147-
}
148-
149110
/* We're good to go */
150111
return config
151112
}

0 commit comments

Comments
 (0)