Block evaluator attribute
guybedford opened this issue · 1 comments
This came up in #7 - would there be any benefit in defining an as "block"
evaluator attribute in future?
For example, to load a source text or Wasm module as a module block to pass to another thread one could write:
import linkedWasmModule from './module.wasm' as 'block';
const worker = new Worker(new URL('./executor.js', import.meta.url));
worker.postMessage(linkedWasmModule);
the benefit of this being the ability to pass any linked module (not just blocks) across boundaries, and possibly for some preloading benefits.
In theory one can easily do the above without such an attribute via:
const linkedWasmModule = module { export * from './module.wasm' };
const worker = new Worker(new URL('./executor.js', import.meta.url));
worker.postMessage(linkedWasmModule);
Although the workflow friction in the above is hitting the problem that export *
excludes the default
export so one does need to reflect the default specifically or not depending on whether it is included, where the attribute would kind of pave the pattern more clearly.
For those unaware: module blocks == https://github.com/tc39/proposal-js-module-blocks.
@surma would this be of interest to you?