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

fix: match unexpected environment resources #5968

Merged
merged 1 commit into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/dull-comics-attack.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@modern-js/uni-builder': patch
---

fix: match unexpected environment resources when artifact with the same name in different environments

fix: 当存在同名产物时匹配到不符合预期的 environment 资源
17 changes: 17 additions & 0 deletions packages/cli/uni-builder/src/shared/plugins/environmentDefaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,23 @@ export const pluginEnvironmentDefaults = (
? mergeRsbuildConfig(compatConfig, config)
: config;
});
// ensure environment order to avoid match unexpected environment resources
// https://github.com/web-infra-dev/rsbuild/issues/2956
api.modifyRsbuildConfig({
handler: config => {
const environmentNameOrder = ['web', 'node', 'serviceWorker'];

config.environments = Object.fromEntries(
Object.entries(config.environments!).sort((a1, a2) =>
environmentNameOrder.includes(a1[0])
? environmentNameOrder.indexOf(a1[0]) -
environmentNameOrder.indexOf(a2[0])
: 1,
),
);
},
order: 'post',
});
api.modifyEnvironmentConfig(async (config, { name }) => {
config.output.overrideBrowserslist ??= await getBrowserslistWithDefault(
api.context.rootPath,
Expand Down
Loading
Loading