iTwin / itwinjs-core

Monorepo for iTwin.js Library
https://www.itwinjs.org
MIT License
583 stars 211 forks source link

Allow map-layers providers use web workers #4474

Open mdastous-bentley opened 1 year ago

mdastous-bentley commented 1 year ago

Some map-layers provider, such as the upcoming ArcGIS feature provider would benefit from using web workers. To use Web worker in type scripts, a web worker needs to be created this way: this._worker = new Worker(new URL("./PaintWorker.js", **import.meta.url**));

To leverage import.meta.url, modules needs to be flagged as ESM modules in package.json using: "type": "module"

Doing so, will make existing fails to compile. (i.e. failing import commands)

We would need guidelines on how to have ESM modules in iTwin.js.

pmconne commented 1 year ago

@mdastous-bentley see if the newly-introduced WebWorkerProxy unblocks you.