Skip to content
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

feat!: make plugins work multi hooks #94

Merged
merged 24 commits into from
Apr 4, 2024

Conversation

florian-lefebvre
Copy link
Owner

@florian-lefebvre florian-lefebvre commented Mar 26, 2024

Depends on #93, close #44

TODO:

  • Types working
  • Update runtime code
  • Test
  • Clean types and add comments (@Fryuni)
  • Check plugin still works as intended (@BryceRussell)
  • Add docs
    • Update definePlugin
    • Update breaking changes
  • Changeset
  • Lint

Copy link

netlify bot commented Apr 2, 2024

Deploy Preview for astro-integration-kit ready!

Name Link
🔨 Latest commit 8c59e6f
🔍 Latest deploy log https://app.netlify.com/sites/astro-integration-kit/deploys/660c3c3d9f466b0008a117e0
😎 Deploy Preview https://deploy-preview-94--astro-integration-kit.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Apr 2, 2024

Deploy Preview for astro-integration-kit ready!

Name Link
🔨 Latest commit dc23999
🔍 Latest deploy log https://app.netlify.com/sites/astro-integration-kit/deploys/660e61037a890800082b6f96
😎 Deploy Preview https://deploy-preview-94--astro-integration-kit.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@florian-lefebvre
Copy link
Owner Author

florian-lefebvre commented Apr 2, 2024

@Fryuni would you be willing to clean the types at package/src/core/types.ts? I know you're good at TS and I've probably done dumb/inefficient stuff so your help would be much appreciated!

@florian-lefebvre
Copy link
Owner Author

@BryceRussell can you check if hasVitePluginPlugin still works as intended on the playground?

@BryceRussell
Copy link
Collaborator

hasVitePluginPlugin still works

@florian-lefebvre
Copy link
Owner Author

Awesome thanks for checking!

@Fryuni
Copy link
Collaborator

Fryuni commented Apr 2, 2024

@Fryuni would you be willing to clean the types at package/src/core/types.ts? I know you're good at TS and I've probably done dumb/inefficient stuff so your help would be much appreciated!

Sure thing. I'll try to reserve some time for it later today or tomorrow

@florian-lefebvre
Copy link
Owner Author

Awesome thank you!

@florian-lefebvre florian-lefebvre marked this pull request as ready for review April 3, 2024 07:11
@florian-lefebvre florian-lefebvre linked an issue Apr 3, 2024 that may be closed by this pull request
@BryceRussell
Copy link
Collaborator

Now that plugins can use multiple hooks, what do you think about adding hasVitePlugin to astro:config:done?

"astro:config:done": (params) => {
	return {
		hasVitePlugin: (plugin: string | PluginOption) =>
			hasVitePlugin(
				params as unknown as HookParameters<"astro:config:setup">,
				{
					plugin,
				},
			),
	};
},

@florian-lefebvre
Copy link
Owner Author

florian-lefebvre commented Apr 3, 2024

In addition to the current hook or as a replacement?

@Fryuni
Copy link
Collaborator

Fryuni commented Apr 3, 2024

Now that plugins can use multiple hooks, what do you think about adding hasVitePlugin to astro:config:done?

I like that idea, but I think it should come with a very tiny little refactor to allow a utility to accept params from more than one hook and work the same. Worth an issue for a following PR

@BryceRussell
Copy link
Collaborator

In addition to the current hook or as a replacement?

In addition to the current hook

I like that idea, but I think it should come with a very tiny little refactor to allow a utility to accept params from more than one hook and work the same

Sounds good, it would be nicer to type this properly. I originally added this to test the changes in the playground and thought it could be an easy thing to support

@florian-lefebvre
Copy link
Owner Author

Sounds good! Let's track in a distinct issue

Copy link
Collaborator

@Fryuni Fryuni left a comment

Choose a reason for hiding this comment

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

Left a few optimizations and small points, but overall looks awesome.

package/src/core/with-plugins.ts Outdated Show resolved Hide resolved
package/src/core/with-plugins.ts Outdated Show resolved Hide resolved
package/src/core/with-plugins.ts Outdated Show resolved Hide resolved
@florian-lefebvre florian-lefebvre requested a review from Fryuni April 4, 2024 08:13
@florian-lefebvre florian-lefebvre merged commit 967ca76 into release/0.9 Apr 4, 2024
7 checks passed
@florian-lefebvre florian-lefebvre deleted the feat/multi-hooks-plugins branch April 4, 2024 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow plugins to use several hooks
4 participants