Skip to content

Commit

Permalink
Downgrade to Webpack@2.3.2 for Perf Reasons
Browse files Browse the repository at this point in the history
  • Loading branch information
samouri committed Jun 13, 2017
1 parent 0a72e8d commit 0f6447b
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
"uuid": "2.0.1",
"valid-url": "1.0.9",
"walk": "2.3.4",
"webpack": "2.6.1",
"webpack": "2.3.2",
"webpack-dev-middleware": "1.10.2",
"webpack-hot-middleware": "2.18.0",
"wpcom": "5.4.0",
Expand Down
27 changes: 27 additions & 0 deletions server/bundler/webpack-plugins/NamedChunksPlugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
class NamedChunksPlugin {
static defaultNameResolver( chunk ) {
return chunk.name || null;
}

constructor( nameResolver ) {
this.nameResolver = nameResolver || NamedChunksPlugin.defaultNameResolver;
}

apply( compiler ) {
compiler.plugin( 'compilation', compilation => {
compilation.plugin( 'before-chunk-ids', chunks => {
chunks.forEach( chunk => {
if ( chunk.id === null ) {
chunk.id = this.nameResolver( chunk );
}
} );
} );
} );
}
}

module.exports = NamedChunksPlugin;
25 changes: 25 additions & 0 deletions server/bundler/webpack-plugins/NamedModulesPlugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
class NamedModulesPlugin {
constructor( options ) {
this.options = options || {};
}

apply( compiler ) {
compiler.plugin( 'compilation', compilation => {
compilation.plugin( 'before-module-ids', modules => {
modules.forEach( module => {
if ( module.id === null && module.libIdent ) {
module.id = module.libIdent( {
context: this.options.context || compiler.options.context,
} );
}
} );
} );
} );
}
}

module.exports = NamedModulesPlugin;
6 changes: 4 additions & 2 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ const cacheIdentifier = require( './server/bundler/babel/babel-loader-cache-iden
const ChunkFileNamePlugin = require( './server/bundler/plugin' );
const CopyWebpackPlugin = require( 'copy-webpack-plugin' );
const HardSourceWebpackPlugin = require( 'hard-source-webpack-plugin' );
const NamedChunksPlugin = require( 'bundler/webpack-plugins/NamedChunksPlugin' );
const NamedModulesPlugin = require( 'bundler/webpack-plugins/NamedModulesPlugin' );

/**
* Internal variables
Expand Down Expand Up @@ -93,8 +95,8 @@ const webpackConfig = {
} ),
new webpack.IgnorePlugin( /^props$/ ),
new CopyWebpackPlugin( [ { from: 'node_modules/flag-icon-css/flags/4x3', to: 'images/flags' } ] ),
new webpack.NamedModulesPlugin(),
new webpack.NamedChunksPlugin(),
new NamedModulesPlugin(),
new NamedChunksPlugin(),
],
externals: [ 'electron' ]
};
Expand Down

0 comments on commit 0f6447b

Please sign in to comment.