@rspress/core 2.0.0-beta.15 → 2.0.0-beta.16

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.
Files changed (2) hide show
  1. package/dist/index.js +24 -20
  2. package/package.json +10 -12
package/dist/index.js CHANGED
@@ -179,7 +179,7 @@ const pluginVirtualModule = (pluginOptions = {})=>({
179
179
  }
180
180
  }
181
181
  });
182
- var package_namespaceObject = JSON.parse('{"i8":"2.0.0-beta.15"}');
182
+ var package_namespaceObject = JSON.parse('{"i8":"2.0.0-beta.16"}');
183
183
  const RSPRESS_VERSION = package_namespaceObject.i8;
184
184
  const isProduction = ()=>'production' === process.env.NODE_ENV;
185
185
  const importStatementRegex = /import\s+(.*?)\s+from\s+(['"])(.*?)(?:"|');?/gm;
@@ -204,6 +204,8 @@ const META_GENERATOR = '<!--<?- GENERATOR ?>-->';
204
204
  const DEFAULT_TITLE = 'Rspress';
205
205
  const PUBLIC_DIR = 'public';
206
206
  const constants_TEMP_DIR = node_path.join(process.cwd(), 'node_modules', RSPRESS_TEMP_DIR);
207
+ const NODE_SSG_BUNDLE_FOLDER = '__ssg__';
208
+ const NODE_SSG_BUNDLE_NAME = 'rspress-ssg-entry.cjs';
207
209
  async function pathExists(path) {
208
210
  try {
209
211
  await node_fs_promises.access(path);
@@ -1193,7 +1195,6 @@ async function renderPages(routeService, config, pluginDriver, ssrBundlePath, ht
1193
1195
  throw e;
1194
1196
  }
1195
1197
  }
1196
- const NODE_SSR_BUNDLE_NAME = 'rspress-ssg-entry.cjs';
1197
1198
  const rsbuildPluginSSG = ({ routeService, config, pluginDriver })=>({
1198
1199
  name: 'rspress-inner-rsbuild-plugin-ssg',
1199
1200
  async setup (api) {
@@ -1205,7 +1206,8 @@ const rsbuildPluginSSG = ({ routeService, config, pluginDriver })=>({
1205
1206
  targets: [
1206
1207
  'web'
1207
1208
  ]
1208
- }, ({ assets, compilation })=>{
1209
+ }, ({ assets, compilation, environment })=>{
1210
+ if ('web' !== environment.name) return;
1209
1211
  for (const [assetName, assetSource] of Object.entries(assets))if ('index.html' === assetName) {
1210
1212
  htmlTemplate = assetSource.source().toString();
1211
1213
  compilation.deleteAsset(assetName);
@@ -1226,23 +1228,28 @@ const rsbuildPluginSSG = ({ routeService, config, pluginDriver })=>({
1226
1228
  'node'
1227
1229
  ]
1228
1230
  }, async ({ assets, compilation, environment, compiler })=>{
1231
+ if ('node' !== environment.name) return;
1229
1232
  const distPath = environment.distPath;
1230
- await mkdir(distPath, {
1233
+ const ssgFolderPath = join(distPath, NODE_SSG_BUNDLE_FOLDER);
1234
+ const mainCjsAbsolutePath = join(ssgFolderPath, NODE_SSG_BUNDLE_NAME);
1235
+ await mkdir(ssgFolderPath, {
1231
1236
  recursive: true
1232
1237
  });
1233
- let mainCjsAbsolutePath = '';
1234
- for (const [assetName, assetSource] of Object.entries(assets))if (assetName.includes(NODE_SSR_BUNDLE_NAME)) {
1235
- mainCjsAbsolutePath = join(distPath, assetName);
1236
- await writeFile(mainCjsAbsolutePath, assetSource.source().toString());
1237
- compilation.deleteAsset(assetName);
1238
- break;
1239
- }
1238
+ await Promise.all(Object.entries(assets).map(async ([assetName, assetSource])=>{
1239
+ if (assetName.startsWith(`${NODE_SSG_BUNDLE_FOLDER}/`)) {
1240
+ const fileAbsolutePath = join(distPath, assetName);
1241
+ await writeFile(fileAbsolutePath, assetSource.source().toString());
1242
+ compilation.deleteAsset(assetName);
1243
+ }
1244
+ }));
1240
1245
  const emitAsset = (assetName, content)=>{
1241
1246
  compilation.emitAsset(assetName, new compiler.webpack.sources.RawSource(content));
1242
1247
  };
1243
1248
  await indexHtmlEmittedInWeb;
1244
1249
  await renderPages(routeService, config, pluginDriver, mainCjsAbsolutePath, htmlTemplate, emitAsset);
1245
- if (!isDebugMode()) await rm(mainCjsAbsolutePath);
1250
+ if (!isDebugMode()) await rm(ssgFolderPath, {
1251
+ recursive: true
1252
+ });
1246
1253
  });
1247
1254
  });
1248
1255
  }
@@ -1536,7 +1543,11 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
1536
1543
  chain.module.rule('css-virtual-module').test(/\.rspress[\\/]runtime[\\/]virtual-global-styles/).merge({
1537
1544
  sideEffects: true
1538
1545
  });
1539
- if (isServer) chain.output.filename(NODE_SSR_BUNDLE_NAME);
1546
+ if (isServer) {
1547
+ chain.output.filename(`${NODE_SSG_BUNDLE_FOLDER}/${NODE_SSG_BUNDLE_NAME}`);
1548
+ chain.output.chunkFilename(`${NODE_SSG_BUNDLE_FOLDER}/[name].cjs`);
1549
+ chain.target('async-node');
1550
+ }
1540
1551
  }
1541
1552
  },
1542
1553
  environments: {
@@ -1574,13 +1585,6 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
1574
1585
  ...reactRouterDomAlias
1575
1586
  }
1576
1587
  },
1577
- tools: {
1578
- rspack: {
1579
- output: {
1580
- asyncChunks: false
1581
- }
1582
- }
1583
- },
1584
1588
  source: {
1585
1589
  entry: {
1586
1590
  index: SSR_SERVER_ENTRY
package/package.json CHANGED
@@ -1,21 +1,19 @@
1
1
  {
2
2
  "name": "@rspress/core",
3
- "version": "2.0.0-beta.15",
3
+ "version": "2.0.0-beta.16",
4
4
  "description": "The Rspress Documentation Framework",
5
5
  "bugs": "https://github.com/web-infra-dev/rspress/issues",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "git+https://github.com/web-infra-dev/rspress.git",
9
- "directory": "packages/cli/core"
9
+ "directory": "packages/core"
10
10
  },
11
11
  "license": "MIT",
12
12
  "sideEffects": [
13
13
  "*.css",
14
14
  "*.less",
15
15
  "*.sass",
16
- "*.scss",
17
- "**/virtual-global-styles.js",
18
- "virtual-global-styles"
16
+ "*.scss"
19
17
  ],
20
18
  "type": "module",
21
19
  "exports": {
@@ -77,13 +75,13 @@
77
75
  "unified": "^11.0.5",
78
76
  "unist-util-visit": "^5.0.0",
79
77
  "unist-util-visit-children": "^3.0.0",
80
- "@rspress/plugin-auto-nav-sidebar": "2.0.0-beta.15",
81
- "@rspress/plugin-medium-zoom": "2.0.0-beta.15",
82
- "@rspress/plugin-container-syntax": "2.0.0-beta.15",
83
- "@rspress/plugin-last-updated": "2.0.0-beta.15",
84
- "@rspress/runtime": "2.0.0-beta.15",
85
- "@rspress/shared": "2.0.0-beta.15",
86
- "@rspress/theme-default": "2.0.0-beta.15"
78
+ "@rspress/plugin-auto-nav-sidebar": "2.0.0-beta.16",
79
+ "@rspress/plugin-container-syntax": "2.0.0-beta.16",
80
+ "@rspress/plugin-medium-zoom": "2.0.0-beta.16",
81
+ "@rspress/runtime": "2.0.0-beta.16",
82
+ "@rspress/shared": "2.0.0-beta.16",
83
+ "@rspress/theme-default": "2.0.0-beta.16",
84
+ "@rspress/plugin-last-updated": "2.0.0-beta.16"
87
85
  },
88
86
  "devDependencies": {
89
87
  "@microsoft/api-extractor": "^7.52.8",