@modern-js/plugin-ssg 1.2.5 → 1.2.6

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,13 @@
1
1
  # @modern-js/plugin-ssg
2
2
 
3
+ ## 1.2.6
4
+
5
+ ### Patch Changes
6
+
7
+ - c7dc7f54: migrate to new plugin style
8
+ - Updated dependencies [5bf5868d]
9
+ - @modern-js/utils@1.3.5
10
+
3
11
  ## 1.2.5
4
12
 
5
13
  ### Patch Changes
@@ -6,181 +6,179 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
6
6
 
7
7
  import path from 'path';
8
8
  import { logger, PLUGIN_SCHEMAS } from '@modern-js/utils';
9
- import { createPlugin, useAppContext, useResolvedConfigContext } from '@modern-js/core';
10
9
  import { generatePath } from 'react-router-dom';
11
10
  import { formatOutput, isDynamicUrl, readJSONSpec, standardOptions, writeJSONSpec } from "./libs/util";
12
11
  import { createServer } from "./server";
13
12
  import { writeHtmlFile } from "./libs/output";
14
13
  import { replaceRoute } from "./libs/replace";
15
14
  import { makeRoute } from "./libs/make";
16
- export default createPlugin(() => {
17
- const agreedRouteMap = {};
18
- return {
19
- validateSchema() {
20
- return PLUGIN_SCHEMAS['@modern-js/plugin-ssg'];
21
- },
22
-
23
- modifyFileSystemRoutes({
24
- entrypoint,
25
- routes
26
- }) {
27
- const {
28
- entryName
29
- } = entrypoint;
30
- agreedRouteMap[entryName] = routes;
31
- return {
15
+ export default (() => ({
16
+ name: '@modern-js/plugin-ssg',
17
+ setup: api => {
18
+ const agreedRouteMap = {};
19
+ return {
20
+ validateSchema() {
21
+ return PLUGIN_SCHEMAS['@modern-js/plugin-ssg'];
22
+ },
23
+
24
+ modifyFileSystemRoutes({
32
25
  entrypoint,
33
26
  routes
34
- };
35
- },
36
-
37
- // eslint-disable-next-line max-statements
38
- async afterBuild() {
39
- // eslint-disable-next-line react-hooks/rules-of-hooks
40
- const resolvedConfig = useResolvedConfigContext(); // eslint-disable-next-line react-hooks/rules-of-hooks
41
-
42
- const appContext = useAppContext();
43
- const {
44
- appDirectory,
45
- entrypoints
46
- } = appContext;
47
- const {
48
- output
49
- } = resolvedConfig;
50
- const {
51
- ssg,
52
- path: outputPath
53
- } = output;
54
- const ssgOptions = Array.isArray(ssg) ? ssg.pop() : ssg; // no ssg configuration, skip ssg render.
55
-
56
- if (!ssgOptions) {
57
- return;
58
- }
27
+ }) {
28
+ const {
29
+ entryName
30
+ } = entrypoint;
31
+ agreedRouteMap[entryName] = routes;
32
+ return {
33
+ entrypoint,
34
+ routes
35
+ };
36
+ },
37
+
38
+ // eslint-disable-next-line max-statements
39
+ async afterBuild() {
40
+ const resolvedConfig = api.useResolvedConfigContext();
41
+ const appContext = api.useAppContext();
42
+ const {
43
+ appDirectory,
44
+ entrypoints
45
+ } = appContext;
46
+ const {
47
+ output
48
+ } = resolvedConfig;
49
+ const {
50
+ ssg,
51
+ path: outputPath
52
+ } = output;
53
+ const ssgOptions = Array.isArray(ssg) ? ssg.pop() : ssg; // no ssg configuration, skip ssg render.
59
54
 
60
- const buildDir = path.join(appDirectory, outputPath);
61
- const routes = readJSONSpec(buildDir); // filter all routes not web
55
+ if (!ssgOptions) {
56
+ return;
57
+ }
62
58
 
63
- const pageRoutes = routes.filter(route => !route.isApi);
64
- const apiRoutes = routes.filter(route => route.isApi); // if no web page route, skip ssg render
59
+ const buildDir = path.join(appDirectory, outputPath);
60
+ const routes = readJSONSpec(buildDir); // filter all routes not web
65
61
 
66
- if (pageRoutes.length === 0) {
67
- return;
68
- }
62
+ const pageRoutes = routes.filter(route => !route.isApi);
63
+ const apiRoutes = routes.filter(route => route.isApi); // if no web page route, skip ssg render
69
64
 
70
- const intermediateOptions = standardOptions(ssgOptions, entrypoints);
71
-
72
- if (!intermediateOptions) {
73
- return;
74
- }
65
+ if (pageRoutes.length === 0) {
66
+ return;
67
+ }
75
68
 
76
- const ssgRoutes = []; // each route will try to match the configuration
69
+ const intermediateOptions = standardOptions(ssgOptions, entrypoints);
77
70
 
78
- pageRoutes.forEach(pageRoute => {
79
- const {
80
- entryName,
81
- entryPath
82
- } = pageRoute;
83
- const agreedRoutes = agreedRouteMap[entryName];
84
- let entryOptions = intermediateOptions[entryName];
85
-
86
- if (!agreedRoutes) {
87
- // default behavior for non-agreed route
88
- if (!entryOptions) {
89
- return;
90
- } // only add entry route if entryOptions is true
91
-
92
-
93
- if (entryOptions === true) {
94
- ssgRoutes.push(_objectSpread(_objectSpread({}, pageRoute), {}, {
95
- output: entryPath
96
- }));
97
- } else if (entryOptions.routes && entryOptions.routes.length > 0) {
98
- // if entryOptions is object and has routes options
99
- // add every route in options
100
- const {
101
- routes: enrtyRoutes,
102
- headers
103
- } = entryOptions;
104
- enrtyRoutes.forEach(route => {
105
- ssgRoutes.push(makeRoute(pageRoute, route, headers));
106
- });
107
- }
108
- } else {
109
- // Unless entryOptions is set to false
110
- // the default behavior is to add all file-based routes
111
- if (entryOptions === false) {
112
- return;
113
- }
71
+ if (!intermediateOptions) {
72
+ return;
73
+ }
114
74
 
115
- if (!entryOptions || entryOptions === true) {
116
- entryOptions = {
117
- preventDefault: [],
118
- routes: [],
119
- headers: {}
120
- };
121
- }
75
+ const ssgRoutes = []; // each route will try to match the configuration
122
76
 
77
+ pageRoutes.forEach(pageRoute => {
123
78
  const {
124
- preventDefault = [],
125
- routes: userRoutes = [],
126
- headers
127
- } = entryOptions; // if the user sets the routes, then only add them
128
-
129
- if (userRoutes.length > 0) {
130
- userRoutes.forEach(route => {
131
- if (typeof route === 'string') {
79
+ entryName,
80
+ entryPath
81
+ } = pageRoute;
82
+ const agreedRoutes = agreedRouteMap[entryName];
83
+ let entryOptions = intermediateOptions[entryName];
84
+
85
+ if (!agreedRoutes) {
86
+ // default behavior for non-agreed route
87
+ if (!entryOptions) {
88
+ return;
89
+ } // only add entry route if entryOptions is true
90
+
91
+
92
+ if (entryOptions === true) {
93
+ ssgRoutes.push(_objectSpread(_objectSpread({}, pageRoute), {}, {
94
+ output: entryPath
95
+ }));
96
+ } else if (entryOptions.routes && entryOptions.routes.length > 0) {
97
+ // if entryOptions is object and has routes options
98
+ // add every route in options
99
+ const {
100
+ routes: enrtyRoutes,
101
+ headers
102
+ } = entryOptions;
103
+ enrtyRoutes.forEach(route => {
132
104
  ssgRoutes.push(makeRoute(pageRoute, route, headers));
133
- } else if (Array.isArray(route.params)) {
134
- route.params.forEach(param => {
135
- ssgRoutes.push(makeRoute(pageRoute, _objectSpread(_objectSpread({}, route), {}, {
136
- url: generatePath(route.url, param)
137
- }), headers));
138
- });
139
- } else {
140
- ssgRoutes.push(makeRoute(pageRoute, route, headers));
141
- }
142
- });
105
+ });
106
+ }
143
107
  } else {
144
- // otherwith add all except dynamic routes
145
- agreedRoutes.filter(route => !preventDefault.includes(route.path)).forEach(route => {
146
- if (!isDynamicUrl(route.path)) {
147
- ssgRoutes.push(makeRoute(pageRoute, route.path, headers));
148
- }
149
- });
108
+ // Unless entryOptions is set to false
109
+ // the default behavior is to add all file-based routes
110
+ if (entryOptions === false) {
111
+ return;
112
+ }
113
+
114
+ if (!entryOptions || entryOptions === true) {
115
+ entryOptions = {
116
+ preventDefault: [],
117
+ routes: [],
118
+ headers: {}
119
+ };
120
+ }
121
+
122
+ const {
123
+ preventDefault = [],
124
+ routes: userRoutes = [],
125
+ headers
126
+ } = entryOptions; // if the user sets the routes, then only add them
127
+
128
+ if (userRoutes.length > 0) {
129
+ userRoutes.forEach(route => {
130
+ if (typeof route === 'string') {
131
+ ssgRoutes.push(makeRoute(pageRoute, route, headers));
132
+ } else if (Array.isArray(route.params)) {
133
+ route.params.forEach(param => {
134
+ ssgRoutes.push(makeRoute(pageRoute, _objectSpread(_objectSpread({}, route), {}, {
135
+ url: generatePath(route.url, param)
136
+ }), headers));
137
+ });
138
+ } else {
139
+ ssgRoutes.push(makeRoute(pageRoute, route, headers));
140
+ }
141
+ });
142
+ } else {
143
+ // otherwith add all except dynamic routes
144
+ agreedRoutes.filter(route => !preventDefault.includes(route.path)).forEach(route => {
145
+ if (!isDynamicUrl(route.path)) {
146
+ ssgRoutes.push(makeRoute(pageRoute, route.path, headers));
147
+ }
148
+ });
149
+ }
150
150
  }
151
- }
152
- });
151
+ });
153
152
 
154
- if (ssgRoutes.length === 0) {
155
- return;
156
- } // currently SSG and SSR cannot be turned on at the same time、same route
153
+ if (ssgRoutes.length === 0) {
154
+ return;
155
+ } // currently SSG and SSR cannot be turned on at the same time、same route
157
156
 
158
157
 
159
- ssgRoutes.forEach(ssgRoute => {
160
- if (ssgRoute.isSSR) {
161
- const isOriginRoute = pageRoutes.some(pageRoute => pageRoute.urlPath === ssgRoute.urlPath && pageRoute.entryName === ssgRoute.entryName);
158
+ ssgRoutes.forEach(ssgRoute => {
159
+ if (ssgRoute.isSSR) {
160
+ const isOriginRoute = pageRoutes.some(pageRoute => pageRoute.urlPath === ssgRoute.urlPath && pageRoute.entryName === ssgRoute.entryName);
162
161
 
163
- if (isOriginRoute) {
164
- throw new Error(`ssg can not using with ssr,url - ${ssgRoute.urlPath}, entry - ${ssgRoute.entryName} `);
165
- }
162
+ if (isOriginRoute) {
163
+ throw new Error(`ssg can not using with ssr,url - ${ssgRoute.urlPath}, entry - ${ssgRoute.entryName} `);
164
+ }
166
165
 
167
- logger.warn(`new ssg route ${ssgRoute.urlPath} is using ssr now,maybe from parent route ${ssgRoute.entryName},close ssr`);
168
- }
166
+ logger.warn(`new ssg route ${ssgRoute.urlPath} is using ssr now,maybe from parent route ${ssgRoute.entryName},close ssr`);
167
+ }
169
168
 
170
- ssgRoute.isSSR = false;
171
- ssgRoute.output = formatOutput(ssgRoute.output);
172
- });
173
- const htmlAry = await createServer(ssgRoutes, pageRoutes, apiRoutes, resolvedConfig, appDirectory); // write to dist file
169
+ ssgRoute.isSSR = false;
170
+ ssgRoute.output = formatOutput(ssgRoute.output);
171
+ });
172
+ const htmlAry = await createServer(ssgRoutes, pageRoutes, apiRoutes, resolvedConfig, appDirectory); // write to dist file
174
173
 
175
- writeHtmlFile(htmlAry, ssgRoutes, buildDir); // format route info, side effect
174
+ writeHtmlFile(htmlAry, ssgRoutes, buildDir); // format route info, side effect
176
175
 
177
- replaceRoute(ssgRoutes, pageRoutes); // write routes to spec file
176
+ replaceRoute(ssgRoutes, pageRoutes); // write routes to spec file
178
177
 
179
- writeJSONSpec(buildDir, pageRoutes.concat(apiRoutes));
180
- logger.info('ssg Compiled successfully');
181
- }
178
+ writeJSONSpec(buildDir, pageRoutes.concat(apiRoutes));
179
+ logger.info('ssg Compiled successfully');
180
+ }
182
181
 
183
- };
184
- }, {
185
- name: '@modern-js/plugin-ssg'
186
- });
182
+ };
183
+ }
184
+ }));
@@ -9,8 +9,6 @@ var _path = _interopRequireDefault(require("path"));
9
9
 
10
10
  var _utils = require("@modern-js/utils");
11
11
 
12
- var _core = require("@modern-js/core");
13
-
14
12
  var _reactRouterDom = require("react-router-dom");
15
13
 
16
14
  var _util = require("./libs/util");
@@ -31,178 +29,177 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
31
29
 
32
30
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
33
31
 
34
- var _default = (0, _core.createPlugin)(() => {
35
- const agreedRouteMap = {};
36
- return {
37
- validateSchema() {
38
- return _utils.PLUGIN_SCHEMAS['@modern-js/plugin-ssg'];
39
- },
40
-
41
- modifyFileSystemRoutes({
42
- entrypoint,
43
- routes
44
- }) {
45
- const {
46
- entryName
47
- } = entrypoint;
48
- agreedRouteMap[entryName] = routes;
49
- return {
32
+ var _default = () => ({
33
+ name: '@modern-js/plugin-ssg',
34
+ setup: api => {
35
+ const agreedRouteMap = {};
36
+ return {
37
+ validateSchema() {
38
+ return _utils.PLUGIN_SCHEMAS['@modern-js/plugin-ssg'];
39
+ },
40
+
41
+ modifyFileSystemRoutes({
50
42
  entrypoint,
51
43
  routes
52
- };
53
- },
54
-
55
- // eslint-disable-next-line max-statements
56
- async afterBuild() {
57
- // eslint-disable-next-line react-hooks/rules-of-hooks
58
- const resolvedConfig = (0, _core.useResolvedConfigContext)(); // eslint-disable-next-line react-hooks/rules-of-hooks
59
-
60
- const appContext = (0, _core.useAppContext)();
61
- const {
62
- appDirectory,
63
- entrypoints
64
- } = appContext;
65
- const {
66
- output
67
- } = resolvedConfig;
68
- const {
69
- ssg,
70
- path: outputPath
71
- } = output;
72
- const ssgOptions = Array.isArray(ssg) ? ssg.pop() : ssg; // no ssg configuration, skip ssg render.
73
-
74
- if (!ssgOptions) {
75
- return;
76
- }
77
-
78
- const buildDir = _path.default.join(appDirectory, outputPath);
44
+ }) {
45
+ const {
46
+ entryName
47
+ } = entrypoint;
48
+ agreedRouteMap[entryName] = routes;
49
+ return {
50
+ entrypoint,
51
+ routes
52
+ };
53
+ },
54
+
55
+ // eslint-disable-next-line max-statements
56
+ async afterBuild() {
57
+ const resolvedConfig = api.useResolvedConfigContext();
58
+ const appContext = api.useAppContext();
59
+ const {
60
+ appDirectory,
61
+ entrypoints
62
+ } = appContext;
63
+ const {
64
+ output
65
+ } = resolvedConfig;
66
+ const {
67
+ ssg,
68
+ path: outputPath
69
+ } = output;
70
+ const ssgOptions = Array.isArray(ssg) ? ssg.pop() : ssg; // no ssg configuration, skip ssg render.
79
71
 
80
- const routes = (0, _util.readJSONSpec)(buildDir); // filter all routes not web
72
+ if (!ssgOptions) {
73
+ return;
74
+ }
81
75
 
82
- const pageRoutes = routes.filter(route => !route.isApi);
83
- const apiRoutes = routes.filter(route => route.isApi); // if no web page route, skip ssg render
76
+ const buildDir = _path.default.join(appDirectory, outputPath);
84
77
 
85
- if (pageRoutes.length === 0) {
86
- return;
87
- }
78
+ const routes = (0, _util.readJSONSpec)(buildDir); // filter all routes not web
88
79
 
89
- const intermediateOptions = (0, _util.standardOptions)(ssgOptions, entrypoints);
80
+ const pageRoutes = routes.filter(route => !route.isApi);
81
+ const apiRoutes = routes.filter(route => route.isApi); // if no web page route, skip ssg render
90
82
 
91
- if (!intermediateOptions) {
92
- return;
93
- }
83
+ if (pageRoutes.length === 0) {
84
+ return;
85
+ }
94
86
 
95
- const ssgRoutes = []; // each route will try to match the configuration
87
+ const intermediateOptions = (0, _util.standardOptions)(ssgOptions, entrypoints);
96
88
 
97
- pageRoutes.forEach(pageRoute => {
98
- const {
99
- entryName,
100
- entryPath
101
- } = pageRoute;
102
- const agreedRoutes = agreedRouteMap[entryName];
103
- let entryOptions = intermediateOptions[entryName];
104
-
105
- if (!agreedRoutes) {
106
- // default behavior for non-agreed route
107
- if (!entryOptions) {
108
- return;
109
- } // only add entry route if entryOptions is true
110
-
111
-
112
- if (entryOptions === true) {
113
- ssgRoutes.push(_objectSpread(_objectSpread({}, pageRoute), {}, {
114
- output: entryPath
115
- }));
116
- } else if (entryOptions.routes && entryOptions.routes.length > 0) {
117
- // if entryOptions is object and has routes options
118
- // add every route in options
119
- const {
120
- routes: enrtyRoutes,
121
- headers
122
- } = entryOptions;
123
- enrtyRoutes.forEach(route => {
124
- ssgRoutes.push((0, _make.makeRoute)(pageRoute, route, headers));
125
- });
126
- }
127
- } else {
128
- // Unless entryOptions is set to false
129
- // the default behavior is to add all file-based routes
130
- if (entryOptions === false) {
131
- return;
132
- }
89
+ if (!intermediateOptions) {
90
+ return;
91
+ }
133
92
 
134
- if (!entryOptions || entryOptions === true) {
135
- entryOptions = {
136
- preventDefault: [],
137
- routes: [],
138
- headers: {}
139
- };
140
- }
93
+ const ssgRoutes = []; // each route will try to match the configuration
141
94
 
95
+ pageRoutes.forEach(pageRoute => {
142
96
  const {
143
- preventDefault = [],
144
- routes: userRoutes = [],
145
- headers
146
- } = entryOptions; // if the user sets the routes, then only add them
147
-
148
- if (userRoutes.length > 0) {
149
- userRoutes.forEach(route => {
150
- if (typeof route === 'string') {
151
- ssgRoutes.push((0, _make.makeRoute)(pageRoute, route, headers));
152
- } else if (Array.isArray(route.params)) {
153
- route.params.forEach(param => {
154
- ssgRoutes.push((0, _make.makeRoute)(pageRoute, _objectSpread(_objectSpread({}, route), {}, {
155
- url: (0, _reactRouterDom.generatePath)(route.url, param)
156
- }), headers));
157
- });
158
- } else {
97
+ entryName,
98
+ entryPath
99
+ } = pageRoute;
100
+ const agreedRoutes = agreedRouteMap[entryName];
101
+ let entryOptions = intermediateOptions[entryName];
102
+
103
+ if (!agreedRoutes) {
104
+ // default behavior for non-agreed route
105
+ if (!entryOptions) {
106
+ return;
107
+ } // only add entry route if entryOptions is true
108
+
109
+
110
+ if (entryOptions === true) {
111
+ ssgRoutes.push(_objectSpread(_objectSpread({}, pageRoute), {}, {
112
+ output: entryPath
113
+ }));
114
+ } else if (entryOptions.routes && entryOptions.routes.length > 0) {
115
+ // if entryOptions is object and has routes options
116
+ // add every route in options
117
+ const {
118
+ routes: enrtyRoutes,
119
+ headers
120
+ } = entryOptions;
121
+ enrtyRoutes.forEach(route => {
159
122
  ssgRoutes.push((0, _make.makeRoute)(pageRoute, route, headers));
160
- }
161
- });
123
+ });
124
+ }
162
125
  } else {
163
- // otherwith add all except dynamic routes
164
- agreedRoutes.filter(route => !preventDefault.includes(route.path)).forEach(route => {
165
- if (!(0, _util.isDynamicUrl)(route.path)) {
166
- ssgRoutes.push((0, _make.makeRoute)(pageRoute, route.path, headers));
167
- }
168
- });
126
+ // Unless entryOptions is set to false
127
+ // the default behavior is to add all file-based routes
128
+ if (entryOptions === false) {
129
+ return;
130
+ }
131
+
132
+ if (!entryOptions || entryOptions === true) {
133
+ entryOptions = {
134
+ preventDefault: [],
135
+ routes: [],
136
+ headers: {}
137
+ };
138
+ }
139
+
140
+ const {
141
+ preventDefault = [],
142
+ routes: userRoutes = [],
143
+ headers
144
+ } = entryOptions; // if the user sets the routes, then only add them
145
+
146
+ if (userRoutes.length > 0) {
147
+ userRoutes.forEach(route => {
148
+ if (typeof route === 'string') {
149
+ ssgRoutes.push((0, _make.makeRoute)(pageRoute, route, headers));
150
+ } else if (Array.isArray(route.params)) {
151
+ route.params.forEach(param => {
152
+ ssgRoutes.push((0, _make.makeRoute)(pageRoute, _objectSpread(_objectSpread({}, route), {}, {
153
+ url: (0, _reactRouterDom.generatePath)(route.url, param)
154
+ }), headers));
155
+ });
156
+ } else {
157
+ ssgRoutes.push((0, _make.makeRoute)(pageRoute, route, headers));
158
+ }
159
+ });
160
+ } else {
161
+ // otherwith add all except dynamic routes
162
+ agreedRoutes.filter(route => !preventDefault.includes(route.path)).forEach(route => {
163
+ if (!(0, _util.isDynamicUrl)(route.path)) {
164
+ ssgRoutes.push((0, _make.makeRoute)(pageRoute, route.path, headers));
165
+ }
166
+ });
167
+ }
169
168
  }
170
- }
171
- });
169
+ });
172
170
 
173
- if (ssgRoutes.length === 0) {
174
- return;
175
- } // currently SSG and SSR cannot be turned on at the same time、same route
171
+ if (ssgRoutes.length === 0) {
172
+ return;
173
+ } // currently SSG and SSR cannot be turned on at the same time、same route
176
174
 
177
175
 
178
- ssgRoutes.forEach(ssgRoute => {
179
- if (ssgRoute.isSSR) {
180
- const isOriginRoute = pageRoutes.some(pageRoute => pageRoute.urlPath === ssgRoute.urlPath && pageRoute.entryName === ssgRoute.entryName);
176
+ ssgRoutes.forEach(ssgRoute => {
177
+ if (ssgRoute.isSSR) {
178
+ const isOriginRoute = pageRoutes.some(pageRoute => pageRoute.urlPath === ssgRoute.urlPath && pageRoute.entryName === ssgRoute.entryName);
181
179
 
182
- if (isOriginRoute) {
183
- throw new Error(`ssg can not using with ssr,url - ${ssgRoute.urlPath}, entry - ${ssgRoute.entryName} `);
184
- }
180
+ if (isOriginRoute) {
181
+ throw new Error(`ssg can not using with ssr,url - ${ssgRoute.urlPath}, entry - ${ssgRoute.entryName} `);
182
+ }
185
183
 
186
- _utils.logger.warn(`new ssg route ${ssgRoute.urlPath} is using ssr now,maybe from parent route ${ssgRoute.entryName},close ssr`);
187
- }
184
+ _utils.logger.warn(`new ssg route ${ssgRoute.urlPath} is using ssr now,maybe from parent route ${ssgRoute.entryName},close ssr`);
185
+ }
188
186
 
189
- ssgRoute.isSSR = false;
190
- ssgRoute.output = (0, _util.formatOutput)(ssgRoute.output);
191
- });
192
- const htmlAry = await (0, _server.createServer)(ssgRoutes, pageRoutes, apiRoutes, resolvedConfig, appDirectory); // write to dist file
187
+ ssgRoute.isSSR = false;
188
+ ssgRoute.output = (0, _util.formatOutput)(ssgRoute.output);
189
+ });
190
+ const htmlAry = await (0, _server.createServer)(ssgRoutes, pageRoutes, apiRoutes, resolvedConfig, appDirectory); // write to dist file
193
191
 
194
- (0, _output.writeHtmlFile)(htmlAry, ssgRoutes, buildDir); // format route info, side effect
192
+ (0, _output.writeHtmlFile)(htmlAry, ssgRoutes, buildDir); // format route info, side effect
195
193
 
196
- (0, _replace.replaceRoute)(ssgRoutes, pageRoutes); // write routes to spec file
194
+ (0, _replace.replaceRoute)(ssgRoutes, pageRoutes); // write routes to spec file
197
195
 
198
- (0, _util.writeJSONSpec)(buildDir, pageRoutes.concat(apiRoutes));
196
+ (0, _util.writeJSONSpec)(buildDir, pageRoutes.concat(apiRoutes));
199
197
 
200
- _utils.logger.info('ssg Compiled successfully');
201
- }
198
+ _utils.logger.info('ssg Compiled successfully');
199
+ }
202
200
 
203
- };
204
- }, {
205
- name: '@modern-js/plugin-ssg'
201
+ };
202
+ }
206
203
  });
207
204
 
208
205
  exports.default = _default;
@@ -1,3 +1,5 @@
1
- declare const _default: any;
1
+ import type { CliPlugin } from '@modern-js/core';
2
+
3
+ declare const _default: () => CliPlugin;
2
4
 
3
5
  export default _default;
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.2.5",
14
+ "version": "1.2.6",
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.4",
58
+ "@modern-js/utils": "^1.3.5",
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.4",
66
- "@modern-js/prod-server": "^1.0.2",
65
+ "@modern-js/types": "^1.3.5",
66
+ "@modern-js/prod-server": "^1.0.4",
67
67
  "@types/jest": "^26",
68
68
  "@types/node": "^14",
69
69
  "@types/react": "^17",
@@ -71,14 +71,11 @@
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.4.6",
74
+ "@modern-js/core": "^1.5.0",
75
75
  "@scripts/build": "0.0.0",
76
76
  "jest": "^27",
77
77
  "@scripts/jest-config": "0.0.0"
78
78
  },
79
- "peerDependencies": {
80
- "@modern-js/core": "^1.4.6"
81
- },
82
79
  "sideEffects": false,
83
80
  "modernConfig": {
84
81
  "output": {
@@ -3,5 +3,6 @@ import plugin from '../src';
3
3
  describe('plugin-ssg', () => {
4
4
  it('default', () => {
5
5
  expect(plugin).toBeDefined();
6
+ expect(plugin().name).toBe('@modern-js/plugin-ssg');
6
7
  });
7
8
  });