From 696b8d4b3c26fc2f2995a90cc93e4e4cc86f9efc Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Thu, 9 Feb 2017 10:20:28 -0500 Subject: [PATCH] Fix Buffer conversion logic in writeFile. --- tools/isobuild/bundler.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tools/isobuild/bundler.js b/tools/isobuild/bundler.js index 405e6b8c4c..722d5073a6 100644 --- a/tools/isobuild/bundler.js +++ b/tools/isobuild/bundler.js @@ -2419,10 +2419,11 @@ var writeFile = Profile("bundler writeFile", function (file, builder, options) { const hash = file.hash(); if (options && options.sourceMapUrl) { - data = new Buffer( - addSourceMappingURL(data, options.sourceMapUrl), - "utf8" - ); + data = addSourceMappingURL(data, options.sourceMapUrl); + } + + if (! Buffer.isBuffer(data)) { + data = new Buffer(data, "utf8"); } builder.write(file.targetPath, { data, hash });