Add support for setting initialization-time script location#278
Merged
tschneidereit merged 3 commits intobytecodealliance:mainfrom Oct 15, 2025
Merged
Add support for setting initialization-time script location#278tschneidereit merged 3 commits intobytecodealliance:mainfrom
tschneidereit merged 3 commits intobytecodealliance:mainfrom
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds an
--init-locationCLI arg that can be used to set a location for use during wizening. This is meant to enable working around issues with libraries that useglobalThis.locationduring 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.locationin 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