@modern-js/plugin-ssg 2.58.1 → 2.58.3

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/cjs/index.js CHANGED
@@ -35,11 +35,11 @@ module.exports = __toCommonJS(src_exports);
35
35
  var import_path = __toESM(require("path"));
36
36
  var import_utils = require("@modern-js/utils");
37
37
  var import_react_router_dom = require("react-router-dom");
38
- var import_util = require("./libs/util");
39
- var import_server = require("./server");
38
+ var import_make = require("./libs/make");
40
39
  var import_output = require("./libs/output");
41
40
  var import_replace = require("./libs/replace");
42
- var import_make = require("./libs/make");
41
+ var import_util = require("./libs/util");
42
+ var import_server = require("./server");
43
43
  const ssgPlugin = () => ({
44
44
  name: "@modern-js/plugin-ssg",
45
45
  pre: [
@@ -22,8 +22,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
22
22
  mod
23
23
  ));
24
24
  var import_http = require("http");
25
- var import_portfinder = __toESM(require("portfinder"));
26
25
  var import_prod_server = require("@modern-js/prod-server");
26
+ var import_portfinder = __toESM(require("portfinder"));
27
27
  var import_consts = require("./consts");
28
28
  process.on("message", async (chunk) => {
29
29
  if (chunk === import_consts.CLOSE_SIGN) {
@@ -42,7 +42,7 @@ process.on("message", async (chunk) => {
42
42
  config: options,
43
43
  appContext,
44
44
  routes,
45
- plugins: (0, import_prod_server.loadServerPlugins)(plugins, appContext.appDirectory || distDirectory),
45
+ plugins: await (0, import_prod_server.loadServerPlugins)(plugins, appContext.appDirectory || distDirectory),
46
46
  staticGenerate: true
47
47
  };
48
48
  nodeServer = await (0, import_prod_server.createProdServer)(serverOptions);
package/dist/esm/index.js CHANGED
@@ -5,11 +5,11 @@ import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
5
5
  import path from "path";
6
6
  import { filterRoutesForServer, logger } from "@modern-js/utils";
7
7
  import { generatePath } from "react-router-dom";
8
- import { flattenRoutes, formatOutput, isDynamicUrl, readJSONSpec, standardOptions, writeJSONSpec } from "./libs/util";
9
- import { createServer } from "./server";
8
+ import { makeRoute } from "./libs/make";
10
9
  import { writeHtmlFile } from "./libs/output";
11
10
  import { replaceRoute } from "./libs/replace";
12
- import { makeRoute } from "./libs/make";
11
+ import { flattenRoutes, formatOutput, isDynamicUrl, readJSONSpec, standardOptions, writeJSONSpec } from "./libs/util";
12
+ import { createServer } from "./server";
13
13
  var ssgPlugin = function() {
14
14
  return {
15
15
  name: "@modern-js/plugin-ssg",
@@ -1,7 +1,7 @@
1
1
  import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
2
2
  import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
3
3
  import path from "path";
4
- import { ROUTE_SPEC_FILE, fs, isSingleEntry, SERVER_BUNDLE_DIRECTORY } from "@modern-js/utils";
4
+ import { fs, ROUTE_SPEC_FILE, SERVER_BUNDLE_DIRECTORY, isSingleEntry } from "@modern-js/utils";
5
5
  function formatOutput(filename) {
6
6
  var outputPath = path.extname(filename) ? filename : "".concat(filename, "/index.html");
7
7
  return outputPath;
@@ -2,12 +2,12 @@ import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
2
  import { _ as _instanceof } from "@swc/helpers/_/_instanceof";
3
3
  import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
4
4
  import { request } from "http";
5
- import portfinder from "portfinder";
6
5
  import { createProdServer, loadServerPlugins } from "@modern-js/prod-server";
6
+ import portfinder from "portfinder";
7
7
  import { CLOSE_SIGN } from "./consts";
8
8
  process.on("message", function() {
9
9
  var _ref = _async_to_generator(function(chunk) {
10
- var context, routes, renderRoutes, options, appContext, plugins, distDirectory, nodeServer, serverConfig, defaultPort, port, serverOptions, e;
10
+ var context, routes, renderRoutes, options, appContext, plugins, distDirectory, nodeServer, serverConfig, defaultPort, port, serverOptions, _tmp, e;
11
11
  return _ts_generator(this, function(_state) {
12
12
  switch (_state.label) {
13
13
  case 0:
@@ -21,9 +21,9 @@ process.on("message", function() {
21
21
  case 1:
22
22
  _state.trys.push([
23
23
  1,
24
- 4,
24
+ 5,
25
25
  ,
26
- 5
26
+ 6
27
27
  ]);
28
28
  serverConfig = options.server;
29
29
  defaultPort = Number(process.env.PORT) || serverConfig.port;
@@ -34,19 +34,23 @@ process.on("message", function() {
34
34
  ];
35
35
  case 2:
36
36
  port = _state.sent();
37
- serverOptions = {
37
+ _tmp = {
38
38
  pwd: distDirectory,
39
39
  config: options,
40
40
  appContext,
41
- routes,
42
- plugins: loadServerPlugins(plugins, appContext.appDirectory || distDirectory),
43
- staticGenerate: true
41
+ routes
44
42
  };
45
43
  return [
46
44
  4,
47
- createProdServer(serverOptions)
45
+ loadServerPlugins(plugins, appContext.appDirectory || distDirectory)
48
46
  ];
49
47
  case 3:
48
+ serverOptions = (_tmp.plugins = _state.sent(), _tmp.staticGenerate = true, _tmp);
49
+ return [
50
+ 4,
51
+ createProdServer(serverOptions)
52
+ ];
53
+ case 4:
50
54
  nodeServer = _state.sent();
51
55
  nodeServer.listen(port, /* @__PURE__ */ _async_to_generator(function() {
52
56
  var htmlAry;
@@ -80,17 +84,17 @@ process.on("message", function() {
80
84
  }));
81
85
  return [
82
86
  3,
83
- 5
87
+ 6
84
88
  ];
85
- case 4:
89
+ case 5:
86
90
  e = _state.sent();
87
91
  nodeServer === null || nodeServer === void 0 ? void 0 : nodeServer.close();
88
92
  process.stderr.write(_instanceof(e, Error) ? e.stack : e.toString());
89
93
  return [
90
94
  3,
91
- 5
95
+ 6
92
96
  ];
93
- case 5:
97
+ case 6:
94
98
  return [
95
99
  2
96
100
  ];
@@ -1,11 +1,11 @@
1
1
  import path from "path";
2
2
  import { filterRoutesForServer, logger } from "@modern-js/utils";
3
3
  import { generatePath } from "react-router-dom";
4
- import { flattenRoutes, formatOutput, isDynamicUrl, readJSONSpec, standardOptions, writeJSONSpec } from "./libs/util";
5
- import { createServer } from "./server";
4
+ import { makeRoute } from "./libs/make";
6
5
  import { writeHtmlFile } from "./libs/output";
7
6
  import { replaceRoute } from "./libs/replace";
8
- import { makeRoute } from "./libs/make";
7
+ import { flattenRoutes, formatOutput, isDynamicUrl, readJSONSpec, standardOptions, writeJSONSpec } from "./libs/util";
8
+ import { createServer } from "./server";
9
9
  const ssgPlugin = () => ({
10
10
  name: "@modern-js/plugin-ssg",
11
11
  pre: [
@@ -1,5 +1,5 @@
1
1
  import path from "path";
2
- import { ROUTE_SPEC_FILE, fs, isSingleEntry, SERVER_BUNDLE_DIRECTORY } from "@modern-js/utils";
2
+ import { fs, ROUTE_SPEC_FILE, SERVER_BUNDLE_DIRECTORY, isSingleEntry } from "@modern-js/utils";
3
3
  function formatOutput(filename) {
4
4
  const outputPath = path.extname(filename) ? filename : `${filename}/index.html`;
5
5
  return outputPath;
@@ -1,6 +1,6 @@
1
1
  import { request } from "http";
2
- import portfinder from "portfinder";
3
2
  import { createProdServer, loadServerPlugins } from "@modern-js/prod-server";
3
+ import portfinder from "portfinder";
4
4
  import { CLOSE_SIGN } from "./consts";
5
5
  process.on("message", async (chunk) => {
6
6
  if (chunk === CLOSE_SIGN) {
@@ -19,7 +19,7 @@ process.on("message", async (chunk) => {
19
19
  config: options,
20
20
  appContext,
21
21
  routes,
22
- plugins: loadServerPlugins(plugins, appContext.appDirectory || distDirectory),
22
+ plugins: await loadServerPlugins(plugins, appContext.appDirectory || distDirectory),
23
23
  staticGenerate: true
24
24
  };
25
25
  nodeServer = await createProdServer(serverOptions);
@@ -1,5 +1,5 @@
1
- import { ServerRoute as ModernRoute } from '@modern-js/types';
2
- import { compile } from '../server/prerender';
3
- import { SSGRouteOptions, SsgRoute } from '../types';
1
+ import type { ServerRoute as ModernRoute } from '@modern-js/types';
2
+ import type { compile } from '../server/prerender';
3
+ import type { SSGRouteOptions, SsgRoute } from '../types';
4
4
  export declare function makeRender(ssgRoutes: SsgRoute[], render: ReturnType<typeof compile>, port: number): Promise<string>[];
5
5
  export declare function makeRoute(baseRoute: ModernRoute, route: string | SSGRouteOptions, headers?: Record<string, any>): SsgRoute;
@@ -1,2 +1,2 @@
1
- import { SsgRoute } from '../types';
1
+ import type { SsgRoute } from '../types';
2
2
  export declare function writeHtmlFile(htmlAry: string[], ssgRoutes: SsgRoute[], baseDir: string): void;
@@ -1,4 +1,4 @@
1
- import { ServerRoute as ModernRoute } from '@modern-js/types';
2
- import { SsgRoute } from '../types';
1
+ import type { ServerRoute as ModernRoute } from '@modern-js/types';
2
+ import type { SsgRoute } from '../types';
3
3
  export declare function exist(route: ModernRoute, pageRoutes: ModernRoute[]): number;
4
4
  export declare function replaceRoute(ssgRoutes: SsgRoute[], pageRoutes: ModernRoute[]): ModernRoute[];
@@ -1,6 +1,6 @@
1
- import { ServerRoute as ModernRoute } from '@modern-js/types';
2
- import { ServerUserConfig } from '@modern-js/app-tools';
3
- import { SsgRoute, SSGConfig, EntryPoint, SSGMultiEntryOptions, AgreedRoute } from '../types';
1
+ import type { ServerUserConfig } from '@modern-js/app-tools';
2
+ import type { ServerRoute as ModernRoute } from '@modern-js/types';
3
+ import type { AgreedRoute, EntryPoint, SSGConfig, SSGMultiEntryOptions, SsgRoute } from '../types';
4
4
  export declare function formatOutput(filename: string): string;
5
5
  export declare function formatPath(str: string): string;
6
6
  export declare function isDynamicUrl(url: string): boolean;
@@ -1,4 +1,4 @@
1
- import type { AppNormalizedConfig, PluginAPI, AppTools } from '@modern-js/app-tools';
2
- import { ServerRoute as ModernRoute } from '@modern-js/types';
3
- import { SsgRoute } from '../types';
1
+ import type { AppNormalizedConfig, AppTools, PluginAPI } from '@modern-js/app-tools';
2
+ import type { ServerRoute as ModernRoute } from '@modern-js/types';
3
+ import type { SsgRoute } from '../types';
4
4
  export declare const createServer: (api: PluginAPI<AppTools>, ssgRoutes: SsgRoute[], pageRoutes: ModernRoute[], apiRoutes: ModernRoute[], options: AppNormalizedConfig, appDirectory: string) => Promise<string[]>;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import { IncomingMessage, ServerResponse } from 'http';
2
+ import type { IncomingMessage, ServerResponse } from 'http';
3
3
  export type Options = {
4
4
  url: string;
5
5
  headers: {
@@ -1,5 +1,5 @@
1
1
  import type { ServerRoute as ModernRoute } from '@modern-js/types';
2
- import { SSGConfig, SSGRouteOptions, SSGMultiEntryOptions, SSGSingleEntryOptions } from '@modern-js/types';
2
+ import type { SSGConfig, SSGMultiEntryOptions, SSGRouteOptions, SSGSingleEntryOptions } from '@modern-js/types';
3
3
  export type { SSGConfig, SSGRouteOptions, SSGMultiEntryOptions, SSGSingleEntryOptions, };
4
4
  export type AgreedRoute = {
5
5
  path?: string;
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.58.1",
18
+ "version": "2.58.3",
19
19
  "jsnext:source": "./src/index.ts",
20
20
  "types": "./dist/types/index.d.ts",
21
21
  "main": "./dist/cjs/index.js",
@@ -63,8 +63,8 @@
63
63
  "node-mocks-http": "^1.11.0",
64
64
  "normalize-path": "3.0.0",
65
65
  "portfinder": "^1.0.28",
66
- "@modern-js/prod-server": "2.58.1",
67
- "@modern-js/utils": "2.58.1"
66
+ "@modern-js/prod-server": "2.58.3",
67
+ "@modern-js/utils": "2.58.3"
68
68
  },
69
69
  "peerDependencies": {
70
70
  "react-router-dom": ">=5.1.2"
@@ -82,10 +82,10 @@
82
82
  "react-dom": "^18",
83
83
  "react-router-dom": "6.22.0",
84
84
  "typescript": "^5",
85
- "@modern-js/types": "2.58.1",
86
- "@modern-js/app-tools": "2.58.1",
87
- "@scripts/jest-config": "2.58.1",
88
- "@scripts/build": "2.58.1"
85
+ "@modern-js/app-tools": "2.58.3",
86
+ "@scripts/build": "2.58.3",
87
+ "@scripts/jest-config": "2.58.3",
88
+ "@modern-js/types": "2.58.3"
89
89
  },
90
90
  "sideEffects": false,
91
91
  "publishConfig": {