Skip to content

Commit 074a26e

Browse files
committed
Performance webpack#106
1 parent d56dce7 commit 074a26e

4 files changed

Lines changed: 18 additions & 2 deletions

File tree

‎lib/ContextModule.js‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55
var Module = require("./Module");
66
var OriginalSource = require("webpack-core/lib/OriginalSource");
7+
var RawSource = require("webpack-core/lib/RawSource");
78

89
function ContextModule(resolveDependencies, context, recursive, regExp, addon) {
910
Module.call(this);
@@ -97,7 +98,11 @@ ContextModule.prototype.source = function(dependencyTemplates, outputOptions, re
9798
"webpackContext.resolve = webpackContextResolve;\n",
9899
"module.exports = webpackContext;\n",
99100
];
100-
return new OriginalSource(str.join(""), this.identifier());
101+
if(this.useSourceMap) {
102+
return new OriginalSource(str.join(""), this.identifier());
103+
} else {
104+
return new RawSource(str.join(""));
105+
}
101106
};
102107

103108
ContextModule.prototype.size = function() {

‎lib/NormalModule.js‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ NormalModule.prototype.build = function build(options, compilation, resolver, fs
6262
this.built = true;
6363
return this.doBuild(options, compilation, resolver, fs, function(err) {
6464
if(err) return callback(err);
65+
if(options.module && options.module.noParse) {
66+
if(Array.isArray(options.module.noParse)) {
67+
if(options.module.noParse.some(function(regExp) {
68+
return regExp.test(this.request);
69+
}, this)) return callback();
70+
} else if(options.module.noParse.test(this.request))
71+
return callback();
72+
}
6573
try {
6674
this.parser.parse(this._source.source(), {
6775
current: this,

‎lib/NormalModuleFactory.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ NormalModuleFactory.prototype.create = function(context, dependency, callback) {
9595
result.parser
9696
)
9797
);
98-
}.bind(this));
98+
});
9999
}
100100
}.bind(this));
101101
}.bind(this));

‎lib/SourceMapDevToolPlugin.js‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ SourceMapDevToolPlugin.prototype.apply = function(compiler) {
1919
var sourceMappingURLComment = this.sourceMappingURLComment;
2020
var requestShortener = new RequestShortener(this.context);
2121
compiler.plugin("compilation", function(compilation) {
22+
compilation.plugin("build-module", function(module) {
23+
module.useSourceMap = true;
24+
});
2225
compilation.plugin("after-optimize-chunk-assets", function(chunks) {
2326
chunks.forEach(function(chunk) {
2427
chunk.files.slice().forEach(function(file) {

0 commit comments

Comments
 (0)