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: target of mf format should be web #412

Merged
merged 2 commits into from
Nov 12, 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
3 changes: 0 additions & 3 deletions examples/module-federation/mf-react-component/rslib.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,5 @@ export default defineConfig({
],
},
],
output: {
target: 'web',
},
plugins: [pluginReact()],
});
16 changes: 12 additions & 4 deletions packages/core/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,6 @@ const composeFormatConfig = ({
output: {
uniqueName: pkgJson.name as string,
},
// TODO when we provide dev mode for rslib mf format, this should be modified to as the same with config.mode
// can not set nodeEnv to false, because mf format should build shared module.
// If nodeEnv is false, the process.env.NODE_ENV in third-party packages's will not be replaced
// now we have not provide dev mode for users, so we can always set nodeEnv as 'production'
Expand All @@ -590,6 +589,9 @@ const composeFormatConfig = ({
},
},
},
output: {
target: 'web',
},
};
default:
throw new Error(`Unsupported format: ${format}`);
Expand Down Expand Up @@ -941,12 +943,17 @@ const composeDtsConfig = async (
};

const composeTargetConfig = (
target: RsbuildConfigOutputTarget = 'node',
target: RsbuildConfigOutputTarget,
format: Format,
): {
config: RsbuildConfig;
target: RsbuildConfigOutputTarget;
} => {
switch (target) {
let defaultTarget = target;
if (!defaultTarget) {
defaultTarget = format === 'mf' ? 'web' : 'node';
}
switch (defaultTarget) {
case 'web':
return {
config: {
Expand Down Expand Up @@ -986,7 +993,7 @@ const composeTargetConfig = (
// },
// };
default:
throw new Error(`Unsupported platform: ${target}`);
throw new Error(`Unsupported platform: ${defaultTarget}`);
}
};

Expand Down Expand Up @@ -1078,6 +1085,7 @@ async function composeLibRsbuildConfig(config: LibConfig, configPath: string) {
);
const { config: targetConfig, target } = composeTargetConfig(
config.output?.target,
format!,
);
const syntaxConfig = composeSyntaxConfig(target, config?.syntax);
const autoExternalConfig = composeAutoExternalConfig({
Expand Down
Loading