Repository navigation
fix(babel): run parallel workers as ES modules - #176
Merged
sapphi-red merged 2 commits intoNov 27, 2026
Merged
Conversation
artichokie runs worker code with `eval: true` by default, so `require`, `module`, `__dirname` and `__filename` are globals in the worker. Babel plugins that check for them gave different output with `parallel` than on the main thread. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
NullVoxPopuli
approved these changes
Nov 26, 2026
NullVoxPopuli
left a comment
Contributor
There was a problem hiding this comment.
I'm happy how small this turned out!
This was referenced Nov 26, 2026
Merged
Closed
Open
Draft
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With
parallel, the workers now run as ES modules (artichokietype: 'module'). Babel plugins then see the same globals in a worker as on the main thread.Before this, artichokie started each worker with
new Worker(code, { eval: true }). In such a worker,require,module,__dirnameand__filenameare globals, and ES modules loaded in the worker can see them. On the main thread they are undefined. So some plugins gave other output withparallel:idwhen it finds a globalrequire. One app got 3.5 kB more output (Spike: replace @rollup/plugin-babel with @rolldown/plugin-babel ember-cli/ember-addon-blueprint#168 (review)). Workaround in Emit a null template id in every environment emberjs/babel-plugin-ember-template-compilation#129.@warp-drive/build-configbefore 5.9 checkstypeof __dirname, gets".", and fails to find itspackage.json. Workaround in Remove the eval globals for @warp-drive/build-config before 5.9 in babel workers NullVoxPopuli/ember.nvp#241.Details: #139 (comment)
The new test runs a fixture plugin in a worker that writes
typeofof the four globals into the output, and expects all four to beundefined. It fails without the change. I also built the package and ran the same fixture throughdist/index.mjs, where the worker importsdist/transform.mjsfrom thedata:URL module. It gave the same result.🤖 Generated with Claude Code