Skip to content

Commit

Permalink
fix: useLoader should run normally in csr when webpack build
Browse files Browse the repository at this point in the history
  • Loading branch information
GiveMe-A-Name committed May 9, 2024
1 parent c61af61 commit 0dbe37f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
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

0 comments on commit 0dbe37f

Please sign in to comment.