diff options
Diffstat (limited to '')
-rw-r--r-- | src/runtime.js | 26 | ||||
-rw-r--r-- | src/runtime.version | 2 | ||||
-rw-r--r-- | src/runtime.zig | 20 | ||||
-rw-r--r-- | src/runtime/hmr.ts | 2 |
4 files changed, 22 insertions, 28 deletions
diff --git a/src/runtime.js b/src/runtime.js index bcfd4c3fb..98cea8b8a 100644 --- a/src/runtime.js +++ b/src/runtime.js @@ -37,6 +37,7 @@ export var __toModule = (module) => { ); }; +var tagSymbol = Symbol("CommonJSTransformed"); export var __commonJS = (cb, name) => { var mod = {}; var has_run = false; @@ -59,21 +60,8 @@ export var __commonJS = (cb, name) => { if ( kind === "object" && "default" in mod.exports && - Object.keys(mod.exports).len === 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 === "object" && - "default" in mod.exports && - Object.keys(mod.exports).len === 1 + !mod.exports[tagSymbol] && + Object.keys(mod.exports).length === 1 ) { mod.exports = mod.exports.default; Object.defineProperty(mod.exports, "default", { @@ -101,6 +89,14 @@ export var __commonJS = (cb, name) => { }); } + if (kind === "object" && !mod.exports[tagSymbol]) { + Object.defineProperty(mod.exports, tagSymbol, { + value: true, + enumerable: false, + configurable: false, + }); + } + return mod.exports; }, }[`require(${name})`]; diff --git a/src/runtime.version b/src/runtime.version index b309f488e..d4f951e04 100644 --- a/src/runtime.version +++ b/src/runtime.version @@ -1 +1 @@ -a36793f60275e5e9
\ No newline at end of file +c525e78958fc519b
\ No newline at end of file diff --git a/src/runtime.zig b/src/runtime.zig index 32c5f752e..7af295957 100644 --- a/src/runtime.zig +++ b/src/runtime.zig @@ -8,25 +8,23 @@ const Schema = @import("./api/schema.zig"); const Api = Schema.Api; -const ErrorCSSPath = "../examples/hello-next/bun-framework-next/bun-error.css"; +const ErrorCSSPath = "packages/bun-framework-next/bun-error.css"; pub const ErrorCSS = struct { pub const ProdSourceContent = @embedFile(ErrorCSSPath); pub fn sourceContent() string { if (comptime isDebug) { - var dirpath = std.fs.path.dirname(@src().file).?; var env = std.process.getEnvMap(default_allocator) catch unreachable; - - const dir = std.mem.replaceOwned( - u8, - default_allocator, - dirpath, - "jarred", - env.get("USER").?, + var out_buffer: [std.fs.MAX_PATH_BYTES]u8 = undefined; + var dirname = std.fs.selfExeDirPath(&out_buffer) catch unreachable; + var paths = [_]string{ dirname, "../../../", ErrorCSSPath }; + const file = std.fs.cwd().openFile( + resolve_path.joinAbsString(dirname, std.mem.span(&paths), .auto), + .{ + .read = true, + }, ) catch unreachable; - var runtime_path = std.fs.path.join(default_allocator, &[_]string{ dir, ErrorCSSPath }) catch unreachable; - const file = std.fs.openFileAbsolute(runtime_path, .{}) catch unreachable; defer file.close(); return file.readToEndAlloc(default_allocator, (file.stat() catch unreachable).size) catch unreachable; } else { diff --git a/src/runtime/hmr.ts b/src/runtime/hmr.ts index dc72f469d..5c91683a2 100644 --- a/src/runtime/hmr.ts +++ b/src/runtime/hmr.ts @@ -611,7 +611,6 @@ if (typeof window !== "undefined") { this.client.verbose = verbose; this.client.start(); globalThis["__BUN_HMR"] = this.client; - globalThis["__BUN"] = this; } handleBuildFailure(buffer: ByteBuffer, timestamp: number) { @@ -1341,6 +1340,7 @@ if (typeof window !== "undefined") { window.addEventListener("error", HMRClient.onError, { passive: true }); } + globalThis["__BUN"] = HMRClient; } export { __HMRModule, __FastRefreshModule, __HMRClient }; |