Skip to content

Commit f95fde4

Browse files
chore(package): update to webpack 4.0.0, lazy load visualizer
1 parent 9b2fae4 commit f95fde4

File tree

5 files changed

+1472
-257
lines changed

5 files changed

+1472
-257
lines changed

app/bootstrap/ngmodule.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import * as angular from "angular";
77
import uiRouter from "@uirouter/angularjs";
88
import { StickyStatesPlugin } from '@uirouter/sticky-states';
99
import { DSRPlugin } from '@uirouter/dsr';
10-
import { visualizer } from "@uirouter/visualizer";
1110
import ocLazyLoad from "oclazyload";
1211

1312
import { MAIN_MODULE } from '../main/main.module';
@@ -34,5 +33,5 @@ ngmodule.config(['$uiRouterProvider', '$locationProvider', ($uiRouter, $location
3433
$uiRouter.plugin(StickyStatesPlugin);
3534
$uiRouter.plugin(DSRPlugin);
3635
// Show the UI-Router Visualizer
37-
visualizer($uiRouter);
36+
import("@uirouter/visualizer").then(module => $uiRouter.plugin(module.Visualizer));
3837
}]);

app/main/app.states.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export const contactsFutureState = {
9292
url: '/contacts',
9393
lazyLoad: function(transition) {
9494
const $ocLazyLoad = transition.injector().get('$ocLazyLoad');
95-
return System.import('../contacts/contacts.module').then(mod => $ocLazyLoad.load(mod.CONTACTS_MODULE))
95+
return import('../contacts/contacts.module').then(mod => $ocLazyLoad.load(mod.CONTACTS_MODULE))
9696
}
9797
};
9898

@@ -103,7 +103,7 @@ export const prefsFutureState = {
103103
url: '/prefs',
104104
lazyLoad: function(transition) {
105105
const $ocLazyLoad = transition.injector().get('$ocLazyLoad');
106-
return System.import('../prefs/prefs.module').then(mod => $ocLazyLoad.load(mod.PREFS_MODULE))
106+
return import('../prefs/prefs.module').then(mod => $ocLazyLoad.load(mod.PREFS_MODULE))
107107
}
108108
};
109109

@@ -114,7 +114,7 @@ export const mymessagesFutureState = {
114114
url: '/mymessages',
115115
lazyLoad: function(transition) {
116116
const $ocLazyLoad = transition.injector().get('$ocLazyLoad');
117-
return System.import('../mymessages/mymessages.module').then(mod => $ocLazyLoad.load(mod.MYMESSAGES_MODULE))
117+
return import('../mymessages/mymessages.module').then(mod => $ocLazyLoad.load(mod.MYMESSAGES_MODULE))
118118
}
119119
};
120120

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,16 @@
3333
"devDependencies": {
3434
"babel-core": "6.26.0",
3535
"babel-loader": "7.1.3",
36+
"babel-plugin-syntax-dynamic-import": "^6.18.0",
3637
"babel-preset-es2015": "6.24.1",
3738
"babel-preset-es2015-ie": "6.7.0",
3839
"browser-sync": "2.23.6",
3940
"cypress": "2.0.4",
4041
"npm-run-all": "4.1.2",
4142
"source-map-loader": "0.2.3",
4243
"wait-on": "2.1.0",
43-
"webpack": "3.11.0",
44+
"webpack": "4.0.0",
45+
"webpack-cli": "^2.0.9",
4446
"webpack-dev-server": "3.0.0"
4547
}
4648
}

webpack.config.js

+3-21
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,13 @@ var path = require('path');
44
var DEV_SERVER = process.argv[1].indexOf('webpack-dev-server') !== -1;
55
var DEV = DEV_SERVER || process.env.DEV;
66

7-
var plugins = [];
8-
if (!DEV) {
9-
// plugins.push(new webpack.optimize.UglifyJsPlugin({ sourceMap: true, }));
10-
}
11-
plugins.push(new webpack.optimize.CommonsChunkPlugin({ name: 'vendor' }));
12-
13-
147
module.exports = {
8+
mode: DEV ? 'development' : 'production',
159
entry: {
1610
"sampleapp": "./app/bootstrap/bootstrap.js",
17-
18-
"vendor": [
19-
'angular',
20-
'oclazyload',
21-
'@uirouter/core',
22-
'@uirouter/angularjs',
23-
'@uirouter/visualizer',
24-
'@uirouter/sticky-states',
25-
'@uirouter/dsr',
26-
],
2711
},
2812

29-
devtool: DEV ? 'source-map' :'source-map',
13+
devtool: DEV ? 'eval' :'source-map',
3014

3115
output: {
3216
path: path.join(__dirname, "_bundles"),
@@ -38,8 +22,6 @@ module.exports = {
3822
extensions: ['.js']
3923
},
4024

41-
plugins: plugins,
42-
4325
module: {
4426
rules: [
4527
{
@@ -51,7 +33,7 @@ module.exports = {
5133
{
5234
test: /\.js$/,
5335
exclude: /(node_modules)/,
54-
use: { loader: 'babel-loader', options: { presets: ['es2015-ie'] } },
36+
use: { loader: 'babel-loader' },
5537
}
5638
]
5739
},

0 commit comments

Comments
 (0)