@modern-js/plugin-ssg 2.35.1 → 2.37.0

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.
@@ -1,10 +1,10 @@
1
1
  import path from "path";
2
2
  import { ROUTE_SPEC_FILE, fs, isSingleEntry, SERVER_BUNDLE_DIRECTORY } from "@modern-js/utils";
3
- export function formatOutput(filename) {
3
+ function formatOutput(filename) {
4
4
  const outputPath = path.extname(filename) ? filename : `${filename}/index.html`;
5
5
  return outputPath;
6
6
  }
7
- export function formatPath(str) {
7
+ function formatPath(str) {
8
8
  let addr = str;
9
9
  if (!addr || typeof addr !== "string") {
10
10
  return addr;
@@ -20,10 +20,10 @@ export function formatPath(str) {
20
20
  }
21
21
  return addr;
22
22
  }
23
- export function isDynamicUrl(url) {
23
+ function isDynamicUrl(url) {
24
24
  return url.includes(":");
25
25
  }
26
- export function getUrlPrefix(route, baseUrl) {
26
+ function getUrlPrefix(route, baseUrl) {
27
27
  let base = "";
28
28
  if (Array.isArray(baseUrl)) {
29
29
  const filters = baseUrl.filter((url) => route.urlPath.includes(url));
@@ -42,7 +42,7 @@ export function getUrlPrefix(route, baseUrl) {
42
42
  const prefix = `${base}/${entryName}`;
43
43
  return prefix.endsWith("/") ? prefix.slice(0, -1) : prefix;
44
44
  }
45
- export function getOutput(route, base, agreed) {
45
+ function getOutput(route, base, agreed) {
46
46
  const { output } = route;
47
47
  if (output) {
48
48
  return output;
@@ -53,13 +53,13 @@ export function getOutput(route, base, agreed) {
53
53
  }
54
54
  throw new Error(`routing must provide output when calling createPage(), check ${route.urlPath}`);
55
55
  }
56
- export const readJSONSpec = (dir) => {
56
+ const readJSONSpec = (dir) => {
57
57
  const routeJSONPath = path.join(dir, ROUTE_SPEC_FILE);
58
58
  const routeJSON = require(routeJSONPath);
59
59
  const { routes } = routeJSON;
60
60
  return routes;
61
61
  };
62
- export const writeJSONSpec = (dir, routes) => {
62
+ const writeJSONSpec = (dir, routes) => {
63
63
  const routeJSONPath = path.join(dir, ROUTE_SPEC_FILE);
64
64
  fs.writeJSONSync(routeJSONPath, {
65
65
  routes
@@ -67,8 +67,8 @@ export const writeJSONSpec = (dir, routes) => {
67
67
  spaces: 2
68
68
  });
69
69
  };
70
- export const replaceWithAlias = (base, filePath, alias) => path.posix.join(alias, path.posix.relative(base, filePath));
71
- export const standardOptions = (ssgOptions, entrypoints, routes, server) => {
70
+ const replaceWithAlias = (base, filePath, alias) => path.posix.join(alias, path.posix.relative(base, filePath));
71
+ const standardOptions = (ssgOptions, entrypoints, routes, server) => {
72
72
  if (ssgOptions === false) {
73
73
  return false;
74
74
  }
@@ -108,12 +108,12 @@ export const standardOptions = (ssgOptions, entrypoints, routes, server) => {
108
108
  }
109
109
  return false;
110
110
  };
111
- export const openRouteSSR = (routes, entries = []) => routes.map((ssgRoute) => ({
111
+ const openRouteSSR = (routes, entries = []) => routes.map((ssgRoute) => ({
112
112
  ...ssgRoute,
113
113
  isSSR: entries.includes(ssgRoute.entryName),
114
114
  bundle: `${SERVER_BUNDLE_DIRECTORY}/${ssgRoute.entryName}.js`
115
115
  }));
116
- export const flattenRoutes = (routes) => {
116
+ const flattenRoutes = (routes) => {
117
117
  const parents = [];
118
118
  const newRoutes = [];
119
119
  const traverseRoute = (route) => {
@@ -138,3 +138,16 @@ export const flattenRoutes = (routes) => {
138
138
  routes.forEach(traverseRoute);
139
139
  return newRoutes;
140
140
  };
141
+ export {
142
+ flattenRoutes,
143
+ formatOutput,
144
+ formatPath,
145
+ getOutput,
146
+ getUrlPrefix,
147
+ isDynamicUrl,
148
+ openRouteSSR,
149
+ readJSONSpec,
150
+ replaceWithAlias,
151
+ standardOptions,
152
+ writeJSONSpec
153
+ };
@@ -1 +1,4 @@
1
- export const CLOSE_SIGN = "modern_close_server";
1
+ const CLOSE_SIGN = "modern_close_server";
2
+ export {
3
+ CLOSE_SIGN
4
+ };
@@ -3,7 +3,7 @@ import path from "path";
3
3
  import { logger } from "@modern-js/utils";
4
4
  import { openRouteSSR } from "../libs/util";
5
5
  import { CLOSE_SIGN } from "./consts";
6
- export const createServer = (api, ssgRoutes, pageRoutes, apiRoutes, options, appDirectory) => new Promise((resolve, reject) => {
6
+ const createServer = (api, ssgRoutes, pageRoutes, apiRoutes, options, appDirectory) => new Promise((resolve, reject) => {
7
7
  var _cp_stderr, _cp_stdout;
8
8
  const entries = ssgRoutes.map((route) => route.entryName);
9
9
  const backup = openRouteSSR(pageRoutes, entries);
@@ -57,3 +57,6 @@ export const createServer = (api, ssgRoutes, pageRoutes, apiRoutes, options, app
57
57
  }
58
58
  });
59
59
  });
60
+ export {
61
+ createServer
62
+ };
@@ -1,7 +1,7 @@
1
1
  import EventEmitter from "events";
2
2
  import { Readable } from "stream";
3
3
  import httpMocks from "node-mocks-http";
4
- export const compile = (requestHandler) => (options, extend = {}) => new Promise((resolve, reject) => {
4
+ const compile = (requestHandler) => (options, extend = {}) => new Promise((resolve, reject) => {
5
5
  const req = httpMocks.createRequest({
6
6
  ...options,
7
7
  eventEmitter: Readable
@@ -32,3 +32,6 @@ export const compile = (requestHandler) => (options, extend = {}) => new Promise
32
32
  reject(e);
33
33
  }
34
34
  });
35
+ export {
36
+ compile
37
+ };
@@ -1 +0,0 @@
1
- export {};
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.35.1",
18
+ "version": "2.37.0",
19
19
  "jsnext:source": "./src/index.ts",
20
20
  "types": "./dist/types/index.d.ts",
21
21
  "main": "./dist/cjs/index.js",
@@ -63,7 +63,7 @@
63
63
  "normalize-path": "^3.0.0",
64
64
  "portfinder": "^1.0.28",
65
65
  "@swc/helpers": "0.5.1",
66
- "@modern-js/utils": "2.35.1"
66
+ "@modern-js/utils": "2.37.0"
67
67
  },
68
68
  "peerDependencies": {
69
69
  "react-router-dom": ">=5.1.2"
@@ -81,11 +81,11 @@
81
81
  "react-dom": "^18",
82
82
  "react-router-dom": "^6.8.1",
83
83
  "typescript": "^5",
84
- "@modern-js/types": "2.35.1",
85
- "@modern-js/app-tools": "2.35.1",
86
- "@modern-js/prod-server": "2.35.1",
87
- "@scripts/jest-config": "2.35.1",
88
- "@scripts/build": "2.35.1"
84
+ "@modern-js/app-tools": "2.37.0",
85
+ "@modern-js/prod-server": "2.37.0",
86
+ "@modern-js/types": "2.37.0",
87
+ "@scripts/build": "2.37.0",
88
+ "@scripts/jest-config": "2.37.0"
89
89
  },
90
90
  "sideEffects": false,
91
91
  "publishConfig": {