Skip to content

refactor!: plugin hooks ssr param to object#5253

Merged
patak-cat merged 7 commits intomainfrom
refactor-plugin-hooks-ssr-param
Oct 27, 2021
Merged

refactor!: plugin hooks ssr param to object#5253
patak-cat merged 7 commits intomainfrom
refactor-plugin-hooks-ssr-param

Conversation

@patak-cat
Copy link
Member

@patak-cat patak-cat commented Oct 11, 2021

Description

See discussion at #5109 (comment).

This PR modifies the way Vite informs ssr mode to plugin hooks from a positional param to a prop in the options object of resolveId, transform and load. This was already discussed by the team and the plugin authors.

export interface Plugin extends RollupPlugin {
    // ... other hooks
    resolveId?(this: PluginContext, source: string, importer: string | undefined, options: {
        custom?: CustomPluginOptions;
        ssr?: boolean;
    }): Promise<ResolveIdResult> | ResolveIdResult;
    load?(this: PluginContext, id: string, options?: {
        ssr?: boolean;
    }): Promise<LoadResult> | LoadResult;
    transform?(this: TransformPluginContext, code: string, id: string, options?: {
        ssr?: boolean;
    }): Promise<TransformResult> | TransformResult;
}

What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

@brillout
Copy link
Contributor

LGTM (Superficial review. Neat comprehensive docs update 👌.), and vite-plugin-ssr is not using server.pluginContainer.

brillout
brillout previously approved these changes Oct 11, 2021
Shinigami92
Shinigami92 previously approved these changes Oct 12, 2021
Copy link
Member

@Shinigami92 Shinigami92 left a comment

Choose a reason for hiding this comment

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

Do we want to release this with 2.7, or before?
You could add this PR to the milestone dependant on the answer 🙂

@patak-cat
Copy link
Member Author

I didnt add it yet because I dont know if we are targetting 2.7 or 2.8. But given the way the ecosystem reacted, it is probably going to be in the next minor

@patak-cat patak-cat dismissed stale reviews from Shinigami92 and brillout via f57c50c October 12, 2021 20:31
@patak-cat patak-cat removed the on hold label Oct 14, 2021
@patak-cat patak-cat added this to the 2.7 milestone Oct 14, 2021
@patak-cat patak-cat added the p2-nice-to-have Not breaking anything but nice to have (priority) label Oct 14, 2021
@patak-cat patak-cat merged commit d5e51f4 into main Oct 27, 2021
@patak-cat patak-cat deleted the refactor-plugin-hooks-ssr-param branch October 27, 2021 14:06
sfriedel added a commit to nubolab-ffwd/svelte-fluent that referenced this pull request Dec 13, 2021
Adds backwards compatible handling of the plugin API changes from
Vite 2.7 (vitejs/vite#5253)
aleclarson pushed a commit to aleclarson/vite that referenced this pull request Feb 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat: ssr p2-nice-to-have Not breaking anything but nice to have (priority)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants