-
-
Notifications
You must be signed in to change notification settings - Fork 338
fix(dev-server-rollup): add basic support for transform objects #3121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
akrawitz
wants to merge
1
commit into
modernweb-dev:master
Choose a base branch
from
akrawitz:fix-transform
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+13
−2
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@web/dev-server-rollup': patch | ||
| --- | ||
|
|
||
| added support for `transform` objects in Rollup plugins |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC the main reason to define transform function in an object with a
handlerkey is to also defineorder, see ordere.g.
but I don't think we currently handle
orderin the adapterin other words, if you add support for
transform.handler, then it should also implement the ordering, otherwise it doesn't seem to solve any real-world use-case and instead might actually introduce bugsand also I think all hooks support
.handlerand.order, so might be good to check if for other hooks it's also neededUPDATE
in the original issus report you write
the linked code shows also the usage of
.filter, which is also not supported in this PR, and the lack of.filtersupport might as well break the yaml plugin, right?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that this is adding only the most minimal support for
transform.handler. As you point out, it does not deal withtransform.orderortransform.filter(ortransform.sequential).However, the real world use case is to be able to continue using a plugin that has moved from a
transformfunction to atransformobject in the same way that I was using it before. In other words, not relying on any new functionality provided byorder,filter, orsequential.I agree that this partial support is less than ideal, but the fact is that
@web/dev-server-rollupis only providing partial support for Rollup plugins more generally. For example, only a subset of hooks are supported (see https://modern-web.dev/docs/dev-server/plugins/rollup/#compatibility-with-rollup-plugins as compared to https://rollupjs.org/plugin-development/#build-hooks).I would also note that (as far as I can tell) the code dealing with the
idResolvehook is already taking this approach of "cherrypicking"idResolve.handlerwhile ignoringorder,filter, andsequential:web/packages/dev-server-rollup/src/rollupAdapter.ts
Lines 213 to 214 in b949cff
Also, due to the way that
filteris getting used in thehandlerby the YAML plugin, it works just fine.If it would be helpful, I could try to add a test case using
@rollup/plugin-yamlto confirm it works in this sort of basic usage. (Although I haven't even been able to get the existing tests to run successfully, so I might need some help with this...) And I could add a warning to the documentation in the section Compatibility with rollup plugins indicating thatorder,filter, andsequentialare not supported.Having said all of that, I get that this sort of "partial support" can be confusing for users, so I would understand if you don't want to go down this path.