fix(scripts): declare Runnable entry points with var so modern engines find them - #494
Open
ResurrectedTrader wants to merge 1 commit into
Open
ResurrectedTrader wants to merge 1 commit into
ResurrectedTrader wants to merge 1 commit into
Conversation
…s find them Loader resolves each script as `global[script]`. On modern JS engines such as V8 (d2bsn) a top-level `const` is a binding in the global lexical environment, not a property of the global object, so `global["Pindleskin"]` is undefined and every Runnable script dies with "Invalid script function name. Typeof: undefined". Legacy SpiderMonkey aliased top-level `const` to a read-only `var`, which is why this worked there. Switch the 84 script entry points in libs/scripts to `var`, which is a global-object property on both engines, with an inline `eslint-disable-next-line no-var` on each declaration explaining why. SoloPlay is unaffected: its scripts are plain function declarations. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Contributor
Author
|
Note I currently work around this via: |
Contributor
|
I know we've talked about this one before. Still don't like it, just feels wrong to make an exception for |
Contributor
Author
|
It's effectively a var now. |
Contributor
Author
|
Asked robot about globalThis: Let me know how you want to proceed. |
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.
Problem
Loaderresolves every script by name throughglobal[script](libs/core/Loader.js, and SoloPlay'sLoaderOverrides.jsdoes the same). All 84 entry points inlibs/scriptsare declared asconst X = new Runnable(...).On modern JS engines a top-level
const/letis a binding in the global lexical environment, not a property of the global object, soglobal["Pindleskin"]isundefinedand every script fails in the loader with:Legacy SpiderMonkey treated top-level
constas a read-onlyvaron the global object, which is why this has been working so far. Quick reproduction on V8 via node'svmmodule:Change
var, which is a global-object property on every engine. Bare-identifier andtypeof Xaccess across files is unaffected.eslint-disable-next-line no-var -- <reason>so the exemption is limited to exactly these lines;eslint.config.mjsis untouched and lint stays clean.functiondeclarations, and its loader only includesSoloPlay/Scripts/.🤖 Generated with Claude Code