Skip to content

Commit d2d64ae

Browse files
committed
fix($chore): move functions to bottom, add badge to readme
1 parent 56d2c92 commit d2d64ae

File tree

2 files changed

+46
-41
lines changed

2 files changed

+46
-41
lines changed

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
<img alt="Edit Redux-First Router Demo" src="http://cdn.reactlandia.com/chat-badge-reactlandia.png">
33
</a>
44

5+
6+
<a href="https://gitter.im/Reactlandia/Lobby" target="_blank">
7+
<img alt="Edit Redux-First Router Demo" src="http://cdn.reactlandia.com/chat-badge-reactlandia.png">
8+
</a>
9+
510
# extract-css-chunks-webpack-plugin
611

712
<p align="center">

index.js

+41-41
Original file line numberDiff line numberDiff line change
@@ -17,47 +17,6 @@ var pluginSchema = require('./schema/plugin-schema.json');
1717
var NS = fs.realpathSync(__dirname);
1818
var nextId = 0;
1919

20-
function isChunk( chunk, error ) {
21-
if ( !( chunk instanceof Chunk ) ) {
22-
throw new Error( typeof error === 'string' ? error : 'chunk is not an instance of Chunk' );
23-
}
24-
25-
return true;
26-
}
27-
28-
function forEachChunkModule( chunk, cb ) {
29-
isChunk( chunk );
30-
31-
// webpack >= 3.x.x
32-
if ( typeof chunk.forEachModule === 'function' ) {
33-
chunk.forEachModule( cb );
34-
}
35-
else {
36-
// webpack < 3.x.x
37-
chunk.modules.forEach( cb );
38-
}
39-
40-
// Nothing better to return...
41-
return chunk;
42-
}
43-
44-
function getChunkModulesArray( chunk ) {
45-
isChunk( chunk );
46-
47-
var arr = [];
48-
49-
// webpack >= 3.x.x
50-
if ( typeof chunk.mapModules === 'function' ) {
51-
arr = chunk.mapModules();
52-
}
53-
else {
54-
// webpack < 3.x.x
55-
arr = chunk.modules.slice();
56-
}
57-
58-
return arr;
59-
}
60-
6120
function ExtractTextPluginCompilation() {
6221
this.modulesByIdentifier = {};
6322
}
@@ -395,3 +354,44 @@ function getPath(compilation, source, chunk) {
395354
});
396355
}
397356
}
357+
358+
function isChunk(chunk, error) {
359+
if (!(chunk instanceof Chunk)) {
360+
throw new Error(typeof error === 'string' ? error : 'chunk is not an instance of Chunk');
361+
}
362+
363+
return true;
364+
}
365+
366+
function forEachChunkModule(chunk, cb) {
367+
isChunk(chunk);
368+
369+
// webpack >= 3.x.x
370+
if (typeof chunk.forEachModule === 'function') {
371+
chunk.forEachModule(cb);
372+
}
373+
else {
374+
// webpack < 3.x.x
375+
chunk.modules.forEach(cb);
376+
}
377+
378+
// Nothing better to return...
379+
return chunk;
380+
}
381+
382+
function getChunkModulesArray(chunk) {
383+
isChunk(chunk);
384+
385+
var arr = [];
386+
387+
// webpack >= 3.x.x
388+
if ( typeof chunk.mapModules === 'function' ) {
389+
arr = chunk.mapModules();
390+
}
391+
else {
392+
// webpack < 3.x.x
393+
arr = chunk.modules.slice();
394+
}
395+
396+
return arr;
397+
}

0 commit comments

Comments
 (0)