diff options
author | 2022-03-19 00:46:24 -0700 | |
---|---|---|
committer | 2022-03-19 00:46:24 -0700 | |
commit | ce742f665aba7ae9cc5ea1838ea45b4342021a2e (patch) | |
tree | 743e84f23cf03c01ed8c63a540f7c21cbeb76827 /src | |
parent | 521ccba387e171835c0592f070112930fe2dd55e (diff) | |
download | bun-ce742f665aba7ae9cc5ea1838ea45b4342021a2e.tar.gz bun-ce742f665aba7ae9cc5ea1838ea45b4342021a2e.tar.zst bun-ce742f665aba7ae9cc5ea1838ea45b4342021a2e.zip |
generate separate interop code for bun
Diffstat (limited to 'src')
-rw-r--r-- | src/javascript/jsc/javascript.zig | 2 | ||||
-rw-r--r-- | src/runtime.footer.bun.js | 17 | ||||
-rw-r--r-- | src/runtime.js | 9 | ||||
-rw-r--r-- | src/runtime.version | 2 | ||||
-rw-r--r-- | src/runtime.zig | 5 | ||||
-rw-r--r-- | src/runtime/index-with-refresh.ts | 10 | ||||
-rw-r--r-- | src/runtime/index-without-hmr.ts | 2 | ||||
-rw-r--r-- | src/runtime/index.ts | 10 |
8 files changed, 42 insertions, 15 deletions
diff --git a/src/javascript/jsc/javascript.zig b/src/javascript/jsc/javascript.zig index eed427c57..7bd8e0244 100644 --- a/src/javascript/jsc/javascript.zig +++ b/src/javascript/jsc/javascript.zig @@ -866,7 +866,7 @@ pub const VirtualMachine = struct { } else if (jsc_vm.node_modules == null and strings.eqlComptime(_specifier, Runtime.Runtime.Imports.Name)) { return ResolvedSource{ .allocator = null, - .source_code = ZigString.init(Runtime.Runtime.sourceContent(false)), + .source_code = ZigString.init(Runtime.Runtime.sourceContentBun()), .specifier = ZigString.init(Runtime.Runtime.Imports.Name), .source_url = ZigString.init(Runtime.Runtime.Imports.Name), .hash = Runtime.Runtime.versionHash(), diff --git a/src/runtime.footer.bun.js b/src/runtime.footer.bun.js new file mode 100644 index 000000000..a7f7942bd --- /dev/null +++ b/src/runtime.footer.bun.js @@ -0,0 +1,17 @@ +export var $$m = BUN_RUNTIME.$$m; +export var __markAsModule = BUN_RUNTIME.__markAsModule; +export var $$lzy = BUN_RUNTIME.$$lzy; +export var __toModule = BUN_RUNTIME.__toModule; +export var __commonJS = BUN_RUNTIME.__commonJS; +export var __require = BUN_RUNTIME.__require; +export var __name = BUN_RUNTIME.__name; +export var __export = BUN_RUNTIME.__export; +export var __reExport = BUN_RUNTIME.__reExport; +export var __cJS2eSM = BUN_RUNTIME.__cJS2eSM; +export var regeneratorRuntime = BUN_RUNTIME.regeneratorRuntime; +export var __exportValue = BUN_RUNTIME.__exportValue; +export var __exportDefault = BUN_RUNTIME.__exportDefault; +export var $$bun_runtime_json_parse = JSON.parse; +export var __internalIsCommonJSNamespace = + BUN_RUNTIME.__internalIsCommonJSNamespace; +globalThis.require ||= BUN_RUNTIME.__require; diff --git a/src/runtime.js b/src/runtime.js index 38be10ea2..4ac76bff0 100644 --- a/src/runtime.js +++ b/src/runtime.js @@ -182,12 +182,3 @@ export var __reExport = (target, module, desc) => { }); return target; }; - -if (typeof globalThis.process === "undefined") { - globalThis.process = { - env: {}, - cwd() { - return "/bun-fake-dir/"; - }, - }; -} diff --git a/src/runtime.version b/src/runtime.version index f63c71b22..0bbf538da 100644 --- a/src/runtime.version +++ b/src/runtime.version @@ -1 +1 @@ -fcef2b20a766d0b8
\ No newline at end of file +139d399765744be7
\ No newline at end of file diff --git a/src/runtime.zig b/src/runtime.zig index 6ca9a0ac0..11862f544 100644 --- a/src/runtime.zig +++ b/src/runtime.zig @@ -164,6 +164,7 @@ pub const Fallback = struct { pub const Runtime = struct { pub const ProdSourceContent = @embedFile("./runtime.out.js"); + pub const ProdSourceContentBun = @embedFile("./runtime.bun.out.js"); pub const ProdSourceContentWithRefresh = @embedFile("./runtime.out.refresh.js"); pub inline fn sourceContentWithoutRefresh() string { @@ -192,6 +193,10 @@ pub const Runtime = struct { return sourceContentWithoutRefresh(); } + pub inline fn sourceContentBun() string { + return ProdSourceContentBun; + } + pub inline fn sourceContentWithRefresh() string { if (comptime Environment.isDebug) { var dirpath = std.fs.path.dirname(@src().file).?; diff --git a/src/runtime/index-with-refresh.ts b/src/runtime/index-with-refresh.ts index 1aceecc67..d0a0b12ec 100644 --- a/src/runtime/index-with-refresh.ts +++ b/src/runtime/index-with-refresh.ts @@ -1,10 +1,16 @@ import { __injectFastRefresh } from "./hmr"; export * from "./hmr"; export * from "./errors"; -export * from "../runtime.js"; -export { default as regeneratorRuntime } from "./regenerator"; +export * from "./index-without-hmr"; import * as __FastRefreshRuntime from "../react-refresh"; if (typeof window !== "undefined") { __injectFastRefresh(__FastRefreshRuntime); } export { __FastRefreshRuntime }; + +globalThis.process ||= { + env: {}, + cwd() { + return "/bun-fake-dir/"; + }, +}; diff --git a/src/runtime/index-without-hmr.ts b/src/runtime/index-without-hmr.ts new file mode 100644 index 000000000..858688130 --- /dev/null +++ b/src/runtime/index-without-hmr.ts @@ -0,0 +1,2 @@ +export * from "../runtime.js"; +export { default as regeneratorRuntime } from "./regenerator"; diff --git a/src/runtime/index.ts b/src/runtime/index.ts index a2d5382ca..3eebc8d5b 100644 --- a/src/runtime/index.ts +++ b/src/runtime/index.ts @@ -1,4 +1,10 @@ export * from "./hmr"; export * from "./errors"; -export * from "../runtime.js"; -export { default as regeneratorRuntime } from "./regenerator"; +export * from "./index-without-hmr"; + +globalThis.process ||= { + env: {}, + cwd() { + return "/bun-fake-dir/"; + }, +}; |