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: useLoader should run normally in csr when webpack build #5724

Merged
merged 1 commit into from
May 9, 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
6 changes: 6 additions & 0 deletions .changeset/happy-fans-roll.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@modern-js/runtime': patch
---

fix: useLoader should run normally in csr when webpack build
fix: useLoader 当使用 webpack 构建是,在 csr 下应该需要正常跑
14 changes: 3 additions & 11 deletions packages/runtime/plugin-runtime/src/ssr/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ export const ssrPlugin = (): CliPlugin<AppTools> => ({
return {
config() {
const appContext = api.useAppContext();
const userConfig = api.useConfigContext();

pluginsExportsUtils = createRuntimeExportsUtils(
appContext.internalDirectory,
Expand Down Expand Up @@ -93,15 +92,11 @@ export const ssrPlugin = (): CliPlugin<AppTools> => ({
// so we only use useLoader in CSR on Rspack build temporarily.
return (config: any) => {
const userConfig = api.useResolvedConfigContext();
if (isUseSSRBundle(userConfig)) {
if (isUseSSRBundle(userConfig) && checkUseStringSSR(userConfig)) {
config.plugins?.push(
path.join(__dirname, './babel-plugin-ssr-loader-id'),
);
if (checkUseStringSSR(userConfig)) {
config.plugins?.push(
require.resolve('@loadable/babel-plugin'),
);
}
config.plugins?.push(require.resolve('@loadable/babel-plugin'));
}
};
}
Expand Down Expand Up @@ -142,10 +137,7 @@ export const ssrPlugin = (): CliPlugin<AppTools> => ({
]);
}
},
babel:
isUseSSRBundle(userConfig) && checkUseStringSSR(userConfig as any)
? babelHandler
: undefined,
babel: babelHandler,
},
};
},
Expand Down
Loading