worker: strip types in Web Worker module entries - #66085
osztenkurden wants to merge 3 commits into
Conversation
Strip TypeScript from file-backed module worker entries before evaluating the fetched source. Add regression coverage and document the supported entry types. Assisted-by: Codex Signed-off-by: Hubert Walczak <hubertwalczak8@gmail.com>
|
Review requested:
|
|
Welcome to Node.js, and thank you for your first contribution! Before review, please take a moment to read:
Please make sure every commit is signed off. For a first pull request, GitHub Actions require collaborator approval and Jenkins CI must be started by a collaborator or triager, so an initial wait is normal. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #66085 +/- ##
==========================================
+ Coverage 90.27% 90.30% +0.03%
==========================================
Files 789 789
Lines 271623 272896 +1273
Branches 51847 52119 +272
==========================================
+ Hits 245196 246432 +1236
- Misses 16910 16914 +4
- Partials 9517 9550 +33
🚀 New features to boost your workflow:
|
Pass the decoded path to stripTypeScriptModuleTypes() so it does the node_modules check, instead of repeating it in webworker.js. Shorten the note in globals.md and drop the typescript.md paragraph. Remove test cases that repeat what other cases already cover. Signed-off-by: Hubert Walczak <hubertwalczak8@gmail.com>
60307c1 to
29c8d52
Compare
|
@avivkeller would you mind taking a quick look? 🙏 Currently running TypeScript entry WebWorker fails, and that adds a bit of boilerplate |
avivkeller
left a comment
There was a problem hiding this comment.
LGTM, and thanks for the ping! just note it's differing from the HTML Spec (which is fine, but @nodejs/web-standards should take a look)
|
Why would web workers strip types? |
jasnell
left a comment
There was a problem hiding this comment.
Generally LGTM but I think we should probably handle it as independently experimental in case we need to tweak it separately from graduating the main web worker implementation.
Lazy load the type stripping helper with getLazy(), and list type stripping under the differences from the HTML Standard. Signed-off-by: Hubert Walczak <hubertwalczak8@gmail.com>
|
@KhafraDev my reasoning was that if the type stripping was actually already working in worker_threads and in modules that Web Worker imports, then making entry point with types work seemed like a good idea and putting everything in line. |
|
I'm fine with it landing. |
The experimental Web Worker module entries don't perform TypeScript stripping: type annotations in the entry file cause a SyntaxError, even though a JavaScript-compatible entry importing files with TypeScript annotations succeeds.
The proposed solution is to strip types from file-backed .ts, .mts, and .cts module-worker entries before evaluation, preserving existing fetching and worker-type semantics.