You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bindings where @scope has same name as module can result in runtime errors #7478
Ah I didn't read the breaking changes section of v12.0.0-alpha.1 carefully enough - I see now that since #6831 we're not escaping browser globals anymore.
I'll update this issue title and description to not be v12 specific 👍
changed the title [-]v12 breaks bindings where `@scope` has same name as module[/-][+]Bindings where `@scope` has same name as module can result in runtime errors[/+]on May 17, 2025
Activity
cknitt commentedon May 17, 2025
I think this is not a v12 issue per se, it's just that v12 doesn't escape
URLwith$$anymore.If the module name is different, the same problem exists in v11:
https://rescript-lang.org/try?version=v11.1.4&module=esmodule&code=LYewJgrgNgpgBAVQEpIDJwLxwN5zgKDwAEA3AQyjiIGcBjEABxgAoAiZNVgSkLhgA8ALjABOAOwpwRMEiADWMAPIAjAFYxag5KgBccaoJEBLMQHNMAPjgQxRwZjitpshSvWbtrfAF98+DqgAdM7ySmoaWmhs1CDA8BAiUNz4QA
mediremi commentedon May 17, 2025
Ah I didn't read the breaking changes section of
v12.0.0-alpha.1carefully enough - I see now that since #6831 we're not escaping browser globals anymore.I'll update this issue title and description to not be v12 specific 👍
[-]v12 breaks bindings where `@scope` has same name as module[/-][+]Bindings where `@scope` has same name as module can result in runtime errors[/+]cometkim commentedon May 17, 2025
cometkim commentedon May 18, 2025
I see. It should be something like:
cometkim commentedon May 18, 2025
Workaround (IMO the correct resolution):
cknitt commentedon May 19, 2025
Although this can be broken in basically the same way:
cometkim commentedon May 19, 2025
globalThisshould be mangled by default.The output in v12 is:
zth commentedon May 20, 2025
One downside of leveraging
globalThisis that it doesn't look handwritten. But I guess there's no other good way around this.cometkim commentedon May 20, 2025
Maybe we can make it as a standard like
@globalScope(..)?zth commentedon May 20, 2025
Are there any alternative ways around this? Could we detect when this unintended clash happens and only then emit
globalThis?cknitt commentedon May 20, 2025
Ah, right, it is mangled in v12, but not v11.