Skip to content

Conversation

@9aoy
Copy link
Contributor

@9aoy 9aoy commented May 29, 2025

Summary

support get environment context via environment API.

https://rsbuild.rs/api/javascript-api/environment-api#environment-context

const { distPath, config, manifest } = environments.web.context;

console.log(distPath, config, manifest.entries);

Related Links

Checklist

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

Copilot AI review requested due to automatic review settings May 29, 2025 13:26
@netlify
Copy link

netlify bot commented May 29, 2025

Deploy Preview for rsbuild ready!

Name Link
🔨 Latest commit 04e87a0
🔍 Latest deploy log https://app.netlify.com/projects/rsbuild/deploys/683943abf478b20008938d08
😎 Deploy Preview https://deploy-preview-5334--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: 74 (no change from production)
Accessibility: 97 (no change from production)
Best Practices: 92 (no change from production)
SEO: 100 (no change from production)
PWA: 60 (no change from production)
View the detailed breakdown and full score reports

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

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for retrieving the build manifest via the Environment API by introducing a new getManifest method, updating type definitions and docs, and covering it in an end-to-end test.

  • Introduces getManifest in EnvironmentAPI types and implements it in the dev server
  • Updates both Chinese and English docs with usage examples and API details
  • Adds an E2E test to verify manifest retrieval via the Environment API

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
website/docs/zh/config/output/manifest.mdx Mention Environment API for manifest access
website/docs/en/config/output/manifest.mdx Mention Environment API for manifest access
website/docs/zh/api/javascript-api/environment-api.mdx Add getManifest API docs and type signature (Chinese)
website/docs/en/api/javascript-api/environment-api.mdx Add getManifest API docs and type signature (English)
packages/core/src/types/hooks.ts Reference Environment API in manifest context comments
packages/core/src/types/config.ts Add getManifest to EnvironmentAPI type
packages/core/src/server/devServer.ts Implement getManifest method in dev server
e2e/cases/output/manifest-environment/index.test.ts E2E test for getManifest

Copy link
Member

@chenjiahan chenjiahan left a comment

Choose a reason for hiding this comment

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

Can we use the plugin hooks to get the manifest?

See: https://rsbuild.rs/api/javascript-api/environment-api#manifest

@9aoy
Copy link
Contributor Author

9aoy commented May 29, 2025

Can we use the plugin hooks to get the manifest?

See: https://rsbuild.rs/api/javascript-api/environment-api#manifest

If we want to use plugin hooks in devServer to get webManifest, the example is as follows, which is not very convenient.

let webManifest;
api.onDevCompileDone(({ environments }) => {
  webManifest = environments.web.manifest;
});

// ...
const { } = webManifest;

@chenjiahan
Copy link
Member

Since the manifest is already in the environment context, we can expose the environment context instead of adding APIs for each context property.

const { manifest } = await environments.web.context;

console.log(manifest?.entries);

@9aoy
Copy link
Contributor Author

9aoy commented May 30, 2025

Since the manifest is already in the environment context, we can expose the environment context instead of adding APIs for each context property.

const { manifest } = await environments.web.context;

console.log(manifest?.entries);

It's also great to get manifest through context, do you mean rsbuild.context.environments ?

https://rsbuild.rs/api/javascript-api/instance#rsbuildcontext

@9aoy 9aoy changed the title feat: support get manifest via environment API feat: support get environment context via environment API May 30, 2025
@9aoy 9aoy requested a review from chenjiahan May 30, 2025 03:52
@chenjiahan chenjiahan enabled auto-merge (squash) May 30, 2025 05:37
@chenjiahan chenjiahan merged commit fb8820d into main May 30, 2025
11 checks passed
@chenjiahan chenjiahan deleted the manifest-environment-api branch May 30, 2025 05:41
@chenjiahan chenjiahan mentioned this pull request Jun 2, 2025
@chenjiahan chenjiahan mentioned this pull request Jun 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants