Skip to content

Commit 8176090

Browse files
committed
revert: fix: make sure manifest writes don't overlap (d6a20cf) (#73)
1 parent 02cbd20 commit 8176090

File tree

3 files changed

+27
-15
lines changed

3 files changed

+27
-15
lines changed

lib/plugin.js

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
var path = require('path');
22
var fse = require('fs-extra');
33
var _ = require('lodash');
4-
var mutexify = require('mutexify');
5-
6-
var lock = mutexify();
74

85
function ManifestPlugin(opts) {
96
this.opts = _.assign({
@@ -145,23 +142,23 @@ ManifestPlugin.prototype.apply = function(compiler) {
145142

146143
var json = JSON.stringify(manifest, null, 2);
147144

145+
compilation.assets[outputName] = {
146+
source: function() {
147+
return json;
148+
},
149+
size: function() {
150+
return json.length;
151+
}
152+
};
153+
148154
var outputFolder = compilation.options.output.path;
149155
var outputFile = path.resolve(compilation.options.output.path, this.opts.fileName);
150156

151157
if (this.opts.writeToFileEmit) {
152158
fse.outputFileSync(outputFile, json);
153159
}
154160

155-
compiler.outputFileSystem.mkdirp(path.dirname(outputFile), function(err) {
156-
if (err) return compileCallback(err);
157-
158-
lock(function(release) {
159-
compiler.outputFileSystem.writeFile(outputFile, json, function(err) {
160-
release();
161-
compileCallback(err);
162-
});
163-
});
164-
});
161+
compileCallback();
165162
}.bind(this));
166163
};
167164

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@
4040
"homepage": "https://github.com/danethurber/webpack-manifest-plugin",
4141
"dependencies": {
4242
"fs-extra": "^0.30.0",
43-
"lodash": ">=3.5 <5",
44-
"mutexify": "^1.1.0"
43+
"lodash": ">=3.5 <5"
4544
},
4645
"nyc": {
4746
"reporter": [

spec/plugin.spec.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,22 @@ describe('ManifestPlugin', function() {
407407
});
408408
});
409409

410+
it('make manifest available to other webpack plugins', function(done) {
411+
webpackCompile({
412+
context: __dirname,
413+
entry: './fixtures/file.js'
414+
}, {}, function(manifest, stats) {
415+
expect(manifest).toEqual({
416+
'main.js': 'main.js'
417+
});
418+
419+
expect(JSON.parse(stats.compilation.assets['manifest.json'].source())).toEqual({
420+
'main.js': 'main.js'
421+
});
422+
423+
done();
424+
});
425+
});
410426
});
411427

412428
describe('with ExtractTextPlugin', function() {

0 commit comments

Comments
 (0)