Skip to content

Commit 5838e15

Browse files
committed
feat(webpack): update to webpack 4
1 parent 3bfd735 commit 5838e15

File tree

9 files changed

+114
-120
lines changed

9 files changed

+114
-120
lines changed

build/tasks/update-dependenciesjs.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ const latestVersion = require('latest-version');
33
const fs = require('fs');
44
const path = require('path');
55

6+
const ignore = ['text', 'gulp', 'extract-text-webpack-plugin'];
7+
68
gulp.task('update-cli-dependenciesjs', function(done) {
79
let deps = getDepsJSON();
810
updateCLIVersion(deps);
@@ -15,14 +17,14 @@ gulp.task('update-cli-dependenciesjs', function(done) {
1517
gulp.task('update-all-dependenciesjs', function() {
1618
let deps = getDepsJSON();
1719
let p = Promise.resolve();
18-
let lookup = Object.keys(deps);
20+
let lookup = Object.keys(deps).filter(x => !ignore.contains(x));
1921

2022
// for all entries in dependencies.json, lookup the latest version and update the json file
2123
for (let i = 0; i < lookup.length; i++) {
2224
p = p.then(() => {
2325
return latestVersion(lookup[i])
2426
.then(ver => {
25-
console.log('Latest version of ' + lookup[i] + ' is: ' + ver);
27+
console.log(`Latest version of ${lookup[i]} (currently ${deps[lookup[i]]}) is: ${ver}`);
2628
deps[lookup[i]] = '^' + ver;
2729
});
2830
});

lib/commands/new/buildsystems/webpack/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ module.exports = function(project, options) {
5252
'extract-text-webpack-plugin',
5353
'aurelia-webpack-plugin',
5454
'webpack',
55+
'webpack-cli',
5556
'webpack-dev-server',
5657
'expose-loader',
5758
'style-loader',

lib/commands/new/buildsystems/webpack/transpilers/typescript.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module.exports = function(project) {
1212
ProjectItem.resource('system.d.ts', 'content/custom_typings_webpack/system.d.ts')
1313
)
1414
).addToDevDependencies(
15-
'awesome-typescript-loader',
15+
'ts-loader',
1616
'ts-node',
1717
'@types/node',
1818
'@types/lodash',

lib/commands/new/buildsystems/webpack/unit-test-runners/jest.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ module.exports = function(project) {
8888
],
8989
testEnvironment: 'node',
9090
moduleNameMapper: {
91-
'aurelia-(.*)': '<rootDir>/node_modules/$1'
91+
'aurelia-(.*)': '<rootDir>/node_modules/aurelia-$1'
9292
},
9393
collectCoverage: true,
9494
collectCoverageFrom: [
@@ -103,8 +103,7 @@ module.exports = function(project) {
103103
'lcov',
104104
'text',
105105
'html'
106-
],
107-
mapCoverage: true
106+
]
108107
};
109108
}
110109
};

lib/dependencies.json

Lines changed: 96 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -1,107 +1,109 @@
11
{
2-
"@types/jasmine": "^2.2.0",
3-
"@types/jest": "19.2.4",
4-
"@types/lodash": "^4.14.69",
5-
"@types/node": "^6.0.45",
6-
"@types/webpack": "^3.0.4",
7-
"aspnet-webpack": "^2.0.1",
8-
"aurelia-animator-css": "^1.0.2",
9-
"aurelia-bootstrapper": "^2.1.1",
2+
"@types/jasmine": "^2.8.6",
3+
"@types/jest": "^22.1.4",
4+
"@types/lodash": "^4.14.104",
5+
"@types/node": "^9.4.6",
6+
"@types/webpack": "^3.8.8",
7+
"aspnet-webpack": "^2.0.3",
8+
"aurelia-animator-css": "^1.0.4",
9+
"aurelia-bootstrapper": "^2.2.0",
1010
"aurelia-cli": "^0.32.0",
1111
"aurelia-loader-nodejs": "^1.0.1",
12-
"aurelia-pal-nodejs": "1.0.0-beta.3.0.0",
13-
"aurelia-protractor-plugin": "^1.0.5",
14-
"aurelia-testing": "^1.0.0-beta.3.0.1",
15-
"aurelia-tools": "^1.0.0",
16-
"aurelia-webpack-plugin": "^2.0.0-rc.4",
17-
"autoprefixer": "^6.3.6",
18-
"awesome-typescript-loader": "^3.2.1",
19-
"babel-core": "^6.25.0",
20-
"babel-eslint": "^6.0.4",
21-
"babel-jest": "github:JeroenVinke/babel-jest",
22-
"babel-loader": "^7.0.0",
23-
"babel-plugin-istanbul": "4.1.4",
24-
"babel-plugin-syntax-flow": "^6.8.0",
25-
"babel-plugin-transform-class-properties": "6.24.1",
12+
"aurelia-pal-nodejs": "^1.0.0-beta.3.0.0",
13+
"aurelia-protractor-plugin": "^1.0.6",
14+
"aurelia-testing": "^1.0.0-beta.4.0.0",
15+
"aurelia-tools": "^2.0.0",
16+
"aurelia-webpack-plugin": "^3.0.0-rc.1",
17+
"aurelia-polyfills": "^1.3.0",
18+
"autoprefixer": "^8.1.0",
19+
"babel-core": "^6.26.0",
20+
"babel-eslint": "^8.2.2",
21+
"babel-jest": "^22.4.1",
22+
"babel-loader": "^7.1.3",
23+
"babel-plugin-istanbul": "^4.1.5",
24+
"babel-plugin-syntax-flow": "^6.18.0",
25+
"babel-plugin-transform-class-properties": "^6.24.1",
2626
"babel-plugin-transform-decorators-legacy": "^1.3.4",
27-
"babel-plugin-transform-es2015-modules-amd": "^6.8.0",
28-
"babel-plugin-transform-es2015-modules-commonjs": "^6.10.3",
29-
"babel-plugin-transform-flow-strip-types": "^6.8.0",
30-
"babel-polyfill": "^6.9.1",
31-
"babel-preset-env": "1.5.2",
32-
"babel-preset-es2015": "^6.13.2",
33-
"babel-preset-stage-1": "^6.5.0",
34-
"babel-register": "^6.24.0",
35-
"bluebird": "^3.4.1",
36-
"browser-sync": "^2.13.0",
37-
"clean-webpack-plugin": "^0.1.17",
38-
"connect-history-api-fallback": "^1.2.0",
39-
"copy-webpack-plugin": "4.0.1",
40-
"cross-env": "5.0.1",
41-
"css-loader": "0.28.4",
42-
"debounce": "^1.0.2",
27+
"babel-plugin-transform-es2015-modules-amd": "^6.24.1",
28+
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.0",
29+
"babel-plugin-transform-flow-strip-types": "^6.22.0",
30+
"babel-polyfill": "^6.26.0",
31+
"babel-preset-env": "^1.6.1",
32+
"babel-preset-es2015": "^6.24.1",
33+
"babel-preset-stage-1": "^6.24.1",
34+
"babel-register": "^6.26.0",
35+
"bluebird": "^3.5.1",
36+
"browser-sync": "^2.23.6",
37+
"clean-webpack-plugin": "^0.1.18",
38+
"connect-history-api-fallback": "^1.5.0",
39+
"copy-webpack-plugin": "^4.5.0",
40+
"cross-env": "^5.1.3",
41+
"css-loader": "^0.28.10",
42+
"debounce": "^1.1.0",
4343
"del": "^3.0.0",
44-
"event-stream": "^3.3.3",
45-
"expose-loader": "0.7.3",
46-
"extract-text-webpack-plugin": "3.0.0",
47-
"file-loader": "0.11.2",
44+
"event-stream": "^3.3.4",
45+
"expose-loader": "^0.7.4",
46+
"extract-text-webpack-plugin": "next",
47+
"file-loader": "^1.1.11",
4848
"gulp": "github:gulpjs/gulp#4.0",
49-
"gulp-babel": "^6.1.2",
50-
"gulp-changed-in-place": "^2.0.3",
51-
"gulp-eslint": "^2.0.0",
52-
"gulp-htmlmin": "^3.0.0",
53-
"gulp-less": "^3.1.0",
54-
"gulp-notify": "^2.2.0",
55-
"gulp-plumber": "^1.1.0",
56-
"gulp-postcss": "6.1.1",
49+
"gulp-babel": "^7.0.1",
50+
"gulp-changed-in-place": "^2.3.0",
51+
"gulp-eslint": "^4.0.2",
52+
"gulp-htmlmin": "^4.0.0",
53+
"gulp-less": "^4.0.0",
54+
"gulp-notify": "^3.2.0",
55+
"gulp-plumber": "^1.2.0",
56+
"gulp-postcss": "7.0.1",
5757
"gulp-rename": "^1.2.2",
5858
"gulp-sass": "^3.1.0",
59-
"gulp-sourcemaps": "^2.0.0-alpha",
60-
"gulp-stylus": "^2.5.0",
61-
"gulp-tslint": "^5.0.0",
62-
"gulp-typescript": "^3.1.4",
59+
"gulp-sourcemaps": "^2.6.4",
60+
"gulp-stylus": "^2.7.0",
61+
"gulp-tslint": "^8.1.3",
62+
"gulp-typescript": "^4.0.1",
6363
"gulp-util": "^3.0.8",
64-
"gulp-watch": "^4.3.11",
65-
"html-minifier": "^3.2.3",
66-
"html-webpack-plugin": "2.30.1",
67-
"istanbul-instrumenter-loader": "^2.0.0",
68-
"jasmine-core": "^2.4.1",
69-
"jest": "20.0.4",
70-
"jest-jasmine2": "21.2.1",
71-
"jest-cli": "20.0.4",
64+
"gulp-watch": "^5.0.0",
65+
"html-minifier": "^3.5.9",
66+
"html-webpack-plugin": "^3.0.4",
67+
"istanbul-instrumenter-loader": "^3.0.0",
68+
"jasmine-core": "^3.1.0",
69+
"jest": "^22.4.2",
70+
"jest-jasmine2": "^22.4.2",
71+
"jest-cli": "^22.4.2",
7272
"jest-matchers": "^20.0.3",
73-
"json-loader": "0.5.7",
74-
"html-loader": "0.4.5",
75-
"karma": "^0.13.22",
76-
"karma-babel-preprocessor": "^6.0.1",
73+
"json-loader": "^0.5.7",
74+
"html-loader": "^0.5.5",
75+
"karma": "^2.0.0",
76+
"karma-babel-preprocessor": "^7.0.0",
7777
"karma-chrome-launcher": "^2.2.0",
78-
"karma-coverage-istanbul-reporter": "^1.3.0",
79-
"karma-jasmine": "^1.0.2",
78+
"karma-coverage-istanbul-reporter": "^1.4.1",
79+
"karma-jasmine": "^1.1.1",
8080
"karma-sourcemap-loader": "^0.3.7",
81-
"karma-typescript-preprocessor": "^0.2.1",
82-
"minimatch": "^3.0.2",
83-
"node-sass": "4.5.3",
84-
"nps": "^5.7.1",
85-
"nps-utils": "1.2.0",
86-
"opn": "^5.1.0",
87-
"protractor": "^5.1.2",
88-
"requirejs": "^2.3.2",
89-
"sass-loader": "^6.0.6",
90-
"style-loader": "0.18.2",
91-
"stylus": "0.54.5",
92-
"systemjs": "0.20.13",
93-
"systemjs-plugin-text": "0.0.9",
81+
"karma-typescript-preprocessor": "^0.3.1",
82+
"minimatch": "^3.0.4",
83+
"node-sass": "^4.7.2",
84+
"nps": "^5.8.1",
85+
"nps-utils": "^1.5.0",
86+
"opn": "^5.2.0",
87+
"protractor": "^5.3.0",
88+
"requirejs": "^2.3.5",
89+
"sass-loader": "^6.0.7",
90+
"style-loader": "^0.20.2",
91+
"stylus": "^0.54.5",
92+
"systemjs": "^0.21.0",
93+
"systemjs-plugin-text": "0.0.11",
9494
"text": "github:requirejs/text#latest",
95-
"through2": "^2.0.1",
96-
"ts-jest": "20.0.6",
97-
"ts-node": "^3.2.0",
98-
"tslint": "^3.11.0",
99-
"typescript": ">=1.9.0-dev || ^2.0.0",
100-
"uglify-js": "^3.0.19",
101-
"url-loader": "0.5.8",
102-
"vinyl-fs": "^2.4.3",
103-
"wait-on": "2.0.2",
104-
"webpack": "3.5.5",
105-
"webpack-dev-server": "2.7.1",
106-
"webpack-hot-middleware": "^2.18.2"
107-
}
95+
"through2": "^2.0.3",
96+
"ts-jest": "22.4.1",
97+
"ts-node": "^5.0.1",
98+
"ts-loader": "^4.0.1",
99+
"tslint": "^5.9.1",
100+
"typescript": "^2.7.2",
101+
"uglify-js": "^3.3.12",
102+
"url-loader": "^1.0.1",
103+
"vinyl-fs": "^3.0.2",
104+
"wait-on": "^2.1.0",
105+
"webpack": "^4.0.1",
106+
"webpack-cli": "^2.0.9",
107+
"webpack-dev-server": "^3.1.0",
108+
"webpack-hot-middleware": "^2.21.1"
109+
}

lib/resources/content/tsconfig.template.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"experimentalDecorators": true,
2323
"moduleResolution": "node",
2424
"sourceRoot": "src",
25+
"sourceMap": true,
2526
"allowJs": true,
2627
"baseUrl": "src",
2728
"skipLibCheck": true,

lib/resources/content/webpack.config.template.js

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@ const CopyWebpackPlugin = require('copy-webpack-plugin');
44
const ExtractTextPlugin = require('extract-text-webpack-plugin');
55
const project = require('./aurelia_project/aurelia.json');
66
const { AureliaPlugin, ModuleDependenciesPlugin } = require('aurelia-webpack-plugin');
7-
const { optimize: { CommonsChunkPlugin, UglifyJsPlugin }, ProvidePlugin } = require('webpack');
8-
// @if transpiler.id='typescript'
9-
const { TsConfigPathsPlugin, CheckerPlugin } = require('awesome-typescript-loader');
10-
// @endif
7+
const { ProvidePlugin } = require('webpack');
118

129
// config helpers:
1310
const ensureArray = (config) => config && (Array.isArray(config) ? config : [config]) || [];
@@ -45,13 +42,15 @@ module.exports = ({production, server, extractCss, coverage} = {}) => ({
4542
app: ['aurelia-bootstrapper'],
4643
vendor: ['bluebird'],
4744
},
45+
mode: production ? 'production' : 'development',
4846
output: {
4947
path: outDir,
5048
publicPath: baseUrl,
5149
filename: production ? '[name].[chunkhash].bundle.js' : '[name].[hash].bundle.js',
5250
sourceMapFilename: production ? '[name].[chunkhash].bundle.map' : '[name].[hash].bundle.map',
5351
chunkFilename: production ? '[name].[chunkhash].chunk.js' : '[name].[hash].chunk.js'
5452
},
53+
performance: { hints: false },
5554
devServer: {
5655
contentBase: outDir,
5756
// serve index.html for all 404 (required for push-state)
@@ -120,7 +119,7 @@ module.exports = ({production, server, extractCss, coverage} = {}) => ({
120119
},
121120
// @endif
122121
// @if transpiler.id='typescript'
123-
{ test: /\.ts$/i, loader: 'awesome-typescript-loader', exclude: nodeModulesDir },
122+
{ test: /\.tsx?$/, loader: "ts-loader" },
124123
// @endif
125124
{ test: /\.json$/i, loader: 'json-loader' },
126125
// use Bluebird as the global Promise implementation:
@@ -148,10 +147,6 @@ module.exports = ({production, server, extractCss, coverage} = {}) => ({
148147
new ModuleDependenciesPlugin({
149148
'aurelia-testing': [ './compile-spy', './view-spy' ]
150149
}),
151-
// @if transpiler.id='typescript'
152-
new TsConfigPathsPlugin(),
153-
new CheckerPlugin(),
154-
// @endif
155150
new HtmlWebpackPlugin({
156151
template: 'index.ejs',
157152
// @if markupProcessor.id='minimum'
@@ -183,14 +178,8 @@ module.exports = ({production, server, extractCss, coverage} = {}) => ({
183178
filename: production ? '[contenthash].css' : '[id].css',
184179
allChunks: true
185180
})),
186-
...when(production, new CommonsChunkPlugin({
187-
name: ['common']
188-
})),
189181
...when(production, new CopyWebpackPlugin([
190182
{ from: 'static/favicon.ico', to: 'favicon.ico' }
191-
])),
192-
...when(production, new UglifyJsPlugin({
193-
sourceMap: true
194-
}))
183+
]))
195184
]
196185
});

lib/resources/test/webpack/babel/karma-bundle.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function loadTestModules() {
2323
// recursive:
2424
true,
2525
// tests in /src folder regex:
26-
/\.spec\.[tj]s$/igm
26+
/\.spec\.[tj]s$/im
2727
);
2828

2929
const testContext = require.context(
@@ -32,7 +32,7 @@ function loadTestModules() {
3232
// recursive:
3333
true,
3434
// tests in ./unit folder regex:
35-
/\.spec\.[tj]s$/igm
35+
/\.spec\.[tj]s$/im
3636
);
3737

3838
return [srcContext, testContext];

lib/resources/test/webpack/typescript/karma-bundle.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function loadTestModules() {
2323
// recursive:
2424
true,
2525
// tests in /src folder regex:
26-
/\.spec\.[tj]s$/igm
26+
/\.spec\.[tj]s$/im
2727
);
2828

2929
const testContext = require.context(
@@ -32,7 +32,7 @@ function loadTestModules() {
3232
// recursive:
3333
true,
3434
// tests in ./unit folder regex:
35-
/\.spec\.[tj]s$/igm
35+
/\.spec\.[tj]s$/im
3636
);
3737

3838
return [srcContext, testContext];

0 commit comments

Comments
 (0)