vite: no enforce: "post" - #8627
Merged
Merged
Conversation
🦋 Changeset detectedLatest commit: eb7d570 The changes in this PR will be included in the next version bump. This PR includes changesets to release 16 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
pcattori
force-pushed
the
pedro/vite-no-enforce-post
branch
from
January 29, 2024 19:46
819a425 to
428d6fb
Compare
"Post" plugins are meant primarily for build analysis. Previously we were relying on `enforce: "post"` to ensure that plugins that transpile other languages to JS/TS ran before the Remix plugin. However, it should be the responsability of _those_ plugins to declare themselves with `enforce: "pre"`. In the case of MDX, the canonical plugin is not a Vite plugin, but rather a Rollup plugin so it cannot set `enforce` as that is a Vite-only API. Ideally, someone would wrap the MDX Rollup plugin and declare it as `enforce: "pre"`. This can also be done in userland through a simple object spread. That said, its simpler to place the MDX plugin before the Remix plugin in the Vite plugins array. Order is semantically meaningful for Vite plugins anyway.
pcattori
force-pushed
the
pedro/vite-no-enforce-post
branch
from
January 30, 2024 00:58
428d6fb to
eb7d570
Compare
Contributor
|
🤖 Hello there, We just published version Thanks! |
Contributor
|
🤖 Hello there, We just published version Thanks! |
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.
tl;dr: we were abusing
enforce: "post"so thatmdxplugin could be place afterremixplugin. Instead, we should either expect plugins likemdxto self-declare aspreor rely on Vite plugin ordering."Post" plugins are meant primarily for build analysis. Previously we were relying on
enforce: "post"to ensure that plugins that transpile other languages to JS/TS ran before the Remix plugin. However, it should be the responsability of those plugins to declare themselves withenforce: "pre". In the case of MDX, the canonical plugin is not a Vite plugin, but rather a Rollup plugin so it cannot setenforceas that is a Vite-only API.Ideally, someone would wrap the MDX Rollup plugin and declare it as
enforce: "pre". This can also be done in userland through a simple object spread.That said, its simpler to place the MDX plugin before the Remix plugin in the Vite plugins array. Order is semantically meaningful for Vite plugins anyway.
The official Vite React SWC plugin also relies on plugin ordering for MDX.