Skip to content

Add support for setting initialization-time script location - #278

Merged
tschneidereit merged 3 commits into
bytecodealliance:mainfrom
tschneidereit:wizening-location
Oct 15, 2025
Merged

tschneidereit merged 3 commits into
bytecodealliance:mainfrom
tschneidereit:wizening-location

Conversation

@tschneidereit

@tschneidereit tschneidereit commented Oct 15, 2025 •

Copy link
Copy Markdown
Member

This adds an --init-location CLI arg that can be used to set a location for use during wizening. This is meant to enable working around issues with libraries that use globalThis.location during top-level evaluation.

An example of a library that does this, and is used as a dependency in a number of projects, is cfworker.

The location will not be used for anything runtime-internal. Specifically, it'll not be used to resolve relative paths for module loading purposes or file handling in general.

The other two commits add some needed test infrastructure and two tests: one for trying to use globalThis.location in top-level code without using --init-location, and another for successfully using it with the arg.

BEGIN_COMMIT_OVERRIDE
feat: add support for setting initialization-time script location
END_COMMIT_OVERRIDE

This adds an `--init-location` CLI arg that can be used to set a location for use during wizening. This is meant to enable working around issues with libraries that use `globalThis.location` during top-level evaluation.

An example of a library that does this, and is used as a dependency in a number of projects, is [cfworker](https://github.com/cfworker/cfworker/blob/b9a093a54ba81ef58960cb43574169df021ecc70/packages/json-schema/src/dereference.ts#L68-L75).

The location will not be used for anything runtime-internal. Specifically, it'll not be used to resolve relative paths for module loading purposes or file handling in general.

Signed-off-by: Till Schneidereit <till@tillschneidereit.net>
Signed-off-by: Till Schneidereit <till@tillschneidereit.net>
Signed-off-by: Till Schneidereit <till@tillschneidereit.net>

@andreiltd andreiltd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! 🎉

@tschneidereit
tschneidereit merged commit 176ccdd into bytecodealliance:main Oct 15, 2025
6 checks passed
@tschneidereit
tschneidereit deleted the wizening-location branch October 15, 2025 13:38
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