Skip to content

Commit

Permalink
fix: remove all exports of routes when render mode is csr (alibaba#6140)
Browse files Browse the repository at this point in the history
  • Loading branch information
ClarkXia authored Apr 11, 2023
1 parent 48c40ea commit 7b04ca7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/tricky-fans-shave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@ice/app': patch
---

fix: remove all exports of components when render mode is csr
1 change: 1 addition & 0 deletions packages/ice/src/createService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ async function createService({ rootDir, command, commandArgs }: CreateServiceOpt
rootDir,
task: platformTaskConfig,
server,
csr,
});
addWatchEvent([
/src\/?[\w*-:.$]+$/,
Expand Down
4 changes: 4 additions & 0 deletions packages/ice/src/service/ServerRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { filterAlias, getRuntimeDefination } from './serverCompiler.js';
interface InitOptions {
rootDir: string;
server: UserConfig['server'];
csr: boolean;
task: TaskConfig<Config>;
}

Expand Down Expand Up @@ -86,6 +87,7 @@ class ServerRunner extends Runner {
task,
server,
rootDir,
csr,
}: InitOptions) {
const transformPlugins = getCompilerPlugins(rootDir, {
...task.config,
Expand All @@ -94,6 +96,8 @@ class ServerRunner extends Runner {
polyfill: false,
swcOptions: {
nodeTransform: true,
// Remove all exports except pageConfig when ssr and ssg both are false.
keepExports: csr ? ['pageConfig'] : null,
compilationConfig: {
jsc: {
// https://node.green/#ES2020
Expand Down

0 comments on commit 7b04ca7

Please sign in to comment.