Replies: 7 comments 9 replies
-
As I stated in the PR, any of these options would be fine and future proof for Rollup, including the third. That one is probably the best from a dev experience point. |
Beta Was this translation helpful? Give feedback.
-
We discussed this with the team, and we think we should move forward so the plugin API is future-proof to both rollup and Vite extensions. Instead of the current interface Plugin {
resolveId?(
source: string,
importer: string | undefined,
options: { custom?: CustomPluginOptions, ssr?: boolean }
): ...
load?(
id: string,
options?: { ssr?: boolean }
): ...
transform?(
code: string,
id: string,
options?: { ssr?: boolean }
): ...
} Rollup already has an options object in This is a breaking change, but we believe that it is worth doing now that we can still coordinate between the different frameworks. @antfu @benmccann @brillout @frandiox @galvez @DylanPiercey @ryansolid @natemoo-re @fks @drwpow (please help us to involve others that may be affected by this), what do you think? We could target 2.7 or 2.8 if we need more time (but probably better to do it sooner rather than later) |
Beta Was this translation helpful? Give feedback.
-
👍 FYI, newly released // https://github.com/vitejs/vite/discussions/5109#discussioncomment-1450726
function isSSR(options: undefined | boolean | { ssr: boolean }): boolean {
if (options === undefined) {
return false
}
if (typeof options === 'boolean') {
return options
}
if (isObject(options)) {
return !!options.ssr
}
assert(false)
} |
Beta Was this translation helpful? Give feedback.
-
released @sveltejs/[email protected] with support for this sveltejs/vite-plugin-svelte#187 thanks for driving this @patak-js |
Beta Was this translation helpful? Give feedback.
-
Thanks @patak-js ! I think this won't be a breaking change for vitedge or vite-ssr, so we're good 👍 |
Beta Was this translation helpful? Give feedback.
-
Thanks for the heads up — FWIW I don't use any of these features yet in fastify-vite though. I might start using them soon to provide virtual modules for common boilerplate items. |
Beta Was this translation helpful? Give feedback.
-
We have now a PR to update the plugin hooks in #5253. It currently implements what we have discussed. Moving a discussion about Vite also exposes in the JS API through the server, access to the export interface PluginContainer {
options: InputOptions
buildStart(options: InputOptions): Promise<void>
resolveId(
id: string,
importer?: string,
skip?: Set<Plugin>,
ssr?: boolean
): Promise<PartialResolvedId | null>
transform(
code: string,
id: string,
inMap?: SourceDescription['map'],
ssr?: boolean
): Promise<SourceDescription | null>
load(id: string, ssr?: boolean): Promise<LoadResult | null>
close(): Promise<void>
} We didn't discuss changing this API yet. I don't know how many plugins or integrations are using it. Contrary to the changes in the plugin hooks, modifying this one can not be done in a compatible way (where plugin authors can check if the export interface PluginContainer {
options: InputOptions
buildStart(options: InputOptions): Promise<void>
resolveId(
id: string,
importer?: string,
options?: { skip?: Set<Plugin>, ssr?: boolean }
): Promise<PartialResolvedId | null>
transform(
code: string,
id: string,
options?: { inMap?: SourceDescription['map'], ssr?: boolean }
): Promise<SourceDescription | null>
load(
id: string,
options?: { ssr?: boolean }
): Promise<LoadResult | null>
close(): Promise<void>
} I don't know if this change is justified though. This isn't an API shared with Rollup. And this wouldn't only affect the experimental SSR API (it also touches |
Beta Was this translation helpful? Give feedback.
-
Rollup is extending its plugin API to support an
isEntry
flag in theoptions
ofresolveId
andresolve
. See rollup/rollup#4230Vite added an
ssr
boolean flag toresolveId
,load
, andtransform
. This doesn't interfere inresolveId
as it goes after theoptions
param. But intransform
, there isn't anoptions
object:There may be further extensions to the Rollup plugin API (or extensions that originate from Vite). We may want to review the SSR extension before SSR is out of experimental, as IMO the ecosystem of plugins and integrations could still adapt if we do this in a minor. There are probably other API changes to the SSR API anyways and we could bundle these changes together.
See comment from @lukastaegert about their experience in Rollup rollup/rollup#4230 (comment) after using positional args they have switched to only add new things in options, they are suggesting that we switch to
or
For completeness, we could also just use
ssr
here, because it is probable that our extensions are also going to be useful to other tools like WMR.Bringing the discussion here to avoid derailing the
isEntry
extension PR.Beta Was this translation helpful? Give feedback.
All reactions