Skip to content

fix(webgal): map global to globalThis in browser builds - #1025

Open
modenicheng wants to merge 1 commit into
OpenWebGAL:mainfrom
modenicheng:fix/browser-global
Open

fix(webgal): map global to globalThis in browser builds#1025
modenicheng wants to merge 1 commit into
OpenWebGAL:mainfrom
modenicheng:fix/browser-global

Conversation

@modenicheng

Copy link
Copy Markdown

Summary

Map the browser bundle's global identifier to globalThis so expression evaluation works in browser builds.

Problem

angular-expressions@1.4.3 accesses Node's global during compile():

if (global.storeFnString) {
  global.storeFnString(fnString);
}

When WebGAL runs in a browser bundle, global is undefined. This makes expression evaluation fail with:

ReferenceError: global is not defined

The failure affects script expressions such as setVar:morale=morale+1 and conditional evaluation used by -when. In the current error handling, those failures can silently turn into an empty variable value or a false condition.

Fix

Configure Vite to replace global with the browser-standard globalThis in the generated bundle. This keeps the fix scoped to the browser build and avoids changing WebGAL's expression semantics.

Validation

  • git diff --check passes.
  • The project's existing PR workflow will run parser tests and the full WebGAL build.

This is separate from #1005, which addresses expression evaluation semantics and variable extraction rather than the browser global compatibility failure.

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