Skip to content

Add opt-in behavior for custom transforms to support bundles#31301

Merged
rbuckton merged 1 commit intomasterfrom
fixCustomTransformers
May 8, 2019
Merged

Add opt-in behavior for custom transforms to support bundles#31301
rbuckton merged 1 commit intomasterfrom
fixCustomTransformers

Conversation

@rbuckton
Copy link
Copy Markdown
Contributor

@rbuckton rbuckton commented May 7, 2019

As an alternative approach to #29871, this PR addresses a backwards-compatibility issue when we added support for transforming Bundle nodes. Custom transformers have the type TransformerFactory<SourceFile>, as they only expect to receive source files. However, we assign them to an array of TransformerFactory<Bundle | SourceFile>[] and may inadvertently pass a Bundle to a transformer that is not able to support it.

To address this, I've added an opt-in mechanism where custom transform authors can return a CustomTransformer object or the existing Transformer<SourceFile> callback. Custom transformers are then wrapped in a callback that invokes the transformation based on whether it is a function (and correctly wraps it in a call to chainBundle), or an object (in which case the appropriate transformSourceFile or transformBundle methods are called).

Fixes #28310, #24459
Replaces #29871

Copy link
Copy Markdown
Member

@weswigham weswigham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good, but that union type looks like a typo 😉

@rbuckton rbuckton force-pushed the fixCustomTransformers branch from 3fdf078 to 0c1a283 Compare May 8, 2019 00:29
@rbuckton rbuckton merged commit 15e9c4c into master May 8, 2019
@rbuckton rbuckton deleted the fixCustomTransformers branch May 8, 2019 00:31
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

API: Make public internal chainBundle

2 participants