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: use environment param instead of context.environment #2721

Merged
merged 9 commits into from
Jun 28, 2024

Conversation

9aoy
Copy link
Collaborator

@9aoy 9aoy commented Jun 28, 2024

Summary

remove api.context.environments, use environment param instead.

  • add environment param into modifyBundlerChain / modifyRspackConfig / modifyHTMLTags hooks
  • add environments param into onAfterBuild / onAfterCreateCompiler / onBeforeStartDevServer / onBeforeBuild / onAfterBuild hooks
type EnvironmentContext = {
  index: number;
  name: string;
  entry: RsbuildEntry;
  htmlPaths: Record<string, string>;
  distPath: string;
  browserslist: string[];
  tsconfigPath?: string;
  config: NormalizedEnvironmentConfig;
};


type ModifyBundlerChainUtils = {
  environment: string;
  environment: EnvironmentContext;
};
const myPlugin = () => ({
  setup: (api) => {
    api.modifyBundlerChain((chain, utils) => {
-      const { distPath } = api.context.environments[utils.environment];
+      const { distPath } = utils.environment;

-      const environmentConfig = api.getNormalizedConfig({ environment });
+      const environmentConfig = environment.config;
    });
  },
});

Related Links

#2620

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copy link

netlify bot commented Jun 28, 2024

Deploy Preview for rsbuild ready!

Name Link
🔨 Latest commit f9efb04
🔍 Latest deploy log https://app.netlify.com/sites/rsbuild/deploys/667e6cf2bd48fb0008be6868
😎 Deploy Preview https://deploy-preview-2721--rsbuild.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 79 (🔴 down 9 from production)
Accessibility: 97 (no change from production)
Best Practices: 100 (no change from production)
SEO: 92 (no change from production)
PWA: -
View the detailed breakdown and full score reports

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

packages/compat/plugin-swc/src/plugin.ts Show resolved Hide resolved
packages/shared/src/types/hooks.ts Outdated Show resolved Hide resolved
packages/compat/plugin-swc/src/plugin.ts Outdated Show resolved Hide resolved
packages/core/src/createContext.ts Outdated Show resolved Hide resolved
packages/shared/src/types/hooks.ts Outdated Show resolved Hide resolved
@9aoy 9aoy changed the title chore: use environment param instead of context.environment refactor: use environment param instead of context.environment Jun 28, 2024
@9aoy 9aoy enabled auto-merge (squash) June 28, 2024 07:57
@9aoy 9aoy merged commit d807007 into main Jun 28, 2024
10 checks passed
@9aoy 9aoy deleted the fix/environment-context branch June 28, 2024 08:05
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.

2 participants