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

refactor: resolvePlugins by combining resolveFarmPlugins and resolveAsyncPlugins #1274

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

Conversation

DeepeshKalura
Copy link

Description:

This PR introduces a new function, resolvePlugins, which combines the functionality of resolveFarmPlugins and resolveAsyncPlugins. This new function first resolves any promises and flattens the array of plugins, and then processes the resulting plugins as in resolveFarmPlugins. This allows the use of async and nested plugins in the configuration.

Changes:

Added a new function resolvePlugins in src/plugin/index.ts that handles async and nested plugins.
Replaced calls to resolveFarmPlugins with resolvePlugins in the codebase.

BREAKING CHANGE:

This change should not introduce any breaking changes. The new function resolvePlugins is backwards compatible with resolveFarmPlugins.

Related issue :
Resolves #1224

Copy link

changeset-bot bot commented Apr 30, 2024

🦋 Changeset detected

Latest commit: 6e3d7a3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 8 packages
Name Type
@farmfe/core Major
@farmfe-examples/react-antd Patch
@farmfe/js-plugin-less Major
@farmfe/js-plugin-postcss Major
@farmfe/js-plugin-sass Major
@farmfe/js-plugin-solid Major
@farmfe/js-plugin-svgr Major
@farmfe/js-plugin-vue Major

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

@ErKeLost ErKeLost changed the title Refactor resolvePlugins by combining resolveFarmPlugins and resolveAsyncPlugins chore: Refactor resolvePlugins by combining resolveFarmPlugins and resolveAsyncPlugins Apr 30, 2024
@ErKeLost ErKeLost changed the title chore: Refactor resolvePlugins by combining resolveFarmPlugins and resolveAsyncPlugins refactor: resolvePlugins by combining resolveFarmPlugins and resolveAsyncPlugins Apr 30, 2024
let plugins = config.plugins ?? [];

// First, resolve any promises and flatten the array
plugins = await resolveAsyncPlugins(plugins);
Copy link
Member

Choose a reason for hiding this comment

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

We should first judge whether there is a plugins.

  if (!plugins.length) {
    return {
      rustPlugins: [],
      jsPlugins: []
    };
  }

This code should be put in front.

@@ -9,8 +9,27 @@ import merge from '../utils/merge.js';
export * from './js/index.js';
export * from './rust/index.js';

export async function resolveFarmPlugins(config: UserConfig) {
const plugins = config.plugins ?? [];
export async function resolveAsyncPlugins<T>(arr: T[]): Promise<T[]> {
Copy link
Member

Choose a reason for hiding this comment

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

This method seems to just move the position, and we should put the important method at the top of the code

@DeepeshKalura
Copy link
Author

@ErKeLost Thanks for changing the PR name, I was getting a PR linter error. I don't understand why I was getting this error. Then I saw the github actions and realised I was missing the PR tags. Maybe that was causing the error. Does there exist PR docs like better PR for this project or an explanation for PR tagging something down this line?

@ErKeLost
Copy link
Member

thanks

@ErKeLost
Copy link
Member

ErKeLost commented Apr 30, 2024

@ErKeLost Thanks for changing the PR name, I was getting a PR linter error. I don't understand why I was getting this error. Then I saw the github actions and realised I was missing the PR tags. Maybe that was causing the error. Does there exist PR docs like better PR for this project or an explanation for PR tagging something down this line?

Here are some pr title specifications, which I will add later in the contribution guide

Available types:
 - fix
 - feat
 - docs
 - style
 - refactor
 - perf
 - test
 - build
 - ci
 - chore
 - revert
 - release

This ci, I'll just run again. then its will be fixed

@@ -0,0 +1,5 @@
---
'@farmfe/core': minor
Copy link
Member

Choose a reason for hiding this comment

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

We should only release the patch version of @ farmfe/ core. You need to rerun npx changeset.

@DeepeshKalura
Copy link
Author

@ErKeLost could you also tell me docs about the npx changeset, Like what is patch or minor or major change when to use when.

@ErKeLost
Copy link
Member

ErKeLost commented May 1, 2024

@ErKeLost could you also tell me docs about the npx changeset, Like what is patch or minor or major change when to use when.

For all regular pr, we need to upgrade the patch version. Minor or major is generally not allowed. I will note it in CONTRIBUTING.md later.

After typing npx changeset, select @farmfe/core to press enter twice in a row and you will see the updated patch version.

@DeepeshKalura
Copy link
Author

@ErKeLost I am resloving the cause of falling test case in the github actions. So, I will not updating the changeset to patch until it resolves.

@ErKeLost
Copy link
Member

ErKeLost commented May 5, 2024

@DeepeshKalura hi, I updated the contribution guide. Thank you for your advice. I think what you said is very helpful, so I added a column in the document to make it more intuitive for users to see. If you think there's anything else to add, just let me know.

contribution guide

@DeepeshKalura
Copy link
Author

@ErKeLost Hello, I see your updated contribution guide feels the same to me. I gave some advice damm! I even don't know why self 😅. If I do so, it will be great that my goal begins with helping this project.

I was out for like 3 days hackathon in my college so I can't resolve this error until 11 May. If this issue is not resolved by that time then I will resolve that error and hope this PR merge Successfully.

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.

support receive Promise plugin
2 participants