Skip to content

refactor: replace runtime module options with wazero ModuleConfig#46

Open
stephenafamo wants to merge 1 commit into
fastschema:masterfrom
nineninesai:module-config
Open

refactor: replace runtime module options with wazero ModuleConfig#46
stephenafamo wants to merge 1 commit into
fastschema:masterfrom
nineninesai:module-config

Conversation

@stephenafamo
Copy link
Copy Markdown

This migrates runtime module-instantiation customization from several ad hoc qjs.Option fields to wazero.ModuleConfig.

Instead of exposing separate CWD, StartFunctionName, Stdout, and Stderr fields, qjs.Option now exposes a single ModuleConfig field for advanced module setup.

When ModuleConfig is nil, qjs now creates a default wazero module config that:

  • clears wazero's default start functions with WithStartFunctions()
  • mounts the current working directory at /
  • enables walltime, nanotime, and nanosleep
  • wires stdout/stderr to the host process

This preserves the previous behavior of qjs.New() after the refactor.
Without explicitly clearing start functions, bare wazero.NewModuleConfig() would run _start during instantiation and break normal runtime creation.

Replace the bespoke runtime module-instantiation fields on qjs.Option
with wazero.ModuleConfig and update tests/docs to match.
@stephenafamo
Copy link
Copy Markdown
Author

Implements #45

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.

1 participant