Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: isolate root.C and root.JavaScriptCore #16384

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

fel1x-developer
Copy link
Contributor

@fel1x-developer fel1x-developer commented Jan 13, 2025

What does this PR do?

Currently,

const C = @import("root").C;

and

const C = bun.C;

are same. This is because src/bun.zig exposes C as a pub const. This should be avoided and only

const C = @import("root").C;

should be accepted.

  • Documentation or TypeScript types (it's okay to leave the rest blank in this case)
  • Code changes

How did you verify your code works?

@fel1x-developer fel1x-developer changed the title refactor: isolate root.C WIP: refactor: isolate root.C Jan 14, 2025
@fel1x-developer fel1x-developer changed the title WIP: refactor: isolate root.C refactor: isolate root.C Jan 14, 2025
@fel1x-developer fel1x-developer force-pushed the isolate-c branch 2 times, most recently from 110c19c to 878315e Compare January 14, 2025 02:49
@paperclover
Copy link
Member

i think all uses of @import("root").C should be moved to bun.C and not the other way around, since bun is the primary namespace in this codebase, not the root file's struct. if anything, the root file should be empty besides pub const bun = ...; and the stuff from main.zig.

@fel1x-developer fel1x-developer force-pushed the isolate-c branch 2 times, most recently from 5370581 to 7373c0b Compare January 14, 2025 22:33
@fel1x-developer fel1x-developer changed the title refactor: isolate root.C refactor: isolate root.C and root.JavaScriptCore Jan 14, 2025
@fel1x-developer
Copy link
Contributor Author

@paperclover Could you give a try for CI check?

@fel1x-developer
Copy link
Contributor Author

@paperclover , why do we need this?

const is_standalone = !@hasDecl(@import("root"), "JavaScriptCore");
const bun = if (!is_standalone) @import("root").bun else @compileError("cannot use 'bun' in standalone build of bun_shim_impl");

This is causing error since I move JSC to be under Bun namespace (bun.JSC)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants