Skip to content

Commit 260e413

Browse files
authored
Merge pull request webpack#3986 from webpack/bugfix/revert_use_of_buffer_dot_from
fix(node): rollback changes of Buffer.from to new Buffer()
2 parents 0b47602 + 72226db commit 260e413

8 files changed

Lines changed: 121 additions & 89 deletions

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ matrix:
2222
node_js: "6"
2323
env: NO_WATCH_TESTS=1 JOB_PART=test
2424
- os: linux
25-
node_js: "4"
25+
node_js: "4.3"
2626
env: NO_WATCH_TESTS=1 JOB_PART=test
2727
- os: osx
2828
node_js: "7"

bin/webpack.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
Author Tobias Koppers @sokra
66
*/
77
var path = require("path");
8+
89
// Local version replace global one
910
try {
1011
var localWebpack = require.resolve(path.join(process.cwd(), "node_modules", "webpack", "bin", "webpack.js"));

lib/Compiler.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,11 @@ Compiler.prototype.emitAssets = function(compilation, callback) {
320320
return callback();
321321
}
322322
var content = source.source();
323-
if(!Buffer.isBuffer(content))
324-
content = Buffer.from(content, "utf8");
323+
324+
if(!Buffer.isBuffer(content)) {
325+
content = new Buffer(content, "utf8"); //eslint-disable-line
326+
}
327+
325328
source.existsAt = targetPath;
326329
source.emitted = true;
327330
this.outputFileSystem.writeFile(targetPath, content, callback);

lib/EvalSourceMapDevToolModuleTemplatePlugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ EvalSourceMapDevToolModuleTemplatePlugin.prototype.apply = function(moduleTempla
5858
}
5959
sourceMap.sourceRoot = options.sourceRoot || "";
6060
sourceMap.file = module.id + ".js";
61-
var footer = self.sourceMapComment.replace(/\[url\]/g, "data:application/json;charset=utf-8;base64," + Buffer.from(JSON.stringify(sourceMap)).toString("base64"));
61+
var footer = self.sourceMapComment.replace(/\[url\]/g, "data:application/json;charset=utf-8;base64," + new Buffer(JSON.stringify(sourceMap), "utf8").toString("base64")); //eslint-disable-line
6262
source.__EvalSourceMapDevToolData = new RawSource("eval(" + JSON.stringify(content + footer) + ");");
6363
return source.__EvalSourceMapDevToolData;
6464
});

lib/LibManifestPlugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ LibManifestPlugin.prototype.apply = function(compiler) {
4343
return obj;
4444
}.bind(this), {})
4545
};
46-
var content = Buffer.from(JSON.stringify(manifest, null, 2), "utf8");
46+
var content = new Buffer(JSON.stringify(manifest, null, 2), "utf8"); //eslint-disable-line
4747
compiler.outputFileSystem.mkdirp(path.dirname(targetPath), function(err) {
4848
if(err) return callback(err);
4949
compiler.outputFileSystem.writeFile(targetPath, content, callback);

lib/SourceMapDevToolPlugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ SourceMapDevToolPlugin.prototype.apply = function(compiler) {
155155
})
156156
.replace(/\[url\]/g, function() {
157157
return "data:application/json;charset=utf-8;base64," +
158-
Buffer.from(JSON.stringify(sourceMap)).toString("base64");
158+
new Buffer(JSON.stringify(sourceMap), "utf8").toString("base64"); //eslint-disable-line
159159
})
160160
);
161161
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
"worker-loader": "~0.7.0"
6666
},
6767
"engines": {
68-
"node": ">=4.7.0 <5.0.0 || >=5.10"
68+
"node": ">=4.3.0 <5.0.0 || >=5.10"
6969
},
7070
"repository": {
7171
"type": "git",

0 commit comments

Comments
 (0)