Skip to content

Commit

Permalink
Merge pull request #5137 from mzgoddard/concatenated-file-dependencies
Browse files Browse the repository at this point in the history
Include module file and context dependencies in ConcatenatedModule
  • Loading branch information
sokra committed Jul 1, 2017
2 parents 0905974 + 3d6fe2c commit a6e4cdd
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/optimize/ConcatenatedModule.js
Expand Up @@ -154,6 +154,8 @@ class ConcatenatedModule extends Module {
this.dependencies = [];
this.dependenciesWarnings = [];
this.dependenciesErrors = [];
this.fileDependencies = [];
this.contextDependencies = [];
this.warnings = [];
this.errors = [];
this.assets = {};
Expand All @@ -165,6 +167,10 @@ class ConcatenatedModule extends Module {
m.dependenciesWarnings.forEach(depWarning => this.dependenciesWarnings.push(depWarning));
// populate dep errors
m.dependenciesErrors.forEach(depError => this.dependenciesErrors.push(depError));
// populate file dependencies
if(m.fileDependencies) m.fileDependencies.forEach(file => this.fileDependencies.push(file));
// populate context dependencies
if(m.contextDependencies) m.contextDependencies.forEach(context => this.contextDependencies.push(context));
// populate warnings
m.warnings.forEach(warning => this.warnings.push(warning));
// populate errors
Expand Down
@@ -0,0 +1 @@
export default 'This ';
@@ -0,0 +1,5 @@
import a from './a';
import b from './b';
import c from './c';

export default a + b + c;
@@ -0,0 +1 @@
export default 'is only';
@@ -0,0 +1 @@
export default ' a test';
@@ -0,0 +1 @@
module.exports = require('../bar/abc').default + '.0';
13 changes: 13 additions & 0 deletions test/watchCases/plugins/module-concatenation-plugin/0/index.js
@@ -0,0 +1,13 @@
it("should watch for changes", function() {
if(WATCH_STEP === '0') {
require("./foo/" + WATCH_STEP).should.be.eql('This is only a test.' + WATCH_STEP);
}
else if(WATCH_STEP === '1') {
require("./foo/" + WATCH_STEP).should.be.eql('This should be a test.' + WATCH_STEP);
}
else if(WATCH_STEP === '2') {
require("./foo/" + WATCH_STEP).should.be.eql('This should be working.' + WATCH_STEP);
}

STATS_JSON.modules.length.should.equal(4 + Number(WATCH_STEP));
});
@@ -0,0 +1 @@
export default 'should be';
@@ -0,0 +1 @@
module.exports = require('../bar/abc').default + '.1';
@@ -0,0 +1 @@
export default ' working';
@@ -0,0 +1 @@
module.exports = require('../bar/abc').default + '.2';
@@ -0,0 +1,6 @@
var webpack = require("../../../../");
module.exports = {
plugins: [
new webpack.optimize.ModuleConcatenationPlugin()
]
};

0 comments on commit a6e4cdd

Please sign in to comment.