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: support plugin.order #769

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

moushicheng
Copy link

@moushicheng moushicheng commented Apr 6, 2024

Description

⚠️This pr is under construction

support plugin attr order:
rollup doc

order: "pre" | "post" | null
If there are several plugins implementing this hook, either run this plugin first ("pre"), last ("post"), or in the user-specified > position (no value or null).

export default function resolveFirst() {
	return {
		name: 'resolve-first',
		resolveId: {
			order: 'pre',
			handler(source) {
				if (source === 'external') {
					return { id: source, external: true };
				}
				return null;
			}
		}
	};
}

If several plugins use "pre" or "post", Rollup runs them in the user-specified order. This option can be used for all plugin hooks. For parallel hooks, it changes the order in which the synchronous part of the hook is run.

confusion

I want to sort the plugins , i think it should implementation in PluginDriver.
site: crates/rolldown_plugin/src/plugin_driver/build_hooks.rs

impl PluginDriver {
  pub async fn build_start(&self) -> HookNoopReturn {
    // TODO should call `build_start` of all plugins in parallel
    for (plugin:&Box<dyn Plugin>, ctx) in &self.plugins {
      plugin.build_start(ctx).await?;
    }
    Ok(())
  }
}

but beacause of plugin type is &Box<dyn Plugin>,i cant get buildstart hook options although i delivery attribute order.
i want to change plugin type to JsPlugin,but JsPlugin is define in crates rolldown_binding.This does not seem to be a dependency.
so how can i get completly plugin.build_start? I admit I'm not very familiar with rust...

Copy link

netlify bot commented Apr 6, 2024

Deploy Preview for rolldown-rs canceled.

Name Link
🔨 Latest commit 98ef768
🔍 Latest deploy log https://app.netlify.com/sites/rolldown-rs/deploys/66114d2f737aa300087fec36

@hyf0
Copy link
Member

hyf0 commented Apr 6, 2024

Thanks for your work. However it's better to create an issue to discuss about the feature rather than just throwing a PR.

Let's create an issue about supporting plugin order and have a fully investigation on it.

@hyf0 hyf0 removed the needs-triage label Apr 6, 2024
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.

None yet

2 participants