@rspress/core 2.0.17 → 2.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/0~execa.js +1 -1
- package/dist/{7448.js → 3553.js} +2 -2
- package/dist/{8629.js → 5871.js} +3 -3
- package/dist/cli/index.js +2 -2
- package/dist/config/loadConfigFile.js +1 -1
- package/dist/eject-theme/components/DocContent/docComponents/title.tsx +1 -1
- package/dist/eject-theme/components/HomeFeature/index.scss +1 -0
- package/dist/eject-theme/components/HomeFeature/index.tsx +1 -1
- package/dist/eject-theme/components/HoverGroup/index.scss +9 -0
- package/dist/eject-theme/components/Llms/LlmsHiddenHint.test.tsx +23 -0
- package/dist/eject-theme/components/Llms/LlmsHiddenHint.tsx +15 -0
- package/dist/eject-theme/components/Llms/LlmsOpenRow.tsx +51 -64
- package/dist/eject-theme/components/Llms/LlmsViewOptions.tsx +65 -51
- package/dist/eject-theme/components/Llms/index.tsx +6 -1
- package/dist/eject-theme/components/Outline/index.tsx +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/node/PluginDriver.js +1 -1
- package/dist/node/auto-nav-sidebar/index.js +1 -1
- package/dist/node/auto-nav-sidebar/locales.js +1 -1
- package/dist/node/auto-nav-sidebar/normalize.js +1 -1
- package/dist/node/auto-nav-sidebar/utils.js +1 -1
- package/dist/node/auto-nav-sidebar/walk.js +1 -1
- package/dist/node/constants.js +1 -1
- package/dist/node/eject.js +1 -1
- package/dist/node/initRsbuild.js +16 -5
- package/dist/node/llms.d.ts +3 -0
- package/dist/node/llms.js +8 -0
- package/dist/node/route/RoutePage.js +5 -3
- package/dist/node/route/RouteService.js +8 -3
- package/dist/node/route/extractPageData.js +1 -1
- package/dist/node/route/normalizeRoutePath.js +1 -1
- package/dist/node/route/routeChunkAssets.d.ts +15 -0
- package/dist/node/route/routeChunkAssets.js +56 -0
- package/dist/node/runtimeModule/i18n.js +1 -1
- package/dist/node/runtimeModule/pageData/createPageData.js +1 -1
- package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +1 -1
- package/dist/node/runtimeModule/searchHooks.js +1 -1
- package/dist/node/runtimeModule/siteData/createSiteData.js +1 -1
- package/dist/node/runtimeModule/siteData/normalizeThemeConfig.js +1 -1
- package/dist/node/runtimeModule/siteData/rsbuildPlugin.js +1 -1
- package/dist/node/serve.js +1 -1
- package/dist/node/ssg/alternateLinks.d.ts +7 -0
- package/dist/node/ssg/alternateLinks.js +40 -0
- package/dist/node/ssg/htmlFile.js +1 -1
- package/dist/node/ssg/renderHtmlTemplate.d.ts +3 -1
- package/dist/node/ssg/renderHtmlTemplate.js +25 -3
- package/dist/node/ssg/renderPage.d.ts +3 -1
- package/dist/node/ssg/renderPage.js +3 -3
- package/dist/node/ssg/renderPageWorker.js +4 -4
- package/dist/node/ssg/renderPages.d.ts +3 -2
- package/dist/node/ssg/renderPages.js +15 -10
- package/dist/node/ssg/rsbuildPluginCSR.d.ts +3 -1
- package/dist/node/ssg/rsbuildPluginCSR.js +2 -2
- package/dist/node/ssg/rsbuildPluginSSG.d.ts +3 -1
- package/dist/node/ssg/rsbuildPluginSSG.js +3 -3
- package/dist/node/ssg/ssgEnv.js +1 -1
- package/dist/node/ssg-md/llms/emitLlmsTxt.js +2 -2
- package/dist/node/ssg-md/llms/llmsTxt.d.ts +2 -2
- package/dist/node/ssg-md/llms/llmsTxt.js +49 -35
- package/dist/node/ssg-md/renderPage.js +1 -1
- package/dist/node/ssg-md/renderPages.js +2 -2
- package/dist/node/ssg-md/rsbuildPluginSSGMD.js +1 -1
- package/dist/node/utils/checkLanguageParity.js +1 -1
- package/dist/node/utils/createHash.d.ts +1 -1
- package/dist/node/utils/createHash.js +3 -3
- package/dist/node/utils/flattenMdxContent.js +1 -1
- package/dist/node/utils/getPageKey.js +1 -1
- package/dist/node/utils/reactAlias.js +1 -1
- package/dist/runtime/App.js +2 -0
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/index.js +1 -1
- package/dist/runtime/utils.d.ts +2 -1
- package/dist/runtime/utils.js +5 -2
- package/dist/theme/assets/anthropic.js +15 -0
- package/dist/theme/assets/open-in-chat.js +19 -0
- package/dist/theme/assets/openai.js +15 -0
- package/dist/theme/components/DocContent/docComponents/title.js +1 -1
- package/dist/theme/components/HomeFeature/index.css +1 -0
- package/dist/theme/components/HomeFeature/index.js +32 -34
- package/dist/theme/components/HoverGroup/index.css +7 -0
- package/dist/theme/components/Llms/LlmsHiddenHint.d.ts +1 -0
- package/dist/theme/components/Llms/LlmsHiddenHint.js +18 -0
- package/dist/theme/components/Llms/LlmsOpenRow.js +31 -57
- package/dist/theme/components/Llms/LlmsViewOptions.d.ts +6 -4
- package/dist/theme/components/Llms/LlmsViewOptions.js +28 -45
- package/dist/theme/components/Llms/index.d.ts +2 -1
- package/dist/theme/components/Llms/index.js +1 -0
- package/dist/theme/components/Outline/index.js +1 -1
- package/dist/theme/icons.d.ts +4 -1
- package/dist/theme/icons.js +8 -2
- package/dist/theme/index.d.ts +1 -1
- package/dist/theme/index.js +1 -1
- package/package.json +4 -4
- /package/dist/{8629.js.LICENSE.txt → 5871.js.LICENSE.txt} +0 -0
package/dist/node/initRsbuild.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { external_node_process_cwd, node_path, fileURLToPath, addTrailingSlash, PLUGIN_REACT_NAME, removeTrailingSlash, normalizeDarkMode, pluginVirtualModule, pluginReact, createRequire, MDX_OR_MD_REGEXP } from "../
|
|
1
|
+
import { external_node_process_cwd, node_path, fileURLToPath, addTrailingSlash, PLUGIN_REACT_NAME, removeTrailingSlash, normalizeDarkMode, pluginVirtualModule, pluginReact, createRequire, MDX_OR_MD_REGEXP } from "../5871.js";
|
|
2
2
|
import { createError } from "./utils/error.js";
|
|
3
3
|
import { CSR_CLIENT_ENTRY, SSR_CLIENT_ENTRY, OUTPUT_DIR, SSG_MD_SERVER_ENTRY, NODE_SSG_BUNDLE_FOLDER, isProduction, PACKAGE_ROOT, SSR_SERVER_ENTRY, TEMPLATE_PATH, NODE_SSG_MD_BUNDLE_FOLDER, DEFAULT_THEME, NODE_SSG_MD_BUNDLE_NAME, getInlineThemeScript, DEFAULT_TITLE, NODE_SSG_BUNDLE_NAME } from "./constants.js";
|
|
4
|
+
import { isLlmsUIEnabled, isLlmsHintEnabled } from "./llms.js";
|
|
5
|
+
import { RouteChunkAssetsPlugin } from "./route/routeChunkAssets.js";
|
|
4
6
|
import { hintBuilderPluginsBreakingChange, hintThemeBreakingChange } from "./logger/hint.js";
|
|
5
7
|
import { resolveReactRouterDomAlias, resolveReactRenderToMarkdownAlias, resolveReactAlias } from "./utils/reactAlias.js";
|
|
6
8
|
import { rsbuildPluginDocVM } from "./runtimeModule/pageData/rsbuildPlugin.js";
|
|
@@ -14,7 +16,7 @@ import { siteDataVMPlugin } from "./runtimeModule/siteData/rsbuildPlugin.js";
|
|
|
14
16
|
import { rsbuildPluginSSG } from "./ssg/rsbuildPluginSSG.js";
|
|
15
17
|
import { rsbuildPluginCSR } from "./ssg/rsbuildPluginCSR.js";
|
|
16
18
|
import { rsbuildPluginSSGMD } from "./ssg-md/rsbuildPluginSSGMD.js";
|
|
17
|
-
import { package_namespaceObject } from "../
|
|
19
|
+
import { package_namespaceObject } from "../3553.js";
|
|
18
20
|
function isPluginIncluded(config, pluginName) {
|
|
19
21
|
return Boolean(config.builderConfig?.plugins?.some((plugin)=>plugin && plugin.name === pluginName));
|
|
20
22
|
}
|
|
@@ -39,7 +41,10 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
39
41
|
const CUSTOM_THEME_DIR = node_path.isAbsolute(config.themeDir) ? config.themeDir : node_path.join(external_node_process_cwd(), config.themeDir);
|
|
40
42
|
const outDir = config?.outDir ?? OUTPUT_DIR;
|
|
41
43
|
const base = config?.base ?? '/';
|
|
44
|
+
const enableLlmsUI = isLlmsUIEnabled(config);
|
|
45
|
+
const enableLlmsHint = isLlmsHintEnabled(config, enableSSG);
|
|
42
46
|
const assetPrefix = isProduction() ? addTrailingSlash(config?.builderConfig?.output?.assetPrefix ?? base) : '/';
|
|
47
|
+
const routeChunkAssets = new RouteChunkAssetsPlugin(routeService);
|
|
43
48
|
const normalizeIcon = (icon)=>{
|
|
44
49
|
if (!icon) return;
|
|
45
50
|
icon = icon.toString();
|
|
@@ -86,10 +91,12 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
86
91
|
}),
|
|
87
92
|
enableSSG && config.ssg ? rsbuildPluginSSG({
|
|
88
93
|
routeService,
|
|
89
|
-
config
|
|
94
|
+
config,
|
|
95
|
+
routeChunkAssets
|
|
90
96
|
}) : rsbuildPluginCSR({
|
|
91
97
|
routeService,
|
|
92
|
-
config
|
|
98
|
+
config,
|
|
99
|
+
routeChunkAssets
|
|
93
100
|
}),
|
|
94
101
|
enableSSG && config.llms ? rsbuildPluginSSGMD({
|
|
95
102
|
routeService,
|
|
@@ -158,7 +165,8 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
158
165
|
],
|
|
159
166
|
define: {
|
|
160
167
|
'process.env.TEST': JSON.stringify(process.env.TEST),
|
|
161
|
-
'
|
|
168
|
+
'import.meta.env.ENABLE_LLMS_UI': JSON.stringify(enableLlmsUI),
|
|
169
|
+
'import.meta.env.ENABLE_LLMS_HINT': JSON.stringify(enableLlmsHint)
|
|
162
170
|
}
|
|
163
171
|
},
|
|
164
172
|
performance: {
|
|
@@ -271,6 +279,9 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
271
279
|
},
|
|
272
280
|
tools: {
|
|
273
281
|
rspack: {
|
|
282
|
+
plugins: [
|
|
283
|
+
routeChunkAssets
|
|
284
|
+
],
|
|
274
285
|
node: {
|
|
275
286
|
__dirname: 'mock',
|
|
276
287
|
__filename: 'mock'
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
function isLlmsUIEnabled(config) {
|
|
2
|
+
return Boolean(config.themeConfig?.llmsUI ?? config.llms);
|
|
3
|
+
}
|
|
4
|
+
function isLlmsHintEnabled(config, enableSSG) {
|
|
5
|
+
const llmsUI = config.themeConfig?.llmsUI;
|
|
6
|
+
return enableSSG && false !== config.ssg && isLlmsUIEnabled(config) && ('object' != typeof llmsUI || false !== llmsUI.injectLlmsHint);
|
|
7
|
+
}
|
|
8
|
+
export { isLlmsHintEnabled, isLlmsUIEnabled };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { node_path } from "../../
|
|
1
|
+
import { node_path } from "../../5871.js";
|
|
2
2
|
import { RouteService } from "./RouteService.js";
|
|
3
3
|
import { normalizePath, slash } from "../utils/normalizePath.js";
|
|
4
4
|
import { getPageKey } from "../utils/getPageKey.js";
|
|
@@ -23,9 +23,10 @@ class RoutePage {
|
|
|
23
23
|
}
|
|
24
24
|
static generateRouteMeta(routePath, filepath, docDir) {
|
|
25
25
|
const routeService = RouteService.getInstance();
|
|
26
|
-
const { routePath: normalizedPath, lang, version } = routeService.normalizeRoutePath(routePath);
|
|
26
|
+
const { routePath: normalizedPath, lang, pureRoutePath, version } = routeService.normalizeRoutePath(routePath);
|
|
27
27
|
return {
|
|
28
28
|
routePath: normalizedPath,
|
|
29
|
+
pureRoutePath,
|
|
29
30
|
absolutePath: normalizePath(filepath),
|
|
30
31
|
relativePath: absolutePathToRelativePath(filepath, docDir),
|
|
31
32
|
pageName: getPageKey(routePath),
|
|
@@ -39,11 +40,12 @@ function absolutePathToRelativePath(absolutePath, docsDir) {
|
|
|
39
40
|
}
|
|
40
41
|
function absolutePathToRouteMeta(absolutePath, docsDir, routeService = RouteService.getInstance()) {
|
|
41
42
|
const relativePath = absolutePathToRelativePath(absolutePath, docsDir);
|
|
42
|
-
const { lang, routePath, version } = routeService.normalizeRoutePath(relativePath);
|
|
43
|
+
const { lang, pureRoutePath, routePath, version } = routeService.normalizeRoutePath(relativePath);
|
|
43
44
|
return {
|
|
44
45
|
pageName: getPageKey(relativePath),
|
|
45
46
|
absolutePath,
|
|
46
47
|
lang,
|
|
48
|
+
pureRoutePath,
|
|
47
49
|
version,
|
|
48
50
|
routePath,
|
|
49
51
|
relativePath
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { RSPRESS_TEMP_DIR, node_path, removeTrailingSlash, promises, addTrailingSlash, DEFAULT_PAGE_EXTENSIONS, glob } from "../../
|
|
1
|
+
import { RSPRESS_TEMP_DIR, node_path, removeTrailingSlash, promises, addTrailingSlash, DEFAULT_PAGE_EXTENSIONS, glob } from "../../5871.js";
|
|
2
2
|
import { RoutePage, absolutePathToRoutePath, absolutePathToRelativePath } from "./RoutePage.js";
|
|
3
3
|
import { createError } from "../utils/error.js";
|
|
4
|
+
import { getRouteChunkName } from "./routeChunkAssets.js";
|
|
4
5
|
import { getRoutePathParts, normalizeRoutePath, splitRoutePathParts } from "./normalizeRoutePath.js";
|
|
5
6
|
class RouteService {
|
|
6
7
|
routeData = new Map();
|
|
@@ -152,12 +153,16 @@ class RouteService {
|
|
|
152
153
|
return `
|
|
153
154
|
import React from 'react';
|
|
154
155
|
import { lazyWithPreload } from "react-lazy-with-preload";
|
|
155
|
-
${routeMeta.map((route, index)
|
|
156
|
+
${routeMeta.map((route, index)=>{
|
|
157
|
+
const chunkName = getRouteChunkName(route);
|
|
158
|
+
return `const loadRoute${index} = () => import(/* webpackChunkName: "${chunkName}" */ '${route.absolutePath}')
|
|
159
|
+
const Route${index} = lazyWithPreload(loadRoute${index})`;
|
|
160
|
+
}).join('\n')}
|
|
156
161
|
export const routes = [
|
|
157
162
|
${routeMeta.map((route, index)=>{
|
|
158
163
|
const preload = `async () => {
|
|
159
164
|
await Route${index}.preload();
|
|
160
|
-
return
|
|
165
|
+
return loadRoute${index}();
|
|
161
166
|
}`;
|
|
162
167
|
const component = `Route${index}`;
|
|
163
168
|
return `{ path: '${route.routePath}', element: React.createElement(${component}), filePath: '${route.relativePath}', preload: ${preload}, lang: '${route.lang}', version: '${route.version}' }`;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { unified, node_path, promises, loadFrontMatter, remove, remark_gfm, MDX_OR_MD_REGEXP, remark_parse } from "../../
|
|
1
|
+
import { unified, node_path, promises, loadFrontMatter, remove, remark_gfm, MDX_OR_MD_REGEXP, remark_parse } from "../../5871.js";
|
|
2
2
|
import { applyReplaceRules } from "../utils/applyReplaceRules.js";
|
|
3
3
|
import { flattenMdxContent } from "../utils/flattenMdxContent.js";
|
|
4
4
|
import { importStatementRegex } from "../constants.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { addTrailingSlash, DEFAULT_PAGE_EXTENSIONS, addLeadingSlash } from "../../
|
|
1
|
+
import { addTrailingSlash, DEFAULT_PAGE_EXTENSIONS, addLeadingSlash } from "../../5871.js";
|
|
2
2
|
const getRoutePathParts = (relativePath, lang, version, langs, versions)=>{
|
|
3
3
|
const [versionPart, langPart, purePath] = splitRoutePathParts(relativePath, lang, version, langs, versions);
|
|
4
4
|
return [
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Rspack } from '@rsbuild/core';
|
|
2
|
+
import type { RouteMeta } from '@rspress/shared';
|
|
3
|
+
import type { RouteService } from './RouteService.js';
|
|
4
|
+
export interface RouteChunkAssetsManifest {
|
|
5
|
+
assetPrefix: string;
|
|
6
|
+
assets: Record<string, string[]>;
|
|
7
|
+
}
|
|
8
|
+
export declare function getRouteChunkName(route: RouteMeta): string;
|
|
9
|
+
export declare class RouteChunkAssetsPlugin implements Rspack.RspackPluginInstance {
|
|
10
|
+
#private;
|
|
11
|
+
private readonly routeService;
|
|
12
|
+
constructor(routeService: RouteService);
|
|
13
|
+
apply(compiler: Rspack.Compiler): void;
|
|
14
|
+
getManifest(): RouteChunkAssetsManifest;
|
|
15
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { createHash } from "../utils/createHash.js";
|
|
2
|
+
const PLUGIN_NAME = 'RspressRouteChunkAssetsPlugin';
|
|
3
|
+
const JAVASCRIPT_ASSET_REGEXP = /\.[cm]?js$/;
|
|
4
|
+
const ROUTE_CHUNK_HASH_LENGTH = 12;
|
|
5
|
+
function getRouteChunkName(route) {
|
|
6
|
+
return `route-${createHash(route.relativePath, ROUTE_CHUNK_HASH_LENGTH)}`;
|
|
7
|
+
}
|
|
8
|
+
class RouteChunkAssetsPlugin {
|
|
9
|
+
routeService;
|
|
10
|
+
#assetPrefix = '/';
|
|
11
|
+
#chunks = new Map();
|
|
12
|
+
constructor(routeService){
|
|
13
|
+
this.routeService = routeService;
|
|
14
|
+
}
|
|
15
|
+
apply(compiler) {
|
|
16
|
+
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation)=>{
|
|
17
|
+
this.#assetPrefix = 'string' == typeof compilation.outputOptions.publicPath ? compilation.outputOptions.publicPath : '/';
|
|
18
|
+
this.#chunks.clear();
|
|
19
|
+
const routePathsByChunkName = new Map();
|
|
20
|
+
for (const route of this.routeService.getRoutes()){
|
|
21
|
+
const chunkName = getRouteChunkName(route);
|
|
22
|
+
const routePaths = routePathsByChunkName.get(chunkName) ?? [];
|
|
23
|
+
routePaths.push(route.routePath);
|
|
24
|
+
routePathsByChunkName.set(chunkName, routePaths);
|
|
25
|
+
}
|
|
26
|
+
compilation.hooks.chunkAsset.tap(PLUGIN_NAME, (chunk)=>{
|
|
27
|
+
if (!chunk.name) return;
|
|
28
|
+
const routePaths = routePathsByChunkName.get(chunk.name);
|
|
29
|
+
if (!routePaths) return;
|
|
30
|
+
for (const routePath of routePaths){
|
|
31
|
+
const chunks = this.#chunks.get(routePath) ?? new Set();
|
|
32
|
+
chunks.add(chunk);
|
|
33
|
+
this.#chunks.set(routePath, chunks);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
getManifest() {
|
|
39
|
+
return {
|
|
40
|
+
assetPrefix: this.#assetPrefix,
|
|
41
|
+
assets: Object.fromEntries([
|
|
42
|
+
...this.#chunks
|
|
43
|
+
].map(([routePath, chunks])=>{
|
|
44
|
+
const assets = new Set();
|
|
45
|
+
for (const chunk of chunks)for (const filename of chunk.files)if (JAVASCRIPT_ASSET_REGEXP.test(filename)) assets.add(filename);
|
|
46
|
+
return [
|
|
47
|
+
routePath,
|
|
48
|
+
[
|
|
49
|
+
...assets
|
|
50
|
+
]
|
|
51
|
+
];
|
|
52
|
+
}))
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
export { RouteChunkAssetsPlugin, getRouteChunkName };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __webpack_require__ } from "../../0~rslib-runtime.js";
|
|
2
2
|
import "../../4538.js";
|
|
3
|
-
import { createRequire, join, logger } from "../../
|
|
3
|
+
import { createRequire, join, logger } from "../../5871.js";
|
|
4
4
|
import { DEFAULT_I18N_TEXT } from "./DEFAULT_I18N_TEXT.js";
|
|
5
5
|
import { createError } from "../utils/error.js";
|
|
6
6
|
import { pathExists } from "../utils/fs.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SEARCH_INDEX_NAME, groupBy } from "../../../
|
|
1
|
+
import { SEARCH_INDEX_NAME, groupBy } from "../../../5871.js";
|
|
2
2
|
import { extractPageData } from "../../route/extractPageData.js";
|
|
3
3
|
import { createHash } from "../../utils/createHash.js";
|
|
4
4
|
function deletePrivateField(obj) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { logger, pluginVirtualModule } from "../../../
|
|
1
|
+
import { logger, pluginVirtualModule } from "../../../5871.js";
|
|
2
2
|
import { createPageData } from "./createPageData.js";
|
|
3
3
|
const rsbuildPluginDocVM = async ({ config, userDocRoot, routeService, pluginDriver })=>{
|
|
4
4
|
const ref = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getIconUrlPath } from "../../../
|
|
1
|
+
import { getIconUrlPath } from "../../../5871.js";
|
|
2
2
|
import { normalizeThemeConfig } from "./normalizeThemeConfig.js";
|
|
3
3
|
async function createSiteData(userConfig) {
|
|
4
4
|
const tempSearchObj = Object.assign({}, userConfig.search);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isExternalUrl, slash, addLeadingSlash, normalizeHref } from "../../../
|
|
1
|
+
import { isExternalUrl, slash, addLeadingSlash, normalizeHref } from "../../../5871.js";
|
|
2
2
|
import { getI18nData } from "../i18n.js";
|
|
3
3
|
import { applyReplaceRules } from "../../utils/applyReplaceRules.js";
|
|
4
4
|
async function normalizeThemeConfig(docConfig) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isProduction, logger } from "../../../
|
|
1
|
+
import { isProduction, logger } from "../../../5871.js";
|
|
2
2
|
import { modifyConfigWithAutoNavSide } from "../../auto-nav-sidebar/index.js";
|
|
3
3
|
import { createSiteData } from "./createSiteData.js";
|
|
4
4
|
const siteDataVMPlugin = (context)=>{
|
package/dist/node/serve.js
CHANGED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type RouteMeta, type UserConfig } from '@rspress/shared';
|
|
2
|
+
export interface AlternateLink {
|
|
3
|
+
href: string;
|
|
4
|
+
hrefLang: string;
|
|
5
|
+
}
|
|
6
|
+
export type AlternateLinksByRoute = Partial<Record<string, AlternateLink[]>>;
|
|
7
|
+
export declare function createAlternateLinksByRoute(routes: RouteMeta[], config: UserConfig): AlternateLinksByRoute;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { normalizeHref, removeTrailingSlash, addLeadingSlash, normalizePosixPath, withSiteOrigin } from "../../5871.js";
|
|
2
|
+
function createAlternateLinksByRoute(routes, config) {
|
|
3
|
+
const routeGroups = new Map();
|
|
4
|
+
for (const route of routes){
|
|
5
|
+
if (!route.lang) continue;
|
|
6
|
+
const groupKey = JSON.stringify([
|
|
7
|
+
route.version,
|
|
8
|
+
route.pureRoutePath
|
|
9
|
+
]);
|
|
10
|
+
const routeGroup = routeGroups.get(groupKey) ?? [];
|
|
11
|
+
routeGroup.push(route);
|
|
12
|
+
routeGroups.set(groupKey, routeGroup);
|
|
13
|
+
}
|
|
14
|
+
const locales = config.locales ?? config.themeConfig?.locales ?? [];
|
|
15
|
+
const localeOrder = new Map(locales.map(({ lang }, index)=>[
|
|
16
|
+
lang,
|
|
17
|
+
index
|
|
18
|
+
]));
|
|
19
|
+
const alternateLinksByRoute = {};
|
|
20
|
+
for (const routeGroup of routeGroups.values()){
|
|
21
|
+
const routesByLang = new Map(routeGroup.map((route)=>[
|
|
22
|
+
route.lang,
|
|
23
|
+
route
|
|
24
|
+
]));
|
|
25
|
+
if (routesByLang.size < 2) continue;
|
|
26
|
+
const alternateRoutes = Array.from(routesByLang.values()).sort((a, b)=>(localeOrder.get(a.lang) ?? Number.MAX_SAFE_INTEGER) - (localeOrder.get(b.lang) ?? Number.MAX_SAFE_INTEGER) || a.lang.localeCompare(b.lang));
|
|
27
|
+
const alternateLinks = alternateRoutes.map((route)=>({
|
|
28
|
+
href: getRouteHref(route.routePath, config),
|
|
29
|
+
hrefLang: route.lang.replaceAll('_', '-')
|
|
30
|
+
}));
|
|
31
|
+
for (const route of alternateRoutes)alternateLinksByRoute[route.routePath] = alternateLinks;
|
|
32
|
+
}
|
|
33
|
+
return alternateLinksByRoute;
|
|
34
|
+
}
|
|
35
|
+
function getRouteHref(routePath, config) {
|
|
36
|
+
const normalizedHref = normalizeHref(routePath, config.route?.cleanUrls ?? false);
|
|
37
|
+
const normalizedBase = removeTrailingSlash(addLeadingSlash(normalizePosixPath(config.base ?? '/')));
|
|
38
|
+
return withSiteOrigin(`${normalizedBase}${normalizedHref}`, config.siteOrigin);
|
|
39
|
+
}
|
|
40
|
+
export { createAlternateLinksByRoute };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { external_node_path_resolve, relative, isAbsolute } from "../../
|
|
1
|
+
import { external_node_path_resolve, relative, isAbsolute } from "../../3553.js";
|
|
2
2
|
const routePath2HtmlFileName = (routePath)=>{
|
|
3
3
|
let fileName = routePath;
|
|
4
4
|
fileName = fileName.endsWith('/') ? `${routePath}index.html` : `${routePath}.html`;
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
import type { RouteMeta, UserConfig } from '@rspress/shared';
|
|
2
|
-
|
|
2
|
+
import type { RouteChunkAssetsManifest } from '../route/routeChunkAssets.js';
|
|
3
|
+
import type { AlternateLink } from './alternateLinks.js';
|
|
4
|
+
export declare function renderHtmlTemplate(htmlTemplate: string, head: UserConfig['head'], route: RouteMeta, appHtml?: string, alternateLinks?: AlternateLink[], routeChunkAssets?: RouteChunkAssetsManifest): Promise<string>;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { posix } from "../../3553.js";
|
|
1
2
|
import { META_GENERATOR, RSPRESS_VERSION, APP_HTML_MARKER, HEAD_MARKER } from "../constants.js";
|
|
3
|
+
import { routePath2HtmlFileName } from "./htmlFile.js";
|
|
2
4
|
import { createError } from "../utils/error.js";
|
|
3
5
|
async function renderConfigHead(head, route) {
|
|
4
6
|
if (!isRouteMeta(route)) return '';
|
|
@@ -14,18 +16,38 @@ async function renderConfigHead(head, route) {
|
|
|
14
16
|
return `<${head[0]} ${renderAttrs(head[1])}>`;
|
|
15
17
|
}).join('');
|
|
16
18
|
}
|
|
17
|
-
async function renderHtmlTemplate(htmlTemplate, head, route, appHtml = '') {
|
|
19
|
+
async function renderHtmlTemplate(htmlTemplate, head, route, appHtml = '', alternateLinks = [], routeChunkAssets) {
|
|
20
|
+
const alternateLinkTags = alternateLinks.map(({ href, hrefLang })=>`<link ${renderAttrs({
|
|
21
|
+
rel: 'alternate',
|
|
22
|
+
hreflang: hrefLang,
|
|
23
|
+
href
|
|
24
|
+
})}>`).join('');
|
|
25
|
+
const routePreloadLinks = renderRoutePreloadLinks(route, routeChunkAssets);
|
|
18
26
|
const replacedHtmlTemplate = htmlTemplate.replace(APP_HTML_MARKER, ()=>appHtml).replace(META_GENERATOR, ()=>`<meta name="generator" content="Rspress v${RSPRESS_VERSION}">`).replace(HEAD_MARKER, [
|
|
19
|
-
|
|
27
|
+
routePreloadLinks,
|
|
28
|
+
await renderConfigHead(head, route),
|
|
29
|
+
alternateLinkTags
|
|
20
30
|
].join(''));
|
|
21
31
|
return replacedHtmlTemplate;
|
|
22
32
|
}
|
|
33
|
+
function renderRoutePreloadLinks(route, manifest) {
|
|
34
|
+
if (!manifest) return '';
|
|
35
|
+
const assets = manifest.assets[route.routePath];
|
|
36
|
+
if (!assets) return '';
|
|
37
|
+
return assets.map((asset)=>{
|
|
38
|
+
const href = 'auto' === manifest.assetPrefix ? posix.relative(posix.dirname(routePath2HtmlFileName(route.routePath)), asset) : `${manifest.assetPrefix}${asset}`;
|
|
39
|
+
return `<link rel="preload" href="${escapeHtmlAttribute(href)}" as="script">`;
|
|
40
|
+
}).join('');
|
|
41
|
+
}
|
|
42
|
+
function escapeHtmlAttribute(value) {
|
|
43
|
+
return value.replace(/&/g, '&').replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>');
|
|
44
|
+
}
|
|
23
45
|
function renderAttrs(attrs) {
|
|
24
46
|
return Object.entries(attrs).map(([key, value])=>{
|
|
25
47
|
if ('boolean' == typeof value) return key;
|
|
26
48
|
if ('string' == typeof value || 'number' == typeof value) return `${key}="${value}"`;
|
|
27
49
|
throw createError(`Invalid value for attribute ${key}:${JSON.stringify(value)}`);
|
|
28
|
-
}).join('');
|
|
50
|
+
}).join(' ');
|
|
29
51
|
}
|
|
30
52
|
function isRouteMeta(route) {
|
|
31
53
|
return !!route && 'object' == typeof route && 'routePath' in route && 'absolutePath' in route;
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
import type { RouteMeta, UserConfig } from '@rspress/shared';
|
|
2
|
-
|
|
2
|
+
import type { RouteChunkAssetsManifest } from '../route/routeChunkAssets.js';
|
|
3
|
+
import type { AlternateLink } from './alternateLinks.js';
|
|
4
|
+
export declare function renderPage(route: RouteMeta, htmlTemplate: string, configHead: UserConfig['head'], ssrBundlePath: string, alternateLinks?: AlternateLink[], routeChunkAssets?: RouteChunkAssetsManifest): Promise<string>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { __webpack_require__ } from "../../0~rslib-runtime.js";
|
|
2
2
|
import "../../4538.js";
|
|
3
|
-
import { createHead, logger, transformHtmlTemplate, pathToFileURL } from "../../
|
|
3
|
+
import { createHead, logger, transformHtmlTemplate, pathToFileURL } from "../../3553.js";
|
|
4
4
|
import { hintSSGFailed } from "../logger/hint.js";
|
|
5
5
|
import { renderHtmlTemplate } from "./renderHtmlTemplate.js";
|
|
6
6
|
const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
7
7
|
var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
|
|
8
|
-
async function renderPage(route, htmlTemplate, configHead, ssrBundlePath) {
|
|
8
|
+
async function renderPage(route, htmlTemplate, configHead, ssrBundlePath, alternateLinks = [], routeChunkAssets) {
|
|
9
9
|
let render;
|
|
10
10
|
try {
|
|
11
11
|
let { default: ssrExports } = await import(pathToFileURL(ssrBundlePath).toString());
|
|
@@ -31,7 +31,7 @@ ${absolutePath ? picocolors_default().gray(` File: ${absolutePath}\n`) : ''}
|
|
|
31
31
|
throw e;
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
const replacedHtmlTemplate = await renderHtmlTemplate(htmlTemplate, configHead, route, appHtml);
|
|
34
|
+
const replacedHtmlTemplate = await renderHtmlTemplate(htmlTemplate, configHead, route, appHtml, alternateLinks, routeChunkAssets);
|
|
35
35
|
const html = await transformHtmlTemplate(head, replacedHtmlTemplate);
|
|
36
36
|
return html;
|
|
37
37
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { writeFile, mkdir, dirname, workerData } from "../../9857.js";
|
|
2
2
|
import { createError } from "../utils/error.js";
|
|
3
3
|
import { resolveHtmlFilePath } from "./htmlFile.js";
|
|
4
|
-
import { pMap } from "../../
|
|
4
|
+
import { pMap } from "../../3553.js";
|
|
5
5
|
import { renderPage } from "./renderPage.js";
|
|
6
6
|
const params = workerData?.[1]?.params;
|
|
7
7
|
if (!params) throw createError('SSG Worker Thread workerData params missing');
|
|
8
|
-
const { htmlTemplate: htmlTemplate, head: head, ssrBundlePath: ssrBundlePath, distPath: distPath } = params;
|
|
8
|
+
const { htmlTemplate: htmlTemplate, head: head, ssrBundlePath: ssrBundlePath, alternateLinksByRoute: alternateLinksByRoute, distPath: distPath, routeChunkAssets: routeChunkAssets } = params;
|
|
9
9
|
async function writeHtmlFile(routePath, html) {
|
|
10
10
|
if (!distPath) return;
|
|
11
11
|
const fileAbsolutePath = resolveHtmlFilePath(distPath, routePath);
|
|
@@ -17,7 +17,7 @@ async function writeHtmlFile(routePath, html) {
|
|
|
17
17
|
const exportWorkerGlueFn = async ({ routes })=>{
|
|
18
18
|
if (distPath) {
|
|
19
19
|
await pMap(routes, async (route)=>{
|
|
20
|
-
const html = await renderPage(route, htmlTemplate, head, ssrBundlePath);
|
|
20
|
+
const html = await renderPage(route, htmlTemplate, head, ssrBundlePath, alternateLinksByRoute[route.routePath] ?? [], routeChunkAssets);
|
|
21
21
|
await writeHtmlFile(route.routePath, html);
|
|
22
22
|
}, {
|
|
23
23
|
concurrency: 10
|
|
@@ -25,7 +25,7 @@ const exportWorkerGlueFn = async ({ routes })=>{
|
|
|
25
25
|
return [];
|
|
26
26
|
}
|
|
27
27
|
return pMap(routes, async (route)=>{
|
|
28
|
-
const html = await renderPage(route, htmlTemplate, head, ssrBundlePath);
|
|
28
|
+
const html = await renderPage(route, htmlTemplate, head, ssrBundlePath, alternateLinksByRoute[route.routePath] ?? [], routeChunkAssets);
|
|
29
29
|
return html;
|
|
30
30
|
}, {
|
|
31
31
|
concurrency: 10
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { UserConfig } from '@rspress/shared';
|
|
2
2
|
import type { RouteService } from '../route/RouteService.js';
|
|
3
|
-
|
|
4
|
-
export declare function
|
|
3
|
+
import type { RouteChunkAssetsManifest } from '../route/routeChunkAssets.js';
|
|
4
|
+
export declare function renderPages(routeService: RouteService, config: UserConfig, ssrBundlePath: string, htmlTemplate: string, emitAsset: (assetName: string, content: string | Buffer) => void, workerOutputDistPath?: string, routeChunkAssets?: RouteChunkAssetsManifest): Promise<void>;
|
|
5
|
+
export declare function renderCSRPages(routeService: RouteService, config: UserConfig, htmlTemplate: string, emitAsset: (assetName: string, content: string | Buffer) => void, routeChunkAssets?: RouteChunkAssetsManifest): Promise<void>;
|
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
/*! LICENSE: renderPages.js.LICENSE.txt */
|
|
2
2
|
import { __webpack_require__ } from "../../0~rslib-runtime.js";
|
|
3
3
|
import "../../4538.js";
|
|
4
|
-
import { chunk, logger } from "../../
|
|
4
|
+
import { chunk, logger } from "../../5871.js";
|
|
5
|
+
import { createAlternateLinksByRoute } from "./alternateLinks.js";
|
|
5
6
|
import { SSGWorkerThreadTaskSize, getNumberOfThreads, SSGWorkerThreadRecyclerMaxMemory, SSGConcurrency } from "./ssgEnv.js";
|
|
6
7
|
import { routePath2HtmlFileName } from "./htmlFile.js";
|
|
7
|
-
import { pMap } from "../../
|
|
8
|
+
import { pMap } from "../../3553.js";
|
|
8
9
|
import { renderPage } from "./renderPage.js";
|
|
9
10
|
import { hintSSGFailed } from "../logger/hint.js";
|
|
10
11
|
import { renderHtmlTemplate } from "./renderHtmlTemplate.js";
|
|
11
12
|
const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
12
13
|
var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
|
|
13
|
-
async function renderPages(routeService, config, ssrBundlePath, htmlTemplate, emitAsset, workerOutputDistPath) {
|
|
14
|
+
async function renderPages(routeService, config, ssrBundlePath, htmlTemplate, emitAsset, workerOutputDistPath, routeChunkAssets) {
|
|
14
15
|
const startTime = Date.now();
|
|
15
16
|
const ssg = config.ssg ?? true;
|
|
16
17
|
try {
|
|
17
18
|
const routes = routeService.getRoutes();
|
|
19
|
+
const alternateLinksByRoute = createAlternateLinksByRoute(routes, config);
|
|
18
20
|
if (!routeService.isExistRoute('/404')) routes.push({
|
|
19
21
|
routePath: '/404'
|
|
20
22
|
});
|
|
@@ -28,7 +30,7 @@ async function renderPages(routeService, config, ssrBundlePath, htmlTemplate, em
|
|
|
28
30
|
const ssgRoutes = [];
|
|
29
31
|
for (const route of routes)if (shouldIgnoreRoutePaths.has(route.routePath) || shouldIgnoreRoutePathsRegExp.some((reg)=>reg.test(route.routePath))) {
|
|
30
32
|
csrRoutes.push(route);
|
|
31
|
-
promiseList.push(renderCSRPage(config.head, route, htmlTemplate, emitAsset));
|
|
33
|
+
promiseList.push(renderCSRPage(config.head, route, htmlTemplate, alternateLinksByRoute, emitAsset, routeChunkAssets));
|
|
32
34
|
} else ssgRoutes.push(route);
|
|
33
35
|
if (csrRoutes.length > 0) {
|
|
34
36
|
const csrRoutePaths = csrRoutes.map((r)=>r.routePath);
|
|
@@ -60,7 +62,9 @@ async function renderPages(routeService, config, ssrBundlePath, htmlTemplate, em
|
|
|
60
62
|
htmlTemplate,
|
|
61
63
|
head: config.head,
|
|
62
64
|
ssrBundlePath,
|
|
63
|
-
|
|
65
|
+
alternateLinksByRoute,
|
|
66
|
+
distPath: workerOutputDistPath,
|
|
67
|
+
routeChunkAssets
|
|
64
68
|
}
|
|
65
69
|
}
|
|
66
70
|
});
|
|
@@ -80,7 +84,7 @@ async function renderPages(routeService, config, ssrBundlePath, htmlTemplate, em
|
|
|
80
84
|
} else {
|
|
81
85
|
logger.info('Rendering pages...');
|
|
82
86
|
await pMap(routes, async (route)=>{
|
|
83
|
-
const html = await renderPage(route, htmlTemplate, config.head, ssrBundlePath);
|
|
87
|
+
const html = await renderPage(route, htmlTemplate, config.head, ssrBundlePath, alternateLinksByRoute[route.routePath] ?? [], routeChunkAssets);
|
|
84
88
|
const fileName = routePath2HtmlFileName(route.routePath);
|
|
85
89
|
emitAsset(fileName, html);
|
|
86
90
|
}, {
|
|
@@ -98,16 +102,17 @@ async function renderPages(routeService, config, ssrBundlePath, htmlTemplate, em
|
|
|
98
102
|
throw e;
|
|
99
103
|
}
|
|
100
104
|
}
|
|
101
|
-
async function renderCSRPage(head, route, htmlTemplate, emitAsset) {
|
|
102
|
-
const html = await renderHtmlTemplate(htmlTemplate, head, route, '');
|
|
105
|
+
async function renderCSRPage(head, route, htmlTemplate, alternateLinksByRoute, emitAsset, routeChunkAssets) {
|
|
106
|
+
const html = await renderHtmlTemplate(htmlTemplate, head, route, '', alternateLinksByRoute[route.routePath] ?? [], routeChunkAssets);
|
|
103
107
|
const fileName = routePath2HtmlFileName(route.routePath);
|
|
104
108
|
emitAsset(fileName, html);
|
|
105
109
|
}
|
|
106
|
-
async function renderCSRPages(routeService, config, htmlTemplate, emitAsset) {
|
|
110
|
+
async function renderCSRPages(routeService, config, htmlTemplate, emitAsset, routeChunkAssets) {
|
|
107
111
|
const routes = routeService.getRoutes();
|
|
112
|
+
const alternateLinksByRoute = createAlternateLinksByRoute(routes, config);
|
|
108
113
|
if (!routeService.isExistRoute('/404')) routes.push({
|
|
109
114
|
routePath: '/404'
|
|
110
115
|
});
|
|
111
|
-
await Promise.all(routes.map((route)=>renderCSRPage(config.head, route, htmlTemplate, emitAsset)));
|
|
116
|
+
await Promise.all(routes.map((route)=>renderCSRPage(config.head, route, htmlTemplate, alternateLinksByRoute, emitAsset, routeChunkAssets)));
|
|
112
117
|
}
|
|
113
118
|
export { renderCSRPages, renderPages };
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { RsbuildPlugin } from '@rsbuild/core';
|
|
2
2
|
import type { UserConfig } from '@rspress/shared';
|
|
3
3
|
import type { RouteService } from '../route/RouteService.js';
|
|
4
|
-
|
|
4
|
+
import type { RouteChunkAssetsPlugin } from '../route/routeChunkAssets.js';
|
|
5
|
+
export declare const rsbuildPluginCSR: ({ routeService, config, routeChunkAssets, }: {
|
|
5
6
|
routeService: RouteService;
|
|
6
7
|
config: UserConfig;
|
|
8
|
+
routeChunkAssets: RouteChunkAssetsPlugin;
|
|
7
9
|
}) => RsbuildPlugin;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { renderCSRPages } from "./renderPages.js";
|
|
2
|
-
const rsbuildPluginCSR = ({ routeService, config })=>({
|
|
2
|
+
const rsbuildPluginCSR = ({ routeService, config, routeChunkAssets })=>({
|
|
3
3
|
name: 'rspress-inner-rsbuild-plugin-csr',
|
|
4
4
|
async setup (api) {
|
|
5
5
|
api.onBeforeBuild(()=>{
|
|
@@ -20,7 +20,7 @@ const rsbuildPluginCSR = ({ routeService, config })=>({
|
|
|
20
20
|
compilation.deleteAsset(assetName);
|
|
21
21
|
break;
|
|
22
22
|
}
|
|
23
|
-
await renderCSRPages(routeService, config, htmlTemplate, emitAsset);
|
|
23
|
+
await renderCSRPages(routeService, config, htmlTemplate, emitAsset, routeChunkAssets.getManifest());
|
|
24
24
|
});
|
|
25
25
|
});
|
|
26
26
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { RsbuildPlugin } from '@rsbuild/core';
|
|
2
2
|
import { type UserConfig } from '@rspress/shared';
|
|
3
3
|
import type { RouteService } from '../route/RouteService.js';
|
|
4
|
-
|
|
4
|
+
import type { RouteChunkAssetsPlugin } from '../route/routeChunkAssets.js';
|
|
5
|
+
export declare const rsbuildPluginSSG: ({ routeService, config, routeChunkAssets, }: {
|
|
5
6
|
routeService: RouteService;
|
|
6
7
|
config: UserConfig;
|
|
8
|
+
routeChunkAssets: RouteChunkAssetsPlugin;
|
|
7
9
|
}) => RsbuildPlugin;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { logger, writeFile, mkdir, rm, join, isDebugMode } from "../../
|
|
1
|
+
import { logger, writeFile, mkdir, rm, join, isDebugMode } from "../../5871.js";
|
|
2
2
|
import { NODE_SSG_BUNDLE_FOLDER, NODE_SSG_BUNDLE_NAME } from "../constants.js";
|
|
3
3
|
import { renderPages } from "./renderPages.js";
|
|
4
|
-
const rsbuildPluginSSG = ({ routeService, config })=>({
|
|
4
|
+
const rsbuildPluginSSG = ({ routeService, config, routeChunkAssets })=>({
|
|
5
5
|
name: 'rspress-inner-rsbuild-plugin-ssg',
|
|
6
6
|
async setup (api) {
|
|
7
7
|
api.onBeforeBuild(()=>{
|
|
@@ -75,7 +75,7 @@ const rsbuildPluginSSG = ({ routeService, config })=>({
|
|
|
75
75
|
}));
|
|
76
76
|
await indexHtmlEmittedInWeb;
|
|
77
77
|
if (hasError) return;
|
|
78
|
-
await renderPages(routeService, config, mainCjsAbsolutePath, htmlTemplate, emitAsset, distPath);
|
|
78
|
+
await renderPages(routeService, config, mainCjsAbsolutePath, htmlTemplate, emitAsset, distPath, routeChunkAssets.getManifest());
|
|
79
79
|
if (!isDebugMode()) await rm(ssgFolderPath, {
|
|
80
80
|
recursive: true
|
|
81
81
|
});
|
package/dist/node/ssg/ssgEnv.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*! LICENSE: ssgEnv.js.LICENSE.txt */
|
|
2
|
-
import { node_os } from "../../
|
|
2
|
+
import { node_os } from "../../5871.js";
|
|
3
3
|
/**
|
|
4
4
|
* these codes are copied from
|
|
5
5
|
* @link https://github.com/facebook/docusaurus/blob/45065e8d2b5831117b8d69fec1be28f5520cf105/packages/docusaurus/src/ssg/ssgEnv.ts#L11
|