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
I am building a Worker for my team's custom language, and I want to obtain ace modules from ace-builds inside a Worker like so:
import * as ace from 'ace-builds';
const { Mirror } = ace.require('ace/worker/mirror');
I understand that much of Ace only works on the UI thread, but some components are useful inside workers and it is preferable to rely on ace-builds a single source of truth rather than acquiring CommonJS sources from ace-code. In addition to de-duplicating shared code, this would prevent the version of ace-builds and ace-code from going out of sync as other developers take over this project.
However, the unqualified references to window as a free variable in the exportAce function in Makefile.dryice.js ll. 792-798 crashes the worker at module init time.
import * as ace from 'ace-builds' and calling ace.require() should function correctly inside a Worker.
Current Behavior
import * as ace from 'ace-builds' and calling ace.require() crashes with a ReferenceError at module load time when window is referenced as a free variable.
Reproduction Steps
please @ me if you really need this :)
Possible Solution
Replace references to window in Makefile.dryice.js with
Describe the bug
I am building a Worker for my team's custom language, and I want to obtain ace modules from
ace-builds
inside a Worker like so:I understand that much of Ace only works on the UI thread, but some components are useful inside workers and it is preferable to rely on
ace-builds
a single source of truth rather than acquiring CommonJS sources fromace-code
. In addition to de-duplicating shared code, this would prevent the version oface-builds
andace-code
from going out of sync as other developers take over this project.However, the unqualified references to
window
as a free variable in theexportAce
function inMakefile.dryice.js
ll. 792-798 crashes the worker at module init time.Notably,
ace/build_support/mini_require.js
ll. 41-42 andace/lib/ace/loader_build.js
ll. 14-16 do not suffer from this same problem, obtaining a reference toglobal
in a worker-safe manner.Expected Behavior
import * as ace from 'ace-builds'
and callingace.require()
should function correctly inside a Worker.Current Behavior
import * as ace from 'ace-builds'
and callingace.require()
crashes with aReferenceError
at module load time whenwindow
is referenced as a free variable.Reproduction Steps
please @ me if you really need this :)
Possible Solution
Replace references to
window
inMakefile.dryice.js
withto match
build_support/mini_require.js
andlib/ace/loader_build.js
, or replace all three withglobalThis
.Additional Information/Context
No response
Ace Version / Browser / OS / Keyboard layout
1.8.1 / Chrome / Linux / QWERTY
The text was updated successfully, but these errors were encountered: