-
Notifications
You must be signed in to change notification settings - Fork 1
Replace emit_globals with static global.mbt template #7
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
Conversation
- Create global.mbt in base.mbt folder with static global bindings - Remove emit_globals.mbt from emit folder - Remove emit_globals call from main.mbt - Update pkg.generated.mbti to reflect the removal Co-authored-by: bikallem <315907+bikallem@users.noreply.github.com>
|
@copilot run moon fmt && moon test && moon info |
Ran Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR refactors the code generation process by replacing runtime generation of global singleton bindings (document, window, navigator) with a static template file. Instead of dynamically generating globals.mbt based on available interfaces, the code now treats it as a base template that is copied alongside other foundational files like js_value.mbt and js_promise.mbt.
Key changes:
- Static template approach simplifies the build process and eliminates conditional logic
- Removes 142 lines of code generation logic and tests
- Global bindings are now always included regardless of which WebIDL specs are processed
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
webapi_gen/base.mbt/global.mbt |
New static template containing FFI bindings for document, window, and navigator globals |
webapi_gen/emit/emit_globals.mbt |
Removed - no longer needed as globals are now statically defined |
webapi_gen/main.mbt |
Removed emit_globals call and file writing logic; template is now auto-copied via existing copy_templates function |
webapi_gen/emit/pkg.generated.mbti |
Removed emit_globals function signature from package interface |
| @@ -0,0 +1,19 @@ | |||
| // MoonBit bindings for global objects | |||
Copilot
AI
Dec 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The static template will always emit bindings for Document, Window, and Navigator types, even if these interfaces are not present in the processed WebIDL. The previous dynamic implementation conditionally checked whether each interface existed in the flattened IDL before generating bindings. This could cause compilation errors if the core_specs configuration doesn't include the specs that define these interfaces (dom.idl, html.idl, etc.). Consider adding a note in the comment header warning that these global types must be available, or implement a conditional inclusion mechanism.
| // MoonBit bindings for global objects | |
| // MoonBit bindings for global objects | |
| // NOTE: This file assumes that the WebIDL build includes interfaces | |
| // `Document`, `Window`, and `Navigator` (typically from dom.idl/html.idl). | |
| // If these interfaces are omitted from the core_specs configuration, | |
| // the references below will fail to type-check because the types | |
| // will not be defined in the generated bindings. |
The
emit_globals.mbtgenerates static, unchanging code for global singletons (document, window, navigator). Move this to a static template file instead of runtime generation.Changes
webapi_gen/base.mbt/global.mbt— static template with FFI bindings for document, window, navigatorwebapi_gen/emit/emit_globals.mbt— no longer neededwebapi_gen/main.mbt— remove emit_globals call; template is auto-copied by existingcopy_templatesfunctionpkg.generated.mbti— remove emit_globals signatureResult
The global bindings are now treated like other base templates (js_value.mbt, js_promise.mbt, etc.) rather than dynamically generated.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
download.mooncakes.io/home/REDACTED/.moon/bin/moon moon check --target js(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.