@modern-js/plugin-ssg 1.2.7 → 1.2.8

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/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @modern-js/plugin-ssg
2
2
 
3
+ ## 1.2.8
4
+
5
+ ### Patch Changes
6
+
7
+ - 046e58aa: fix: plugin-analyze and plugin-ssg should not import method from core
8
+ - Updated dependencies [77ff9754]
9
+ - Updated dependencies [d2d1d6b2]
10
+ - Updated dependencies [07a4887e]
11
+ - Updated dependencies [ea2ae711]
12
+ - Updated dependencies [17d0cc46]
13
+ - Updated dependencies [d2d1d6b2]
14
+ - @modern-js/utils@1.4.0
15
+
3
16
  ## 1.2.7
4
17
 
5
18
  ### Patch Changes
@@ -35,7 +35,6 @@ export default (() => ({
35
35
  };
36
36
  },
37
37
 
38
- // eslint-disable-next-line max-statements
39
38
  async afterBuild() {
40
39
  const resolvedConfig = api.useResolvedConfigContext();
41
40
  const appContext = api.useAppContext();
@@ -169,7 +168,7 @@ export default (() => ({
169
168
  ssgRoute.isSSR = false;
170
169
  ssgRoute.output = formatOutput(ssgRoute.output);
171
170
  });
172
- const htmlAry = await createServer(ssgRoutes, pageRoutes, apiRoutes, resolvedConfig, appDirectory); // write to dist file
171
+ const htmlAry = await createServer(api, ssgRoutes, pageRoutes, apiRoutes, resolvedConfig, appDirectory); // write to dist file
173
172
 
174
173
  writeHtmlFile(htmlAry, ssgRoutes, buildDir); // format route info, side effect
175
174
 
@@ -1,10 +1,9 @@
1
1
  import childProcess from 'child_process';
2
2
  import path from 'path';
3
3
  import { logger } from '@modern-js/utils';
4
- import { useAppContext } from '@modern-js/core';
5
4
  import { openRouteSSR } from "../libs/util";
6
5
  import { CLOSE_SIGN } from "./consts";
7
- export const createServer = (ssgRoutes, pageRoutes, apiRoutes, options, appDirectory) => new Promise((resolve, reject) => {
6
+ export const createServer = (api, ssgRoutes, pageRoutes, apiRoutes, options, appDirectory) => new Promise((resolve, reject) => {
8
7
  // this side of the shallow copy of a route for subsequent render processing, to prevent the modification of the current field
9
8
  // manually enable the server-side rendering configuration for all routes that require SSG
10
9
  const backup = openRouteSSR(pageRoutes);
@@ -13,7 +12,7 @@ export const createServer = (ssgRoutes, pageRoutes, apiRoutes, options, appDirec
13
12
  cwd: appDirectory,
14
13
  silent: true
15
14
  });
16
- const appContext = useAppContext();
15
+ const appContext = api.useAppContext();
17
16
  const serverPlugins = appContext.plugins.filter(p => p.server).map(p => p.server);
18
17
  const plugins = serverPlugins.map(p => p.name);
19
18
  cp.send(JSON.stringify({
@@ -52,7 +52,6 @@ var _default = () => ({
52
52
  };
53
53
  },
54
54
 
55
- // eslint-disable-next-line max-statements
56
55
  async afterBuild() {
57
56
  const resolvedConfig = api.useResolvedConfigContext();
58
57
  const appContext = api.useAppContext();
@@ -187,7 +186,7 @@ var _default = () => ({
187
186
  ssgRoute.isSSR = false;
188
187
  ssgRoute.output = (0, _util.formatOutput)(ssgRoute.output);
189
188
  });
190
- const htmlAry = await (0, _server.createServer)(ssgRoutes, pageRoutes, apiRoutes, resolvedConfig, appDirectory); // write to dist file
189
+ const htmlAry = await (0, _server.createServer)(api, ssgRoutes, pageRoutes, apiRoutes, resolvedConfig, appDirectory); // write to dist file
191
190
 
192
191
  (0, _output.writeHtmlFile)(htmlAry, ssgRoutes, buildDir); // format route info, side effect
193
192
 
@@ -11,15 +11,13 @@ var _path = _interopRequireDefault(require("path"));
11
11
 
12
12
  var _utils = require("@modern-js/utils");
13
13
 
14
- var _core = require("@modern-js/core");
15
-
16
14
  var _util = require("../libs/util");
17
15
 
18
16
  var _consts = require("./consts");
19
17
 
20
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
19
 
22
- const createServer = (ssgRoutes, pageRoutes, apiRoutes, options, appDirectory) => new Promise((resolve, reject) => {
20
+ const createServer = (api, ssgRoutes, pageRoutes, apiRoutes, options, appDirectory) => new Promise((resolve, reject) => {
23
21
  // this side of the shallow copy of a route for subsequent render processing, to prevent the modification of the current field
24
22
  // manually enable the server-side rendering configuration for all routes that require SSG
25
23
  const backup = (0, _util.openRouteSSR)(pageRoutes);
@@ -30,7 +28,7 @@ const createServer = (ssgRoutes, pageRoutes, apiRoutes, options, appDirectory) =
30
28
  silent: true
31
29
  });
32
30
 
33
- const appContext = (0, _core.useAppContext)();
31
+ const appContext = api.useAppContext();
34
32
  const serverPlugins = appContext.plugins.filter(p => p.server).map(p => p.server);
35
33
  const plugins = serverPlugins.map(p => p.name);
36
34
  cp.send(JSON.stringify({
@@ -1,4 +1,4 @@
1
- import { NormalizedConfig } from '@modern-js/core';
1
+ import type { NormalizedConfig, PluginAPI } from '@modern-js/core';
2
2
  import { ServerRoute as ModernRoute } from '@modern-js/types';
3
3
  import { SsgRoute } from '../types';
4
- export declare const createServer: (ssgRoutes: SsgRoute[], pageRoutes: ModernRoute[], apiRoutes: ModernRoute[], options: NormalizedConfig, appDirectory: string) => Promise<string[]>;
4
+ export declare const createServer: (api: PluginAPI, ssgRoutes: SsgRoute[], pageRoutes: ModernRoute[], apiRoutes: ModernRoute[], options: NormalizedConfig, appDirectory: string) => Promise<string[]>;
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.2.7",
14
+ "version": "1.2.8",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -55,15 +55,15 @@
55
55
  },
56
56
  "dependencies": {
57
57
  "@babel/runtime": "^7",
58
- "@modern-js/utils": "^1.3.7",
58
+ "@modern-js/utils": "^1.4.0",
59
59
  "node-mocks-http": "^1.10.1",
60
60
  "normalize-path": "^3.0.0",
61
61
  "portfinder": "^1.0.28",
62
62
  "react-router-dom": "^5.2.1"
63
63
  },
64
64
  "devDependencies": {
65
- "@modern-js/types": "^1.3.6",
66
- "@modern-js/prod-server": "^1.0.6",
65
+ "@modern-js/types": "^1.4.0",
66
+ "@modern-js/prod-server": "^1.1.0",
67
67
  "@types/jest": "^26",
68
68
  "@types/node": "^14",
69
69
  "@types/react": "^17",
@@ -71,7 +71,7 @@
71
71
  "@types/react-router": "^5.1.16",
72
72
  "@types/react-router-dom": "^5.1.8",
73
73
  "typescript": "^4",
74
- "@modern-js/core": "1.6.1",
74
+ "@modern-js/core": "1.7.0",
75
75
  "@scripts/build": "0.0.0",
76
76
  "jest": "^27",
77
77
  "@scripts/jest-config": "0.0.0"
@@ -74,7 +74,6 @@ describe('test ssg util function', () => {
74
74
  expect(replaceWithAlias('/src', '/src/app.js', '@src')).toBe('@src/app.js');
75
75
  });
76
76
 
77
- // eslint-disable-next-line max-statements
78
77
  it('should starndar user config correctly', () => {
79
78
  const opt0 = standardOptions(false, []);
80
79
  expect(opt0).toBeFalsy();