@modern-js/app-tools 2.0.0-beta.0 → 2.0.0-beta.1
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 +181 -0
- package/dist/js/modern/analyze/generateCode.js +29 -37
- package/dist/js/modern/analyze/getBundleEntry.js +4 -12
- package/dist/js/modern/analyze/getClientRoutes/getRoutes.js +5 -30
- package/dist/js/modern/analyze/getClientRoutes/getRoutesLegacy.js +5 -30
- package/dist/js/modern/analyze/getClientRoutes/utils.js +0 -3
- package/dist/js/modern/analyze/getFileSystemEntry.js +4 -17
- package/dist/js/modern/analyze/getHtmlTemplate.js +2 -9
- package/dist/js/modern/analyze/getServerRoutes.js +15 -32
- package/dist/js/modern/analyze/index.js +79 -22
- package/dist/js/modern/analyze/isDefaultExportFunction.js +0 -4
- package/dist/js/modern/analyze/makeLegalIdentifier.js +0 -2
- package/dist/js/modern/analyze/nestedRoutes.js +8 -33
- package/dist/js/modern/analyze/templates.js +22 -37
- package/dist/js/modern/analyze/utils.js +0 -7
- package/dist/js/modern/builder/builderPlugins/compatModern.js +30 -48
- package/dist/js/modern/builder/createHtmlConfig.js +2 -2
- package/dist/js/modern/builder/createOutputConfig.js +7 -4
- package/dist/js/modern/builder/createSourceConfig.js +0 -11
- package/dist/js/modern/builder/createToolsConfig.js +3 -10
- package/dist/js/modern/builder/index.js +24 -22
- package/dist/js/modern/builder/share.js +0 -4
- package/dist/js/modern/builder/webpackPlugins/htmlAsyncChunkPlugin.js +0 -8
- package/dist/js/modern/builder/webpackPlugins/htmlBottomTemplate.js +2 -13
- package/dist/js/modern/builder/webpackPlugins/routerPlugin.js +97 -0
- package/dist/js/modern/commands/build.js +6 -46
- package/dist/js/modern/commands/dev.js +4 -16
- package/dist/js/modern/commands/inspect.js +3 -20
- package/dist/js/modern/commands/start.js +0 -2
- package/dist/js/modern/index.js +6 -15
- package/dist/js/modern/utils/config.js +1 -12
- package/dist/js/modern/utils/createServer.js +0 -5
- package/dist/js/modern/utils/getSpecifiedEntries.js +0 -6
- package/dist/js/modern/utils/printInstructions.js +2 -1
- package/dist/js/modern/utils/routes.js +0 -2
- package/dist/js/node/analyze/generateCode.js +29 -60
- package/dist/js/node/analyze/getBundleEntry.js +4 -18
- package/dist/js/node/analyze/getClientRoutes/getRoutes.js +5 -45
- package/dist/js/node/analyze/getClientRoutes/getRoutesLegacy.js +5 -45
- package/dist/js/node/analyze/getClientRoutes/index.js +0 -2
- package/dist/js/node/analyze/getClientRoutes/utils.js +0 -14
- package/dist/js/node/analyze/getFileSystemEntry.js +4 -25
- package/dist/js/node/analyze/getHtmlTemplate.js +2 -23
- package/dist/js/node/analyze/getServerRoutes.js +14 -40
- package/dist/js/node/analyze/index.js +79 -32
- package/dist/js/node/analyze/isDefaultExportFunction.js +0 -12
- package/dist/js/node/analyze/makeLegalIdentifier.js +0 -4
- package/dist/js/node/analyze/nestedRoutes.js +8 -41
- package/dist/js/node/analyze/templates.js +22 -47
- package/dist/js/node/analyze/utils.js +0 -20
- package/dist/js/node/builder/builderPlugins/compatModern.js +30 -59
- package/dist/js/node/builder/createHtmlConfig.js +2 -10
- package/dist/js/node/builder/createOutputConfig.js +7 -6
- package/dist/js/node/builder/createSourceConfig.js +0 -17
- package/dist/js/node/builder/createToolsConfig.js +3 -12
- package/dist/js/node/builder/index.js +24 -36
- package/dist/js/node/builder/share.js +0 -12
- package/dist/js/node/builder/webpackPlugins/htmlAsyncChunkPlugin.js +0 -10
- package/dist/js/node/builder/webpackPlugins/htmlBottomTemplate.js +2 -15
- package/dist/js/node/builder/webpackPlugins/routerPlugin.js +105 -0
- package/dist/js/node/commands/build.js +4 -57
- package/dist/js/node/commands/deploy.js +0 -2
- package/dist/js/node/commands/dev.js +3 -27
- package/dist/js/node/commands/index.js +0 -6
- package/dist/js/node/commands/inspect.js +3 -27
- package/dist/js/node/commands/start.js +0 -11
- package/dist/js/node/exports/server.js +0 -1
- package/dist/js/node/hooks.js +0 -2
- package/dist/js/node/index.js +7 -34
- package/dist/js/node/locale/index.js +0 -4
- package/dist/js/node/utils/commands.js +0 -2
- package/dist/js/node/utils/config.js +1 -25
- package/dist/js/node/utils/createServer.js +0 -15
- package/dist/js/node/utils/getSpecifiedEntries.js +0 -9
- package/dist/js/node/utils/language.js +0 -2
- package/dist/js/node/utils/printInstructions.js +2 -5
- package/dist/js/node/utils/routes.js +0 -5
- package/dist/js/treeshaking/analyze/generateCode.js +57 -100
- package/dist/js/treeshaking/analyze/getBundleEntry.js +11 -19
- package/dist/js/treeshaking/analyze/getClientRoutes/getRoutes.js +16 -42
- package/dist/js/treeshaking/analyze/getClientRoutes/getRoutesLegacy.js +16 -42
- package/dist/js/treeshaking/analyze/getClientRoutes/utils.js +0 -3
- package/dist/js/treeshaking/analyze/getFileSystemEntry.js +4 -17
- package/dist/js/treeshaking/analyze/getHtmlTemplate.js +2 -26
- package/dist/js/treeshaking/analyze/getServerRoutes.js +24 -37
- package/dist/js/treeshaking/analyze/index.js +185 -65
- package/dist/js/treeshaking/analyze/isDefaultExportFunction.js +0 -4
- package/dist/js/treeshaking/analyze/makeLegalIdentifier.js +0 -2
- package/dist/js/treeshaking/analyze/nestedRoutes.js +9 -51
- package/dist/js/treeshaking/analyze/templates.js +31 -50
- package/dist/js/treeshaking/analyze/utils.js +7 -14
- package/dist/js/treeshaking/builder/builderPlugins/compatModern.js +40 -59
- package/dist/js/treeshaking/builder/createHtmlConfig.js +15 -15
- package/dist/js/treeshaking/builder/createOutputConfig.js +26 -23
- package/dist/js/treeshaking/builder/createSourceConfig.js +7 -19
- package/dist/js/treeshaking/builder/createToolsConfig.js +16 -21
- package/dist/js/treeshaking/builder/index.js +38 -49
- package/dist/js/treeshaking/builder/share.js +0 -4
- package/dist/js/treeshaking/builder/webpackPlugins/htmlAsyncChunkPlugin.js +1 -13
- package/dist/js/treeshaking/builder/webpackPlugins/htmlBottomTemplate.js +2 -14
- package/dist/js/treeshaking/builder/webpackPlugins/routerPlugin.js +121 -0
- package/dist/js/treeshaking/commands/build.js +26 -111
- package/dist/js/treeshaking/commands/deploy.js +0 -3
- package/dist/js/treeshaking/commands/dev.js +13 -35
- package/dist/js/treeshaking/commands/inspect.js +5 -28
- package/dist/js/treeshaking/commands/start.js +0 -9
- package/dist/js/treeshaking/index.js +2 -39
- package/dist/js/treeshaking/utils/config.js +1 -17
- package/dist/js/treeshaking/utils/createServer.js +0 -10
- package/dist/js/treeshaking/utils/getSpecifiedEntries.js +0 -10
- package/dist/js/treeshaking/utils/printInstructions.js +0 -5
- package/dist/js/treeshaking/utils/routes.js +0 -4
- package/dist/types/analyze/index.d.ts +2 -3
- package/dist/types/analyze/nestedRoutes.d.ts +1 -1
- package/dist/types/analyze/templates.d.ts +3 -1
- package/dist/types/builder/builderPlugins/compatModern.d.ts +0 -1
- package/dist/types/builder/index.d.ts +2 -6
- package/dist/types/builder/webpackPlugins/routerPlugin.d.ts +10 -0
- package/dist/types/commands/inspect.d.ts +1 -4
- package/dist/types/index.d.ts +0 -2
- package/dist/types/utils/config.d.ts +0 -1
- package/package.json +23 -22
- package/dist/js/modern/utils/createCompiler.js +0 -58
- package/dist/js/node/utils/createCompiler.js +0 -75
- package/dist/js/treeshaking/utils/createCompiler.js +0 -117
- package/dist/types/utils/createCompiler.d.ts +0 -12
|
@@ -3,7 +3,7 @@ import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
|
3
3
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
4
4
|
import path from 'path';
|
|
5
5
|
import { defineConfig, cli } from '@modern-js/core';
|
|
6
|
-
import LintPlugin from '@modern-js/plugin-
|
|
6
|
+
import LintPlugin from '@modern-js/plugin-lint';
|
|
7
7
|
import { cleanRequireCache, emptyDir, Import } from '@modern-js/utils';
|
|
8
8
|
import AnalyzePlugin from "./analyze";
|
|
9
9
|
import { hooks } from "./hooks";
|
|
@@ -15,7 +15,7 @@ var upgradeModel = Import.lazy('@modern-js/upgrade', require);
|
|
|
15
15
|
export default (function () {
|
|
16
16
|
return {
|
|
17
17
|
name: '@modern-js/app-tools',
|
|
18
|
-
post: ['@modern-js/plugin-analyze', '@modern-js/plugin-ssr', '@modern-js/plugin-state', '@modern-js/plugin-router', '@modern-js/plugin-router-legacy', '@modern-js/plugin-polyfill'],
|
|
18
|
+
post: ['@modern-js/plugin-analyze', '@modern-js/plugin-ssr', '@modern-js/plugin-document', '@modern-js/plugin-state', '@modern-js/plugin-router', '@modern-js/plugin-router-legacy', '@modern-js/plugin-polyfill'],
|
|
19
19
|
registerHook: hooks,
|
|
20
20
|
usePlugins: [AnalyzePlugin(), LintPlugin()],
|
|
21
21
|
setup: function setup(api) {
|
|
@@ -29,20 +29,17 @@ export default (function () {
|
|
|
29
29
|
program.command('dev').usage('[options]').description(i18n.t(localeKeys.command.dev.describe)).option('-c --config <config>', i18n.t(localeKeys.command.shared.config)).option('-e --entry [entry...]', i18n.t(localeKeys.command.dev.entry)).option('--analyze', i18n.t(localeKeys.command.shared.analyze)).option('--api-only', i18n.t(localeKeys.command.dev.apiOnly)).action( /*#__PURE__*/function () {
|
|
30
30
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
|
|
31
31
|
var _yield$import, dev;
|
|
32
|
-
|
|
33
32
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
34
33
|
while (1) {
|
|
35
34
|
switch (_context.prev = _context.next) {
|
|
36
35
|
case 0:
|
|
37
36
|
_context.next = 2;
|
|
38
37
|
return import("./commands/dev");
|
|
39
|
-
|
|
40
38
|
case 2:
|
|
41
39
|
_yield$import = _context.sent;
|
|
42
40
|
dev = _yield$import.dev;
|
|
43
41
|
_context.next = 6;
|
|
44
42
|
return dev(api, options);
|
|
45
|
-
|
|
46
43
|
case 6:
|
|
47
44
|
case "end":
|
|
48
45
|
return _context.stop();
|
|
@@ -50,7 +47,6 @@ export default (function () {
|
|
|
50
47
|
}
|
|
51
48
|
}, _callee);
|
|
52
49
|
}));
|
|
53
|
-
|
|
54
50
|
return function (_x) {
|
|
55
51
|
return _ref2.apply(this, arguments);
|
|
56
52
|
};
|
|
@@ -58,25 +54,21 @@ export default (function () {
|
|
|
58
54
|
program.command('build').usage('[options]').description(i18n.t(localeKeys.command.build.describe)).option('-c --config <config>', i18n.t(localeKeys.command.shared.config)).option('--analyze', i18n.t(localeKeys.command.shared.analyze)).action( /*#__PURE__*/function () {
|
|
59
55
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options) {
|
|
60
56
|
var _yield$import2, build;
|
|
61
|
-
|
|
62
57
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
63
58
|
while (1) {
|
|
64
59
|
switch (_context2.prev = _context2.next) {
|
|
65
60
|
case 0:
|
|
66
61
|
_context2.next = 2;
|
|
67
62
|
return import("./commands/build");
|
|
68
|
-
|
|
69
63
|
case 2:
|
|
70
64
|
_yield$import2 = _context2.sent;
|
|
71
65
|
build = _yield$import2.build;
|
|
72
66
|
_context2.next = 6;
|
|
73
67
|
return build(api, options);
|
|
74
|
-
|
|
75
68
|
case 6:
|
|
76
69
|
// force exit after build.
|
|
77
70
|
// eslint-disable-next-line no-process-exit
|
|
78
71
|
process.exit(0);
|
|
79
|
-
|
|
80
72
|
case 7:
|
|
81
73
|
case "end":
|
|
82
74
|
return _context2.stop();
|
|
@@ -84,27 +76,23 @@ export default (function () {
|
|
|
84
76
|
}
|
|
85
77
|
}, _callee2);
|
|
86
78
|
}));
|
|
87
|
-
|
|
88
79
|
return function (_x2) {
|
|
89
80
|
return _ref3.apply(this, arguments);
|
|
90
81
|
};
|
|
91
82
|
}());
|
|
92
83
|
program.command('start').usage('[options]').description(i18n.t(localeKeys.command.start.describe)).option('--api-only', i18n.t(localeKeys.command.dev.apiOnly)).option('-c --config <config>', i18n.t(localeKeys.command.shared.config)).action( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
93
84
|
var _yield$import3, start;
|
|
94
|
-
|
|
95
85
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
96
86
|
while (1) {
|
|
97
87
|
switch (_context3.prev = _context3.next) {
|
|
98
88
|
case 0:
|
|
99
89
|
_context3.next = 2;
|
|
100
90
|
return import("./commands/start");
|
|
101
|
-
|
|
102
91
|
case 2:
|
|
103
92
|
_yield$import3 = _context3.sent;
|
|
104
93
|
start = _yield$import3.start;
|
|
105
94
|
_context3.next = 6;
|
|
106
95
|
return start(api);
|
|
107
|
-
|
|
108
96
|
case 6:
|
|
109
97
|
case "end":
|
|
110
98
|
return _context3.stop();
|
|
@@ -115,34 +103,28 @@ export default (function () {
|
|
|
115
103
|
program.command('deploy').usage('[options]').option('-c --config <config>', i18n.t(localeKeys.command.shared.config)).description(i18n.t(localeKeys.command.deploy.describe)).action( /*#__PURE__*/function () {
|
|
116
104
|
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(options) {
|
|
117
105
|
var _yield$import4, build, _yield$import5, deploy;
|
|
118
|
-
|
|
119
106
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
120
107
|
while (1) {
|
|
121
108
|
switch (_context4.prev = _context4.next) {
|
|
122
109
|
case 0:
|
|
123
110
|
_context4.next = 2;
|
|
124
111
|
return import("./commands/build");
|
|
125
|
-
|
|
126
112
|
case 2:
|
|
127
113
|
_yield$import4 = _context4.sent;
|
|
128
114
|
build = _yield$import4.build;
|
|
129
115
|
_context4.next = 6;
|
|
130
116
|
return build(api);
|
|
131
|
-
|
|
132
117
|
case 6:
|
|
133
118
|
_context4.next = 8;
|
|
134
119
|
return import("./commands/deploy");
|
|
135
|
-
|
|
136
120
|
case 8:
|
|
137
121
|
_yield$import5 = _context4.sent;
|
|
138
122
|
deploy = _yield$import5.deploy;
|
|
139
123
|
_context4.next = 12;
|
|
140
124
|
return deploy(api, options);
|
|
141
|
-
|
|
142
125
|
case 12:
|
|
143
126
|
// eslint-disable-next-line no-process-exit
|
|
144
127
|
process.exit(0);
|
|
145
|
-
|
|
146
128
|
case 13:
|
|
147
129
|
case "end":
|
|
148
130
|
return _context4.stop();
|
|
@@ -150,7 +132,6 @@ export default (function () {
|
|
|
150
132
|
}
|
|
151
133
|
}, _callee4);
|
|
152
134
|
}));
|
|
153
|
-
|
|
154
135
|
return function (_x3) {
|
|
155
136
|
return _ref5.apply(this, arguments);
|
|
156
137
|
};
|
|
@@ -158,14 +139,12 @@ export default (function () {
|
|
|
158
139
|
program.command('new').usage('[options]').description(i18n.t(localeKeys.command["new"].describe)).option('-d, --debug', i18n.t(localeKeys.command["new"].debug), false).option('-c, --config <config>', i18n.t(localeKeys.command["new"].config)).option('--dist-tag <tag>', i18n.t(localeKeys.command["new"].distTag)).option('--registry', i18n.t(localeKeys.command["new"].registry)).action( /*#__PURE__*/function () {
|
|
159
140
|
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(options) {
|
|
160
141
|
var _yield$import6, MWANewAction;
|
|
161
|
-
|
|
162
142
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
163
143
|
while (1) {
|
|
164
144
|
switch (_context5.prev = _context5.next) {
|
|
165
145
|
case 0:
|
|
166
146
|
_context5.next = 2;
|
|
167
147
|
return import('@modern-js/new-action');
|
|
168
|
-
|
|
169
148
|
case 2:
|
|
170
149
|
_yield$import6 = _context5.sent;
|
|
171
150
|
MWANewAction = _yield$import6.MWANewAction;
|
|
@@ -173,7 +152,6 @@ export default (function () {
|
|
|
173
152
|
return MWANewAction(_objectSpread(_objectSpread({}, options), {}, {
|
|
174
153
|
locale: locale
|
|
175
154
|
}));
|
|
176
|
-
|
|
177
155
|
case 6:
|
|
178
156
|
case "end":
|
|
179
157
|
return _context5.stop();
|
|
@@ -181,7 +159,6 @@ export default (function () {
|
|
|
181
159
|
}
|
|
182
160
|
}, _callee5);
|
|
183
161
|
}));
|
|
184
|
-
|
|
185
162
|
return function (_x4) {
|
|
186
163
|
return _ref6.apply(this, arguments);
|
|
187
164
|
};
|
|
@@ -189,19 +166,16 @@ export default (function () {
|
|
|
189
166
|
program.command('inspect').description('inspect internal webpack config').option("--env <env>", i18n.t(localeKeys.command.inspect.env), 'development').option('--output <output>', i18n.t(localeKeys.command.inspect.output), '/').option('--verbose', i18n.t(localeKeys.command.inspect.verbose)).option('-c --config <config>', i18n.t(localeKeys.command.shared.config)).action( /*#__PURE__*/function () {
|
|
190
167
|
var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(options) {
|
|
191
168
|
var _yield$import7, inspect;
|
|
192
|
-
|
|
193
169
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
194
170
|
while (1) {
|
|
195
171
|
switch (_context6.prev = _context6.next) {
|
|
196
172
|
case 0:
|
|
197
173
|
_context6.next = 2;
|
|
198
174
|
return import("./commands/inspect");
|
|
199
|
-
|
|
200
175
|
case 2:
|
|
201
176
|
_yield$import7 = _context6.sent;
|
|
202
177
|
inspect = _yield$import7.inspect;
|
|
203
178
|
inspect(api, options);
|
|
204
|
-
|
|
205
179
|
case 5:
|
|
206
180
|
case "end":
|
|
207
181
|
return _context6.stop();
|
|
@@ -209,7 +183,6 @@ export default (function () {
|
|
|
209
183
|
}
|
|
210
184
|
}, _callee6);
|
|
211
185
|
}));
|
|
212
|
-
|
|
213
186
|
return function (_x5) {
|
|
214
187
|
return _ref7.apply(this, arguments);
|
|
215
188
|
};
|
|
@@ -224,16 +197,13 @@ export default (function () {
|
|
|
224
197
|
switch (_context7.prev = _context7.next) {
|
|
225
198
|
case 0:
|
|
226
199
|
command = getCommand();
|
|
227
|
-
|
|
228
200
|
if (!(command === 'dev' || command === 'build')) {
|
|
229
201
|
_context7.next = 5;
|
|
230
202
|
break;
|
|
231
203
|
}
|
|
232
|
-
|
|
233
204
|
appContext = api.useAppContext();
|
|
234
205
|
_context7.next = 5;
|
|
235
206
|
return emptyDir(appContext.distDirectory);
|
|
236
|
-
|
|
237
207
|
case 5:
|
|
238
208
|
case "end":
|
|
239
209
|
return _context7.stop();
|
|
@@ -246,7 +216,6 @@ export default (function () {
|
|
|
246
216
|
fileChange: function fileChange(e) {
|
|
247
217
|
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
248
218
|
var filename, eventType, appContext, appDirectory, srcDirectory, absolutePath, _yield$import8, closeServer;
|
|
249
|
-
|
|
250
219
|
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
251
220
|
while (1) {
|
|
252
221
|
switch (_context8.prev = _context8.next) {
|
|
@@ -255,25 +224,20 @@ export default (function () {
|
|
|
255
224
|
appContext = api.useAppContext();
|
|
256
225
|
appDirectory = appContext.appDirectory, srcDirectory = appContext.srcDirectory;
|
|
257
226
|
absolutePath = path.resolve(appDirectory, filename);
|
|
258
|
-
|
|
259
227
|
if (!(!absolutePath.includes(srcDirectory) && (eventType === 'change' || eventType === 'unlink'))) {
|
|
260
228
|
_context8.next = 13;
|
|
261
229
|
break;
|
|
262
230
|
}
|
|
263
|
-
|
|
264
231
|
_context8.next = 7;
|
|
265
232
|
return import("./utils/createServer");
|
|
266
|
-
|
|
267
233
|
case 7:
|
|
268
234
|
_yield$import8 = _context8.sent;
|
|
269
235
|
closeServer = _yield$import8.closeServer;
|
|
270
236
|
_context8.next = 11;
|
|
271
237
|
return closeServer();
|
|
272
|
-
|
|
273
238
|
case 11:
|
|
274
239
|
_context8.next = 13;
|
|
275
240
|
return cli.restart();
|
|
276
|
-
|
|
277
241
|
case 13:
|
|
278
242
|
case "end":
|
|
279
243
|
return _context8.stop();
|
|
@@ -289,7 +253,6 @@ export default (function () {
|
|
|
289
253
|
switch (_context9.prev = _context9.next) {
|
|
290
254
|
case 0:
|
|
291
255
|
cleanRequireCache([require.resolve("./analyze")]);
|
|
292
|
-
|
|
293
256
|
case 1:
|
|
294
257
|
case "end":
|
|
295
258
|
return _context9.stop();
|
|
@@ -18,10 +18,8 @@ export var buildServerConfig = /*#__PURE__*/function () {
|
|
|
18
18
|
appDirectory = _ref.appDirectory, distDirectory = _ref.distDirectory, configFile = _ref.configFile, options = _ref.options;
|
|
19
19
|
_context2.next = 3;
|
|
20
20
|
return getServerConfig(appDirectory, configFile);
|
|
21
|
-
|
|
22
21
|
case 3:
|
|
23
22
|
configFilePath = _context2.sent;
|
|
24
|
-
|
|
25
23
|
getOutputFile = /*#__PURE__*/function () {
|
|
26
24
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(filepath) {
|
|
27
25
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
@@ -29,7 +27,6 @@ export var buildServerConfig = /*#__PURE__*/function () {
|
|
|
29
27
|
switch (_context.prev = _context.next) {
|
|
30
28
|
case 0:
|
|
31
29
|
return _context.abrupt("return", path.resolve(distDirectory, "".concat(filepath.replace(new RegExp(CONFIG_FILE_EXTENSIONS.join('|')), ''), ".js")));
|
|
32
|
-
|
|
33
30
|
case 1:
|
|
34
31
|
case "end":
|
|
35
32
|
return _context.stop();
|
|
@@ -37,26 +34,21 @@ export var buildServerConfig = /*#__PURE__*/function () {
|
|
|
37
34
|
}
|
|
38
35
|
}, _callee);
|
|
39
36
|
}));
|
|
40
|
-
|
|
41
37
|
return function getOutputFile(_x2) {
|
|
42
38
|
return _ref3.apply(this, arguments);
|
|
43
39
|
};
|
|
44
40
|
}();
|
|
45
|
-
|
|
46
41
|
if (!configFilePath) {
|
|
47
42
|
_context2.next = 14;
|
|
48
43
|
break;
|
|
49
44
|
}
|
|
50
|
-
|
|
51
45
|
configHelperFilePath = path.normalize(path.join(distDirectory, './config-helper.js'));
|
|
52
46
|
helperCode = "\n export const defineConfig = (config) => config;\n ";
|
|
53
47
|
_context2.next = 10;
|
|
54
48
|
return fs.ensureDir(distDirectory);
|
|
55
|
-
|
|
56
49
|
case 10:
|
|
57
50
|
_context2.next = 12;
|
|
58
51
|
return fs.writeFile(configHelperFilePath, helperCode);
|
|
59
|
-
|
|
60
52
|
case 12:
|
|
61
53
|
_context2.next = 14;
|
|
62
54
|
return bundle(configFilePath, _objectSpread(_objectSpread({}, options), {}, {
|
|
@@ -74,7 +66,6 @@ export var buildServerConfig = /*#__PURE__*/function () {
|
|
|
74
66
|
}
|
|
75
67
|
}]
|
|
76
68
|
}));
|
|
77
|
-
|
|
78
69
|
case 14:
|
|
79
70
|
case "end":
|
|
80
71
|
return _context2.stop();
|
|
@@ -82,38 +73,33 @@ export var buildServerConfig = /*#__PURE__*/function () {
|
|
|
82
73
|
}
|
|
83
74
|
}, _callee2);
|
|
84
75
|
}));
|
|
85
|
-
|
|
86
76
|
return function buildServerConfig(_x) {
|
|
87
77
|
return _ref2.apply(this, arguments);
|
|
88
78
|
};
|
|
89
79
|
}();
|
|
80
|
+
|
|
90
81
|
/**
|
|
91
82
|
*
|
|
92
83
|
* 处理循环引用的 replacer
|
|
93
84
|
*/
|
|
94
|
-
|
|
95
85
|
export var safeReplacer = function safeReplacer() {
|
|
96
86
|
var cache = [];
|
|
97
87
|
var keyCache = [];
|
|
98
88
|
return function (key, value) {
|
|
99
89
|
if (_typeof(value) === 'object' && value !== null) {
|
|
100
90
|
var index = cache.indexOf(value);
|
|
101
|
-
|
|
102
91
|
if (index !== -1) {
|
|
103
92
|
return "[Circular ".concat(keyCache[index], "]");
|
|
104
93
|
}
|
|
105
|
-
|
|
106
94
|
cache.push(value);
|
|
107
95
|
keyCache.push(key || 'root');
|
|
108
96
|
}
|
|
109
|
-
|
|
110
97
|
return value;
|
|
111
98
|
};
|
|
112
99
|
};
|
|
113
100
|
export var emitResolvedConfig = /*#__PURE__*/function () {
|
|
114
101
|
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(appDirectory, resolvedConfig) {
|
|
115
102
|
var _resolvedConfig$outpu;
|
|
116
|
-
|
|
117
103
|
var outputPath;
|
|
118
104
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
119
105
|
while (1) {
|
|
@@ -125,7 +111,6 @@ export var emitResolvedConfig = /*#__PURE__*/function () {
|
|
|
125
111
|
spaces: 2,
|
|
126
112
|
replacer: safeReplacer()
|
|
127
113
|
});
|
|
128
|
-
|
|
129
114
|
case 3:
|
|
130
115
|
case "end":
|
|
131
116
|
return _context3.stop();
|
|
@@ -133,7 +118,6 @@ export var emitResolvedConfig = /*#__PURE__*/function () {
|
|
|
133
118
|
}
|
|
134
119
|
}, _callee3);
|
|
135
120
|
}));
|
|
136
|
-
|
|
137
121
|
return function emitResolvedConfig(_x3, _x4) {
|
|
138
122
|
return _ref4.apply(this, arguments);
|
|
139
123
|
};
|
|
@@ -16,13 +16,10 @@ export var closeServer = /*#__PURE__*/function () {
|
|
|
16
16
|
_context.next = 4;
|
|
17
17
|
break;
|
|
18
18
|
}
|
|
19
|
-
|
|
20
19
|
_context.next = 3;
|
|
21
20
|
return server.close();
|
|
22
|
-
|
|
23
21
|
case 3:
|
|
24
22
|
server = null;
|
|
25
|
-
|
|
26
23
|
case 4:
|
|
27
24
|
case "end":
|
|
28
25
|
return _context.stop();
|
|
@@ -30,7 +27,6 @@ export var closeServer = /*#__PURE__*/function () {
|
|
|
30
27
|
}
|
|
31
28
|
}, _callee);
|
|
32
29
|
}));
|
|
33
|
-
|
|
34
30
|
return function closeServer() {
|
|
35
31
|
return _ref.apply(this, arguments);
|
|
36
32
|
};
|
|
@@ -46,19 +42,15 @@ export var createServer = /*#__PURE__*/function () {
|
|
|
46
42
|
_context2.next = 3;
|
|
47
43
|
break;
|
|
48
44
|
}
|
|
49
|
-
|
|
50
45
|
_context2.next = 3;
|
|
51
46
|
return server.close();
|
|
52
|
-
|
|
53
47
|
case 3:
|
|
54
48
|
server = new Server(options);
|
|
55
49
|
_context2.next = 6;
|
|
56
50
|
return server.init();
|
|
57
|
-
|
|
58
51
|
case 6:
|
|
59
52
|
app = _context2.sent;
|
|
60
53
|
return _context2.abrupt("return", app);
|
|
61
|
-
|
|
62
54
|
case 8:
|
|
63
55
|
case "end":
|
|
64
56
|
return _context2.stop();
|
|
@@ -66,14 +58,12 @@ export var createServer = /*#__PURE__*/function () {
|
|
|
66
58
|
}
|
|
67
59
|
}, _callee2);
|
|
68
60
|
}));
|
|
69
|
-
|
|
70
61
|
return function createServer(_x) {
|
|
71
62
|
return _ref2.apply(this, arguments);
|
|
72
63
|
};
|
|
73
64
|
}();
|
|
74
65
|
export var injectDataLoaderPlugin = function injectDataLoaderPlugin(internalPlugins) {
|
|
75
66
|
var DataLoaderPlugin = require.resolve('@modern-js/plugin-data-loader/server');
|
|
76
|
-
|
|
77
67
|
return _objectSpread(_objectSpread({}, internalPlugins), {}, {
|
|
78
68
|
'@modern-js/plugin-data-loader': {
|
|
79
69
|
path: DataLoaderPlugin,
|
|
@@ -4,7 +4,6 @@ import { inquirer } from '@modern-js/utils';
|
|
|
4
4
|
export var getSpecifiedEntries = /*#__PURE__*/function () {
|
|
5
5
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(entry, entrypoints) {
|
|
6
6
|
var entryNames, _yield$inquirer$promp, selected;
|
|
7
|
-
|
|
8
7
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
9
8
|
while (1) {
|
|
10
9
|
switch (_context.prev = _context.next) {
|
|
@@ -12,20 +11,16 @@ export var getSpecifiedEntries = /*#__PURE__*/function () {
|
|
|
12
11
|
entryNames = entrypoints.map(function (e) {
|
|
13
12
|
return e.entryName;
|
|
14
13
|
});
|
|
15
|
-
|
|
16
14
|
if (entry) {
|
|
17
15
|
_context.next = 3;
|
|
18
16
|
break;
|
|
19
17
|
}
|
|
20
|
-
|
|
21
18
|
return _context.abrupt("return", entryNames);
|
|
22
|
-
|
|
23
19
|
case 3:
|
|
24
20
|
if (!(typeof entry === 'boolean')) {
|
|
25
21
|
_context.next = 9;
|
|
26
22
|
break;
|
|
27
23
|
}
|
|
28
|
-
|
|
29
24
|
_context.next = 6;
|
|
30
25
|
return inquirer.prompt([{
|
|
31
26
|
type: 'checkbox',
|
|
@@ -36,16 +31,13 @@ export var getSpecifiedEntries = /*#__PURE__*/function () {
|
|
|
36
31
|
if (answer.length < 1) {
|
|
37
32
|
return 'You must choose at least one topping.';
|
|
38
33
|
}
|
|
39
|
-
|
|
40
34
|
return true;
|
|
41
35
|
}
|
|
42
36
|
}]);
|
|
43
|
-
|
|
44
37
|
case 6:
|
|
45
38
|
_yield$inquirer$promp = _context.sent;
|
|
46
39
|
selected = _yield$inquirer$promp.selected;
|
|
47
40
|
return _context.abrupt("return", selected);
|
|
48
|
-
|
|
49
41
|
case 9:
|
|
50
42
|
entry.forEach(function (name) {
|
|
51
43
|
if (!entryNames.includes(name)) {
|
|
@@ -53,7 +45,6 @@ export var getSpecifiedEntries = /*#__PURE__*/function () {
|
|
|
53
45
|
}
|
|
54
46
|
});
|
|
55
47
|
return _context.abrupt("return", entry);
|
|
56
|
-
|
|
57
48
|
case 11:
|
|
58
49
|
case "end":
|
|
59
50
|
return _context.stop();
|
|
@@ -61,7 +52,6 @@ export var getSpecifiedEntries = /*#__PURE__*/function () {
|
|
|
61
52
|
}
|
|
62
53
|
}, _callee);
|
|
63
54
|
}));
|
|
64
|
-
|
|
65
55
|
return function getSpecifiedEntries(_x, _x2) {
|
|
66
56
|
return _ref.apply(this, arguments);
|
|
67
57
|
};
|
|
@@ -4,23 +4,19 @@ import { prettyInstructions, logger } from '@modern-js/utils';
|
|
|
4
4
|
export var printInstructions = /*#__PURE__*/function () {
|
|
5
5
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(hookRunners, appContext, config) {
|
|
6
6
|
var message, _yield$hookRunners$be, instructions;
|
|
7
|
-
|
|
8
7
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
9
8
|
while (1) {
|
|
10
9
|
switch (_context.prev = _context.next) {
|
|
11
10
|
case 0:
|
|
12
11
|
message = prettyInstructions(appContext, config); // call beforePrintInstructions hook.
|
|
13
|
-
|
|
14
12
|
_context.next = 3;
|
|
15
13
|
return hookRunners.beforePrintInstructions({
|
|
16
14
|
instructions: message
|
|
17
15
|
});
|
|
18
|
-
|
|
19
16
|
case 3:
|
|
20
17
|
_yield$hookRunners$be = _context.sent;
|
|
21
18
|
instructions = _yield$hookRunners$be.instructions;
|
|
22
19
|
logger.info(instructions);
|
|
23
|
-
|
|
24
20
|
case 6:
|
|
25
21
|
case "end":
|
|
26
22
|
return _context.stop();
|
|
@@ -28,7 +24,6 @@ export var printInstructions = /*#__PURE__*/function () {
|
|
|
28
24
|
}
|
|
29
25
|
}, _callee);
|
|
30
26
|
}));
|
|
31
|
-
|
|
32
27
|
return function printInstructions(_x, _x2, _x3) {
|
|
33
28
|
return _ref.apply(this, arguments);
|
|
34
29
|
};
|
|
@@ -2,7 +2,6 @@ import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
|
2
2
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import { fs, ROUTE_SPEC_FILE } from '@modern-js/utils';
|
|
5
|
-
|
|
6
5
|
var generateRoutes = /*#__PURE__*/function () {
|
|
7
6
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(appContext) {
|
|
8
7
|
var serverRoutes, distDirectory, output;
|
|
@@ -16,7 +15,6 @@ var generateRoutes = /*#__PURE__*/function () {
|
|
|
16
15
|
}, null, 2);
|
|
17
16
|
_context.next = 4;
|
|
18
17
|
return fs.outputFile(path.join(distDirectory, ROUTE_SPEC_FILE), output);
|
|
19
|
-
|
|
20
18
|
case 4:
|
|
21
19
|
case "end":
|
|
22
20
|
return _context.stop();
|
|
@@ -24,10 +22,8 @@ var generateRoutes = /*#__PURE__*/function () {
|
|
|
24
22
|
}
|
|
25
23
|
}, _callee);
|
|
26
24
|
}));
|
|
27
|
-
|
|
28
25
|
return function generateRoutes(_x) {
|
|
29
26
|
return _ref.apply(this, arguments);
|
|
30
27
|
};
|
|
31
28
|
}();
|
|
32
|
-
|
|
33
29
|
export { generateRoutes };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { CliPlugin, RuntimePlugin, ImportStatement } from '@modern-js/core';
|
|
2
2
|
import type { RouteLegacy, Entrypoint, ServerRoute, HtmlPartials, NestedRoute, PageRoute } from '@modern-js/types';
|
|
3
|
+
import type { AppHooks } from '../hooks';
|
|
3
4
|
export declare const modifyEntryImports: import("@modern-js/plugin").AsyncWaterfall<{
|
|
4
5
|
imports: ImportStatement[];
|
|
5
6
|
entrypoint: Entrypoint;
|
|
@@ -37,7 +38,5 @@ export declare const beforeGenerateRoutes: import("@modern-js/plugin").AsyncWate
|
|
|
37
38
|
code: string;
|
|
38
39
|
}>;
|
|
39
40
|
export declare const addDefineTypes: import("@modern-js/plugin").AsyncWaterfall<void>;
|
|
40
|
-
|
|
41
|
-
declare const _default: () => CliPlugin;
|
|
42
|
-
|
|
41
|
+
declare const _default: () => CliPlugin<AppHooks>;
|
|
43
42
|
export default _default;
|
|
@@ -38,9 +38,11 @@ export declare const routesForServer: ({
|
|
|
38
38
|
export declare const fileSystemRoutes: ({
|
|
39
39
|
routes,
|
|
40
40
|
ssrMode,
|
|
41
|
-
nestedRoutesEntry
|
|
41
|
+
nestedRoutesEntry,
|
|
42
|
+
entryName
|
|
42
43
|
}: {
|
|
43
44
|
routes: RouteLegacy[] | (NestedRoute | PageRoute)[];
|
|
44
45
|
ssrMode: 'string' | 'stream' | false;
|
|
45
46
|
nestedRoutesEntry?: string | undefined;
|
|
47
|
+
entryName: string;
|
|
46
48
|
}) => string;
|
|
@@ -9,6 +9,5 @@ export declare type PluginCompatModernOptions = FnParameter<Partial<Pick<Builder
|
|
|
9
9
|
/**
|
|
10
10
|
* Provides default configuration consistent with `@modern-js/webpack`
|
|
11
11
|
*/
|
|
12
|
-
|
|
13
12
|
export declare const PluginCompatModern: (appContext: IAppContext, modernConfig: NormalizedConfig, options?: PluginCompatModernOptions) => BuilderPlugin<BuilderPluginAPI>;
|
|
14
13
|
export {};
|
|
@@ -7,13 +7,9 @@ export declare type BuilderOptions = {
|
|
|
7
7
|
appContext: IAppContext;
|
|
8
8
|
compatPluginConfig?: PluginCompatModernOptions;
|
|
9
9
|
};
|
|
10
|
-
|
|
11
|
-
declare const _default: ({
|
|
12
|
-
target,
|
|
10
|
+
export declare function createBuilderForEdenX({
|
|
13
11
|
normalizedConfig,
|
|
14
12
|
appContext,
|
|
15
13
|
compatPluginConfig
|
|
16
|
-
}: BuilderOptions)
|
|
17
|
-
|
|
18
|
-
export default _default;
|
|
14
|
+
}: BuilderOptions): Promise<BuilderInstance>;
|
|
19
15
|
export declare function createBuilderOptions(target: BuilderTarget | BuilderTarget[], appContext: IAppContext): CreateBuilderOptions;
|
|
@@ -1,6 +1,3 @@
|
|
|
1
1
|
import type { PluginAPI } from '@modern-js/core';
|
|
2
2
|
import type { InspectOptions } from '../utils/types';
|
|
3
|
-
export declare const inspect: (api: PluginAPI, options: InspectOptions) => Promise<
|
|
4
|
-
builderConfig: string;
|
|
5
|
-
bundlerConfigs: string[];
|
|
6
|
-
}>;
|
|
3
|
+
export declare const inspect: (api: PluginAPI, options: InspectOptions) => Promise<any>;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -17,6 +17,5 @@ export declare const buildServerConfig: ({
|
|
|
17
17
|
*
|
|
18
18
|
* 处理循环引用的 replacer
|
|
19
19
|
*/
|
|
20
|
-
|
|
21
20
|
export declare const safeReplacer: () => (key: string, value: unknown) => unknown;
|
|
22
21
|
export declare const emitResolvedConfig: (appDirectory: string, resolvedConfig: NormalizedConfig) => Promise<void>;
|