Skip to content

Commit

Permalink
fix($chore): move functions to bottom, add badge to readme
Browse files Browse the repository at this point in the history
  • Loading branch information
faceyspacey committed Jul 27, 2017
1 parent 56d2c92 commit d2d64ae
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 41 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
<img alt="Edit Redux-First Router Demo" src="http://cdn.reactlandia.com/chat-badge-reactlandia.png">
</a>


<a href="https://gitter.im/Reactlandia/Lobby" target="_blank">
<img alt="Edit Redux-First Router Demo" src="http://cdn.reactlandia.com/chat-badge-reactlandia.png">
</a>

# extract-css-chunks-webpack-plugin

<p align="center">
Expand Down
82 changes: 41 additions & 41 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,47 +17,6 @@ var pluginSchema = require('./schema/plugin-schema.json');
var NS = fs.realpathSync(__dirname);
var nextId = 0;

function isChunk( chunk, error ) {
if ( !( chunk instanceof Chunk ) ) {
throw new Error( typeof error === 'string' ? error : 'chunk is not an instance of Chunk' );
}

return true;
}

function forEachChunkModule( chunk, cb ) {
isChunk( chunk );

// webpack >= 3.x.x
if ( typeof chunk.forEachModule === 'function' ) {
chunk.forEachModule( cb );
}
else {
// webpack < 3.x.x
chunk.modules.forEach( cb );
}

// Nothing better to return...
return chunk;
}

function getChunkModulesArray( chunk ) {
isChunk( chunk );

var arr = [];

// webpack >= 3.x.x
if ( typeof chunk.mapModules === 'function' ) {
arr = chunk.mapModules();
}
else {
// webpack < 3.x.x
arr = chunk.modules.slice();
}

return arr;
}

function ExtractTextPluginCompilation() {
this.modulesByIdentifier = {};
}
Expand Down Expand Up @@ -395,3 +354,44 @@ function getPath(compilation, source, chunk) {
});
}
}

function isChunk(chunk, error) {
if (!(chunk instanceof Chunk)) {
throw new Error(typeof error === 'string' ? error : 'chunk is not an instance of Chunk');
}

return true;
}

function forEachChunkModule(chunk, cb) {
isChunk(chunk);

// webpack >= 3.x.x
if (typeof chunk.forEachModule === 'function') {
chunk.forEachModule(cb);
}
else {
// webpack < 3.x.x
chunk.modules.forEach(cb);
}

// Nothing better to return...
return chunk;
}

function getChunkModulesArray(chunk) {
isChunk(chunk);

var arr = [];

// webpack >= 3.x.x
if ( typeof chunk.mapModules === 'function' ) {
arr = chunk.mapModules();
}
else {
// webpack < 3.x.x
arr = chunk.modules.slice();
}

return arr;
}

0 comments on commit d2d64ae

Please sign in to comment.