extract-text-webpack-plugin
Advanced tools
Comparing version 0.4.0 to 0.5.0
@@ -8,3 +8,3 @@ /* | ||
function ExtractedModule(identifier, originalModule, source, sourceMap, addtitionalInformation) { | ||
function ExtractedModule(identifier, originalModule, source, sourceMap, addtitionalInformation, prevModules) { | ||
this._identifier = identifier; | ||
@@ -14,2 +14,3 @@ this._originalModule = originalModule; | ||
this._sourceMap = sourceMap; | ||
this._prevModules = prevModules; | ||
this.addtitionalInformation = addtitionalInformation; | ||
@@ -44,1 +45,16 @@ this.chunks = []; | ||
}; | ||
ExtractedModule.prototype.getOriginalModule = function() { | ||
return this._originalModule; | ||
}; | ||
ExtractedModule.prototype.getPrevModules = function() { | ||
return this._prevModules; | ||
} | ||
ExtractedModule.prototype.addPrevModules = function(prevModules) { | ||
prevModules.forEach(function(m) { | ||
if(this._prevModules.indexOf(m) < 0) | ||
this._prevModules.push(m); | ||
}, this); | ||
}; |
32
index.js
@@ -13,2 +13,3 @@ /* | ||
var Chunk = require("webpack/lib/Chunk"); | ||
var OrderUndefinedError = require("./OrderUndefinedError"); | ||
var loaderUtils = require("loader-utils"); | ||
@@ -201,2 +202,9 @@ | ||
extractedChunk.modules.sort(function(a, b) { | ||
var order = getOrder(a, b); | ||
if(isNaN(order)) { | ||
compilation.errors.push(new OrderUndefinedError(a.getOriginalModule())); | ||
compilation.errors.push(new OrderUndefinedError(b.getOriginalModule())); | ||
} | ||
if(order !== 0 && !isNaN(order)) | ||
return order; | ||
var ai = a.identifier(); | ||
@@ -251,6 +259,8 @@ var bi = b.identifier(); | ||
ExtractTextPluginCompilation.prototype.addModule = function(identifier, originalModule, source, additionalInformation, sourceMap) { | ||
ExtractTextPluginCompilation.prototype.addModule = function(identifier, originalModule, source, additionalInformation, sourceMap, prevModules) { | ||
if(!this.modulesByIdentifier[identifier]) | ||
return this.modulesByIdentifier[identifier] = new ExtractedModule(identifier, originalModule, source, sourceMap, additionalInformation); | ||
return this.modulesByIdentifier[identifier]; | ||
return this.modulesByIdentifier[identifier] = new ExtractedModule(identifier, originalModule, source, sourceMap, additionalInformation, prevModules); | ||
var m = this.modulesByIdentifier[identifier]; | ||
m.addPrevModules(prevModules); | ||
return m; | ||
}; | ||
@@ -263,9 +273,11 @@ | ||
var counterMap = {}; | ||
var prevModules = []; | ||
result.forEach(function(item) { | ||
var c = counterMap[item[0]]; | ||
var i = item.slice(); | ||
var module = this.addModule.call(this, item[0] + (c || ""), originalModule, item[1], item[2], item[3]); | ||
var module = this.addModule.call(this, item[0] + (c || ""), originalModule, item[1], item[2], item[3], prevModules.slice()); | ||
extractedChunk.addModule(module); | ||
module.addChunk(extractedChunk); | ||
counterMap[item[0]] = (c || 0) + 1; | ||
prevModules.push(module); | ||
}, this); | ||
@@ -281,1 +293,13 @@ }; | ||
}; | ||
function getOrder(a, b) { | ||
var bBeforeA = a.getPrevModules().indexOf(b) >= 0; | ||
var aBeforeB = b.getPrevModules().indexOf(a) >= 0; | ||
if(aBeforeB && bBeforeA) | ||
return NaN; | ||
if(bBeforeA) | ||
return 1; | ||
if(aBeforeB) | ||
return -1; | ||
return 0; | ||
} |
{ | ||
"name": "extract-text-webpack-plugin", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"author": "Tobias Koppers @sokra", | ||
@@ -5,0 +5,0 @@ "description": "Extract text from bundle into a file.", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19651
7
458