Fix SharedWorker initialization race and address review feedback
- Make ESM evaluate chunk IIFE async and await `BACKEND.registerChunk()` so
`import(evaluate_chunk)` only resolves after all modules are instantiated.
Without this, SharedWorkers fire the `connect` event before `onconnect`
listeners are registered.
- Rename `worker_chunk_context(is_esm)` → `esm_chunking_context()` (no param).
Callers only call it when `is_esm` is true; the impl returns `self` when
`esm_chunks` is already set (fixes the comparison-vs-self.esm_chunks concern).
- Remove redundant `chunkUrls.reverse()` from ESM worker bootstrap; `import()`
loads in parallel so order doesn't matter.
- Deduplicate preinit loop in `required-scripts.tsx` using a `preinitFn`
variable instead of duplicating the loop body.
- Remove debug logging from shared worker test.
- Fix comment wording: "not yet an array" → "not an array".
Co-Authored-By:
Claude <noreply@anthropic.com>
Showing
Please
register
or
sign in
to comment