mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 18:38:55 +00:00
Use node:fs for require json and toml
This commit is contained in:
@@ -150,7 +150,7 @@ export function internalRequire(this: ImportMetaObject, id) {
|
||||
|
||||
// TODO: remove this hardcoding
|
||||
if (last5 === ".json" && !id.endsWith?.("package.json")) {
|
||||
var fs = (globalThis[Symbol.for("_fs")] ||= Bun.fs());
|
||||
var fs = require("node:fs");
|
||||
var exports = JSON.parse(fs.readFileSync(id, "utf8"));
|
||||
$requireMap.$set(id, $createCommonJSModule(id, exports, true, undefined));
|
||||
return exports;
|
||||
@@ -160,7 +160,7 @@ export function internalRequire(this: ImportMetaObject, id) {
|
||||
$requireMap.$set(id, module);
|
||||
return module.exports;
|
||||
} else if (last5 === ".toml") {
|
||||
var fs = (globalThis[Symbol.for("_fs")] ||= Bun.fs());
|
||||
var fs = require("node:fs");
|
||||
var exports = Bun.TOML.parse(fs.readFileSync(id, "utf8"));
|
||||
$requireMap.$set(id, $createCommonJSModule(id, exports, true, undefined));
|
||||
return exports;
|
||||
|
||||
Reference in New Issue
Block a user