aboutsummaryrefslogtreecommitdiff
path: root/src/runtime.js
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-09-11 01:48:23 -0700
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-09-11 01:48:23 -0700
commit125d88bd6540be5b751404165c69d1c6fdaae322 (patch)
tree9c1bef7429ef83aa39c595f26b5c14ca203468e0 /src/runtime.js
parent6f2554b13ab2c89935bb063c8ab919bfa168ff96 (diff)
downloadbun-125d88bd6540be5b751404165c69d1c6fdaae322.tar.gz
bun-125d88bd6540be5b751404165c69d1c6fdaae322.tar.zst
bun-125d88bd6540be5b751404165c69d1c6fdaae322.zip
bun:error.js into separate module, ensure we don't include fast refresh in Bun.js, log build errors to browser console, don't warn for node_modules,
Diffstat (limited to 'src/runtime.js')
-rw-r--r--src/runtime.js113
1 files changed, 54 insertions, 59 deletions
diff --git a/src/runtime.js b/src/runtime.js
index 98cea8b8a..52974144b 100644
--- a/src/runtime.js
+++ b/src/runtime.js
@@ -42,64 +42,61 @@ export var __commonJS = (cb, name) => {
var mod = {};
var has_run = false;
- return {
- [`require(${name})`]() {
- if (has_run) {
- return mod.exports;
- }
- has_run = true;
- __name(cb);
-
- mod = { exports: {} };
-
- cb(mod, mod.exports);
-
- const kind = typeof mod.exports;
-
- // If it's a default-only export, don't crash if they call .default on the module
- if (
- kind === "object" &&
- "default" in mod.exports &&
- !mod.exports[tagSymbol] &&
- Object.keys(mod.exports).length === 1
- ) {
- mod.exports = mod.exports.default;
- Object.defineProperty(mod.exports, "default", {
- get() {
- return mod.exports;
- },
- enumerable: true,
- configurable: true,
- });
- // If it's a namespace export without .default, pretend .default is the same as mod.exports
- } else if (
- (kind === "function" || kind === "object") &&
- !("default" in mod.exports)
- ) {
- var defaultValue = mod.exports;
- Object.defineProperty(mod.exports, "default", {
- get() {
- return defaultValue;
- },
- set(value) {
- defaultValue = value;
- },
- enumerable: true,
- configurable: true,
- });
- }
+ return function require() {
+ if (has_run) {
+ return mod.exports;
+ }
+ has_run = true;
+
+ mod = { exports: {} };
+
+ cb(mod, mod.exports);
+
+ const kind = typeof mod.exports;
+
+ // If it's a default-only export, don't crash if they call .default on the module
+ if (
+ kind === "object" &&
+ "default" in mod.exports &&
+ !mod.exports[tagSymbol] &&
+ Object.keys(mod.exports).length === 1
+ ) {
+ mod.exports = mod.exports.default;
+ Object.defineProperty(mod.exports, "default", {
+ get() {
+ return mod.exports;
+ },
+ enumerable: true,
+ configurable: true,
+ });
+ // If it's a namespace export without .default, pretend .default is the same as mod.exports
+ } else if (
+ (kind === "function" || kind === "object") &&
+ !("default" in mod.exports)
+ ) {
+ var defaultValue = mod.exports;
+ Object.defineProperty(mod.exports, "default", {
+ get() {
+ return defaultValue;
+ },
+ set(value) {
+ defaultValue = value;
+ },
+ enumerable: true,
+ configurable: true,
+ });
+ }
- if (kind === "object" && !mod.exports[tagSymbol]) {
- Object.defineProperty(mod.exports, tagSymbol, {
- value: true,
- enumerable: false,
- configurable: false,
- });
- }
+ if (kind === "object" && !mod.exports[tagSymbol]) {
+ Object.defineProperty(mod.exports, tagSymbol, {
+ value: true,
+ enumerable: false,
+ configurable: false,
+ });
+ }
- return mod.exports;
- },
- }[`require(${name})`];
+ return mod.exports;
+ };
};
export var __cJS2eSM = (cb, name) => {
@@ -168,9 +165,7 @@ if (
new Map();
}
-export var $$m = (package_json_name, module_path, cb) => {
- return __commonJS(cb, `${package_json_name}/${module_path}`);
-};
+export var $$m = __commonJS;
export var __name = (target, name) => {
Object.defineProperty(target, "name", {