Skip to content

Commit 7f303e5

Browse files
committed
Use Buffer.from instead of new Buffer
1 parent dc90e70 commit 7f303e5

5 files changed

+7
-7
lines changed

lib/Compiler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ class Compiler extends Tapable {
288288
let content = source.source();
289289

290290
if(!Buffer.isBuffer(content)) {
291-
content = new Buffer(content, "utf8"); // eslint-disable-line
291+
content = Buffer.from(content, "utf8");
292292
}
293293

294294
source.existsAt = targetPath;

lib/EvalSourceMapDevToolModuleTemplatePlugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class EvalSourceMapDevToolModuleTemplatePlugin {
6565
sourceMap.sourceRoot = options.sourceRoot || "";
6666
sourceMap.file = `${module.id}.js`;
6767

68-
const footer = self.sourceMapComment.replace(/\[url\]/g, `data:application/json;charset=utf-8;base64,${new Buffer(JSON.stringify(sourceMap), "utf8").toString("base64")}`) + //eslint-disable-line
68+
const footer = self.sourceMapComment.replace(/\[url\]/g, `data:application/json;charset=utf-8;base64,${Buffer.from(JSON.stringify(sourceMap), "utf8").toString("base64")}`) +
6969
`\n//# sourceURL=webpack-internal:///${module.id}\n`; // workaround for chrome bug
7070
source.__EvalSourceMapDevToolData = new RawSource(`eval(${JSON.stringify(content + footer)});`);
7171
return source.__EvalSourceMapDevToolData;

lib/NormalModule.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const asString = (buf) => {
3333

3434
const asBuffer = str => {
3535
if(!Buffer.isBuffer(str)) {
36-
return new Buffer(str, "utf-8"); // eslint-disable-line
36+
return Buffer.from(str, "utf-8");
3737
}
3838
return str;
3939
};

lib/SourceMapDevToolPlugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ class SourceMapDevToolPlugin {
224224
} else {
225225
asset.__SourceMapDevToolData[file] = compilation.assets[file] = new ConcatSource(new RawSource(source), currentSourceMappingURLComment
226226
.replace(/\[map\]/g, () => sourceMapString)
227-
.replace(/\[url\]/g, () => `data:application/json;charset=utf-8;base64,${new Buffer(sourceMapString, "utf-8").toString("base64")}`) // eslint-disable-line
227+
.replace(/\[url\]/g, () => `data:application/json;charset=utf-8;base64,${Buffer.from(sourceMapString, "utf-8").toString("base64")}`)
228228
);
229229
}
230230
});

lib/optimize/ConcatenatedModule.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ class ConcatenatedModule extends Module {
629629
exportName = true;
630630
} else {
631631
const exportData = match[2];
632-
exportName = new Buffer(exportData, "hex").toString("utf-8"); // eslint-disable-line node/no-deprecated-api
632+
exportName = Buffer.from(exportData, "hex").toString("utf-8");
633633
}
634634
const asCall = !!match[3];
635635
const strictHarmonyModule = !!match[4];
@@ -768,7 +768,7 @@ class HarmonyImportSpecifierDependencyConcatenatedTemplate {
768768
} else if(dep.namespaceObjectAsContext) {
769769
content = `__WEBPACK_MODULE_REFERENCE__${info.index}_ns${strictFlag}__[${JSON.stringify(dep.id)}]`;
770770
} else {
771-
const exportData = new Buffer(dep.id, "utf-8").toString("hex"); // eslint-disable-line node/no-deprecated-api
771+
const exportData = Buffer.from(dep.id, "utf-8").toString("hex");
772772
content = `__WEBPACK_MODULE_REFERENCE__${info.index}_${exportData}${callFlag}${strictFlag}__`;
773773
}
774774
if(dep.shorthand) {
@@ -931,7 +931,7 @@ class HarmonyExportImportedSpecifierDependencyConcatenatedTemplate {
931931
if(def.id === true) {
932932
finalName = `__WEBPACK_MODULE_REFERENCE__${info.index}_ns${strictFlag}__`;
933933
} else {
934-
const exportData = new Buffer(def.id, "utf-8").toString("hex"); // eslint-disable-line node/no-deprecated-api
934+
const exportData = Buffer.from(def.id, "utf-8").toString("hex");
935935
finalName = `__WEBPACK_MODULE_REFERENCE__${info.index}_${exportData}${strictFlag}__`;
936936
}
937937
const exportsName = this.rootModule.exportsArgument;

0 commit comments

Comments
 (0)