Skip to content

Commit 0b581a4

Browse files
fix: remove ssr.preload config (#6062)
1 parent a56dcdf commit 0b581a4

File tree

10 files changed

+9
-307
lines changed

10 files changed

+9
-307
lines changed

.changeset/serious-mails-try.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@modern-js/app-tools': patch
3+
'@modern-js/server-core': patch
4+
---
5+
6+
fix: remove ssr.preload config
7+
fix: 移除 ssr.preload 配置

packages/server/core/src/types/config/server.ts

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,34 +11,11 @@ type Route =
1111
};
1212
export type Routes = Record<string, Route>;
1313

14-
type PreloadLink = { url: string; as?: string; rel?: string };
15-
type PreloadInclude = Array<string | PreloadLink>;
16-
interface PreloadAttributes {
17-
script?: Record<string, boolean | string>;
18-
style?: Record<string, boolean | string>;
19-
image?: Record<string, boolean | string>;
20-
font?: Record<string, boolean | string>;
21-
}
22-
export type SSRPreload = {
23-
/** Include external preload links to enhance the page's performance by preloading additional resources. */
24-
include?: PreloadInclude;
25-
26-
/** Utilize string matching to exclude specific preload links. */
27-
exclude?: RegExp | string;
28-
29-
/** Disable preload when the User-Agent is matched. */
30-
userAgentFilter?: RegExp | string;
31-
32-
/** Include additional attributes to the Header Link. */
33-
attributes?: PreloadAttributes;
34-
};
35-
3614
export type SSR =
3715
| boolean
3816
| {
3917
forceCSR?: boolean;
4018
mode?: SSRMode;
41-
preload?: boolean | SSRPreload;
4219
inlineScript?: boolean;
4320
disablePrerender?: boolean;
4421
unsafeHeaders?: string[];

packages/solutions/app-tools/src/builder/shared/builderPlugins/adapterSSR.ts

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,7 @@ export const builderPluginAdapterSSR = <B extends Bundler>(
3535
server: {
3636
// the http-compression can't handler stream http.
3737
// so we disable compress when user use stream ssr temporarily.
38-
compress:
39-
isStreamingSSR(normalizedConfig) || isSSRPreload(normalizedConfig)
40-
? false
41-
: undefined,
38+
compress: isStreamingSSR(normalizedConfig) ? false : undefined,
4239
},
4340
});
4441
});
@@ -91,20 +88,6 @@ export const builderPluginAdapterSSR = <B extends Bundler>(
9188
},
9289
});
9390

94-
const isSSRPreload = (userConfig: AppNormalizedConfig<'shared'>) => {
95-
const {
96-
server: { ssr, ssrByEntries },
97-
} = userConfig;
98-
99-
const checkUsePreload = (ssr?: ServerUserConfig['ssr']) =>
100-
typeof ssr === 'object' && Boolean(ssr.preload);
101-
102-
return (
103-
checkUsePreload(ssr) ||
104-
Object.values(ssrByEntries || {}).some(ssr => checkUsePreload(ssr))
105-
);
106-
};
107-
10891
const isStreamingSSR = (userConfig: AppNormalizedConfig<'shared'>): boolean => {
10992
const isStreaming = (ssr: ServerUserConfig['ssr']) =>
11093
ssr && typeof ssr === 'object' && ssr.mode === 'stream';

packages/solutions/app-tools/src/plugins/analyze/getServerRoutes.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,7 @@ const collectHtmlRoutes = (
145145
const isWorker = Boolean(workerSSR);
146146
// The http would open stream when stream ssr or enable ssr.preload
147147
const isStream =
148-
typeof entryOptions === 'object' &&
149-
(entryOptions.mode === 'stream' || Boolean(entryOptions.preload));
148+
typeof entryOptions === 'object' && entryOptions.mode === 'stream';
150149
const { resHeaders } = routes?.[entryName] || ({} as any);
151150

152151
let route: ServerRoute | ServerRoute[] = {

pnpm-lock.yaml

Lines changed: 0 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/integration/ssr/fixtures/preload/modern.config.ts

Lines changed: 0 additions & 24 deletions
This file was deleted.

tests/integration/ssr/fixtures/preload/package.json

Lines changed: 0 additions & 14 deletions
This file was deleted.

tests/integration/ssr/fixtures/preload/src/routes/index.css

Lines changed: 0 additions & 117 deletions
This file was deleted.

tests/integration/ssr/fixtures/preload/src/routes/layout.jsx

Lines changed: 0 additions & 10 deletions
This file was deleted.

tests/integration/ssr/fixtures/preload/src/routes/page.jsx

Lines changed: 0 additions & 84 deletions
This file was deleted.

0 commit comments

Comments
 (0)