Skip to content

fix: Passing custom transforms to {web,turbo}pack - #44

Merged
timfish merged 2 commits into
mainfrom
fix/web-turbo-pack-custom-transforms
Jul 29, 2026
Merged

fix: Passing custom transforms to {web,turbo}pack#44
timfish merged 2 commits into
mainfrom
fix/web-turbo-pack-custom-transforms

Conversation

@timfish

@timfish timfish commented Jul 23, 2026

Copy link
Copy Markdown
Member

customTransforms was silently dropped by the webpack plugin - it only forwarded instrumentations and dcModule to the loader, so a config naming a transform threw per file and fell back to untransformed code.

  • webpack: the plugin now forwards customTransforms. Webpack passes loader options by reference, so the functions arrive intact.
  • Turbopack / thread-loader: these serialize options, so functions can't get through. New /webpack-loader-factory export — createLoader({ customTransforms }) builds a loader with the transforms bound at require time. Point the plugin at it with the new loaderPath option.
  • Cache fix: webpack keys loaders by ruleset ident, not options content, so a changed config reused stale modules under cache: { type: 'filesystem' } - a pre-existing bug affecting instrumentations too. The ident is now derived from the config. cacheVersion covers data a transform reads but doesn't name, which Function.prototype.toString can't see.

Also updates the README's custom transform example to override tracingChannelImport so injection only happens where instrumentation actually ran — no more phantom Program configs.

@timfish
timfish requested review from AbhiPrasad, Lms24, Qard and isaacs July 23, 2026 15:55
@timfish
timfish enabled auto-merge (squash) July 29, 2026 15:22
@timfish
timfish merged commit e720adc into main Jul 29, 2026
1 check passed
@timfish
timfish deleted the fix/web-turbo-pack-custom-transforms branch July 29, 2026 15:22
@timfish timfish mentioned this pull request Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants