@modern-js/app-tools 1.21.3 → 2.0.0-beta.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.
- package/CHANGELOG.md +138 -16
- package/dist/js/modern/analyze/constants.js +1 -0
- package/dist/js/modern/analyze/generateCode.js +118 -16
- package/dist/js/modern/analyze/getBundleEntry.js +3 -2
- package/dist/js/modern/analyze/getClientRoutes/getRoutes.js +198 -0
- package/dist/js/modern/analyze/{getClientRoutes.js → getClientRoutes/getRoutesLegacy.js} +8 -28
- package/dist/js/modern/analyze/getClientRoutes/index.js +2 -0
- package/dist/js/modern/analyze/getClientRoutes/utils.js +21 -0
- package/dist/js/modern/analyze/getFileSystemEntry.js +31 -12
- package/dist/js/modern/analyze/index.js +2 -1
- package/dist/js/modern/analyze/nestedRoutes.js +127 -0
- package/dist/js/modern/analyze/templates.js +164 -10
- package/dist/js/modern/analyze/utils.js +2 -1
- package/dist/js/modern/builder/builderPlugins/compatModern.js +226 -0
- package/dist/js/modern/builder/createHtmlConfig.js +58 -0
- package/dist/js/modern/builder/createOutputConfig.js +67 -0
- package/dist/js/modern/builder/createSourceConfig.js +85 -0
- package/dist/js/modern/builder/createToolsConfig.js +94 -0
- package/dist/js/modern/builder/index.js +106 -0
- package/dist/js/modern/builder/share.js +48 -0
- package/dist/js/modern/builder/webpackPlugins/htmlAsyncChunkPlugin.js +37 -0
- package/dist/js/modern/builder/webpackPlugins/htmlBottomTemplate.js +44 -0
- package/dist/js/modern/commands/build.js +41 -95
- package/dist/js/modern/commands/dev.js +15 -19
- package/dist/js/modern/commands/inspect.js +17 -58
- package/dist/js/modern/commands/start.js +2 -1
- package/dist/js/modern/index.js +14 -4
- package/dist/js/modern/locale/en.js +0 -1
- package/dist/js/modern/locale/zh.js +0 -1
- package/dist/js/modern/utils/commands.js +5 -0
- package/dist/js/modern/utils/createCompiler.js +37 -40
- package/dist/js/modern/utils/createServer.js +16 -0
- package/dist/js/modern/utils/printInstructions.js +1 -1
- package/dist/js/node/analyze/constants.js +3 -1
- package/dist/js/node/analyze/generateCode.js +121 -14
- package/dist/js/node/analyze/getBundleEntry.js +3 -2
- package/dist/js/node/analyze/getClientRoutes/getRoutes.js +221 -0
- package/dist/js/node/analyze/{getClientRoutes.js → getClientRoutes/getRoutesLegacy.js} +16 -35
- package/dist/js/node/analyze/getClientRoutes/index.js +21 -0
- package/dist/js/node/analyze/getClientRoutes/utils.js +42 -0
- package/dist/js/node/analyze/getFileSystemEntry.js +30 -11
- package/dist/js/node/analyze/index.js +2 -1
- package/dist/js/node/analyze/nestedRoutes.js +144 -0
- package/dist/js/node/analyze/templates.js +167 -10
- package/dist/js/node/analyze/utils.js +6 -2
- package/dist/js/node/builder/builderPlugins/compatModern.js +245 -0
- package/dist/js/node/builder/createHtmlConfig.js +76 -0
- package/dist/js/node/builder/createOutputConfig.js +75 -0
- package/dist/js/node/builder/createSourceConfig.js +99 -0
- package/dist/js/node/builder/createToolsConfig.js +103 -0
- package/dist/js/node/builder/index.js +129 -0
- package/dist/js/node/builder/share.js +63 -0
- package/dist/js/node/builder/webpackPlugins/htmlAsyncChunkPlugin.js +46 -0
- package/dist/js/node/builder/webpackPlugins/htmlBottomTemplate.js +53 -0
- package/dist/js/node/commands/build.js +44 -98
- package/dist/js/node/commands/dev.js +13 -23
- package/dist/js/node/commands/inspect.js +18 -74
- package/dist/js/node/commands/start.js +3 -1
- package/dist/js/node/index.js +19 -2
- package/dist/js/node/locale/en.js +0 -1
- package/dist/js/node/locale/zh.js +0 -1
- package/dist/js/node/utils/commands.js +14 -0
- package/dist/js/node/utils/createCompiler.js +43 -49
- package/dist/js/node/utils/createServer.js +21 -2
- package/dist/js/node/utils/printInstructions.js +1 -1
- package/dist/js/treeshaking/analyze/constants.js +16 -0
- package/dist/js/treeshaking/analyze/generateCode.js +412 -0
- package/dist/js/treeshaking/analyze/getBundleEntry.js +77 -0
- package/dist/js/treeshaking/analyze/getClientRoutes/getRoutes.js +210 -0
- package/dist/js/treeshaking/analyze/getClientRoutes/getRoutesLegacy.js +211 -0
- package/dist/js/treeshaking/analyze/getClientRoutes/index.js +2 -0
- package/dist/js/treeshaking/analyze/getClientRoutes/utils.js +27 -0
- package/dist/js/treeshaking/analyze/getFileSystemEntry.js +109 -0
- package/dist/js/treeshaking/analyze/getHtmlTemplate.js +153 -0
- package/dist/js/treeshaking/analyze/getServerRoutes.js +170 -0
- package/dist/js/treeshaking/analyze/index.js +214 -0
- package/dist/js/treeshaking/analyze/isDefaultExportFunction.js +32 -0
- package/dist/js/treeshaking/analyze/makeLegalIdentifier.js +18 -0
- package/dist/js/treeshaking/analyze/nestedRoutes.js +207 -0
- package/dist/js/treeshaking/analyze/templates.js +189 -0
- package/dist/js/treeshaking/analyze/utils.js +95 -0
- package/dist/js/treeshaking/builder/builderPlugins/compatModern.js +231 -0
- package/dist/js/treeshaking/builder/createHtmlConfig.js +59 -0
- package/dist/js/treeshaking/builder/createOutputConfig.js +67 -0
- package/dist/js/treeshaking/builder/createSourceConfig.js +100 -0
- package/dist/js/treeshaking/builder/createToolsConfig.js +90 -0
- package/dist/js/treeshaking/builder/index.js +172 -0
- package/dist/js/treeshaking/builder/share.js +50 -0
- package/dist/js/treeshaking/builder/webpackPlugins/htmlAsyncChunkPlugin.js +58 -0
- package/dist/js/treeshaking/builder/webpackPlugins/htmlBottomTemplate.js +53 -0
- package/dist/js/treeshaking/commands/build.js +168 -0
- package/dist/js/treeshaking/commands/deploy.js +29 -0
- package/dist/js/treeshaking/commands/dev.js +146 -0
- package/dist/js/treeshaking/commands/index.js +3 -0
- package/dist/js/treeshaking/commands/inspect.js +52 -0
- package/dist/js/treeshaking/commands/start.js +78 -0
- package/dist/js/treeshaking/exports/server.js +1 -0
- package/dist/js/treeshaking/hooks.js +21 -0
- package/dist/js/treeshaking/index.js +304 -0
- package/dist/js/treeshaking/locale/en.js +34 -0
- package/dist/js/treeshaking/locale/index.js +9 -0
- package/dist/js/treeshaking/locale/zh.js +34 -0
- package/dist/js/treeshaking/utils/commands.js +5 -0
- package/dist/js/treeshaking/utils/config.js +140 -0
- package/dist/js/treeshaking/utils/createCompiler.js +117 -0
- package/dist/js/treeshaking/utils/createServer.js +83 -0
- package/dist/js/treeshaking/utils/getSpecifiedEntries.js +68 -0
- package/dist/js/treeshaking/utils/language.js +5 -0
- package/dist/js/treeshaking/utils/printInstructions.js +35 -0
- package/dist/js/treeshaking/utils/routes.js +33 -0
- package/dist/js/treeshaking/utils/types.js +0 -0
- package/dist/types/analyze/constants.d.ts +1 -0
- package/dist/types/analyze/generateCode.d.ts +1 -1
- package/dist/types/analyze/{getClientRoutes.d.ts → getClientRoutes/getRoutes.d.ts} +2 -7
- package/dist/types/analyze/getClientRoutes/getRoutesLegacy.d.ts +15 -0
- package/dist/types/analyze/getClientRoutes/index.d.ts +2 -0
- package/dist/types/analyze/getClientRoutes/utils.d.ts +5 -0
- package/dist/types/analyze/index.d.ts +2 -2
- package/dist/types/analyze/nestedRoutes.d.ts +5 -0
- package/dist/types/analyze/templates.d.ts +17 -3
- package/dist/types/analyze/utils.d.ts +2 -1
- package/dist/types/builder/builderPlugins/compatModern.d.ts +14 -0
- package/dist/types/builder/createHtmlConfig.d.ts +6 -0
- package/dist/types/builder/createOutputConfig.d.ts +3 -0
- package/dist/types/builder/createSourceConfig.d.ts +5 -0
- package/dist/types/builder/createToolsConfig.d.ts +13 -0
- package/dist/types/builder/index.d.ts +19 -0
- package/dist/types/builder/share.d.ts +26 -0
- package/dist/types/builder/webpackPlugins/htmlAsyncChunkPlugin.d.ts +8 -0
- package/dist/types/builder/webpackPlugins/htmlBottomTemplate.d.ts +10 -0
- package/dist/types/commands/build.d.ts +2 -1
- package/dist/types/commands/deploy.d.ts +2 -1
- package/dist/types/commands/dev.d.ts +2 -1
- package/dist/types/commands/inspect.d.ts +5 -6
- package/dist/types/commands/start.d.ts +2 -1
- package/dist/types/hooks.d.ts +15 -10
- package/dist/types/index.d.ts +4 -2
- package/dist/types/locale/en.d.ts +0 -1
- package/dist/types/locale/index.d.ts +0 -2
- package/dist/types/locale/zh.d.ts +0 -1
- package/dist/types/utils/commands.d.ts +1 -0
- package/dist/types/utils/createCompiler.d.ts +9 -10
- package/dist/types/utils/createServer.d.ts +8 -1
- package/dist/types/utils/printInstructions.d.ts +3 -2
- package/dist/types/utils/types.d.ts +2 -3
- package/package.json +25 -43
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
3
|
+
import { chalk, logger } from '@modern-js/utils';
|
|
4
|
+
import createBuilder from "../builder";
|
|
5
|
+
import { printInstructions } from "./printInstructions";
|
|
6
|
+
export var createDevCompiler = /*#__PURE__*/function () {
|
|
7
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(_ref) {
|
|
8
|
+
var api, target, normalizedConfig, appContext, hookRunners, builder;
|
|
9
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
10
|
+
while (1) {
|
|
11
|
+
switch (_context4.prev = _context4.next) {
|
|
12
|
+
case 0:
|
|
13
|
+
api = _ref.api, target = _ref.target, normalizedConfig = _ref.normalizedConfig, appContext = _ref.appContext;
|
|
14
|
+
_context4.prev = 1;
|
|
15
|
+
hookRunners = api.useHookRunners();
|
|
16
|
+
_context4.next = 5;
|
|
17
|
+
return createBuilder({
|
|
18
|
+
target: target,
|
|
19
|
+
normalizedConfig: normalizedConfig,
|
|
20
|
+
appContext: appContext,
|
|
21
|
+
compatPluginConfig: {
|
|
22
|
+
onDevCompileDone: function onDevCompileDone(_ref3) {
|
|
23
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
24
|
+
var isFirstCompile;
|
|
25
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
26
|
+
while (1) {
|
|
27
|
+
switch (_context.prev = _context.next) {
|
|
28
|
+
case 0:
|
|
29
|
+
isFirstCompile = _ref3.isFirstCompile;
|
|
30
|
+
|
|
31
|
+
if (process.stdout.isTTY || isFirstCompile) {
|
|
32
|
+
hookRunners.afterDev();
|
|
33
|
+
|
|
34
|
+
if (isFirstCompile) {
|
|
35
|
+
printInstructions(hookRunners, appContext, normalizedConfig);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
case 2:
|
|
40
|
+
case "end":
|
|
41
|
+
return _context.stop();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}, _callee);
|
|
45
|
+
}))();
|
|
46
|
+
},
|
|
47
|
+
onBeforeCreateCompiler: function onBeforeCreateCompiler(_ref4) {
|
|
48
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
49
|
+
var bundlerConfigs;
|
|
50
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
51
|
+
while (1) {
|
|
52
|
+
switch (_context2.prev = _context2.next) {
|
|
53
|
+
case 0:
|
|
54
|
+
bundlerConfigs = _ref4.bundlerConfigs;
|
|
55
|
+
_context2.next = 3;
|
|
56
|
+
return hookRunners.beforeCreateCompiler({
|
|
57
|
+
bundlerConfigs: bundlerConfigs
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
case 3:
|
|
61
|
+
case "end":
|
|
62
|
+
return _context2.stop();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}, _callee2);
|
|
66
|
+
}))();
|
|
67
|
+
},
|
|
68
|
+
onAfterCreateCompiler: function onAfterCreateCompiler(_ref5) {
|
|
69
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
70
|
+
var compiler;
|
|
71
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
72
|
+
while (1) {
|
|
73
|
+
switch (_context3.prev = _context3.next) {
|
|
74
|
+
case 0:
|
|
75
|
+
compiler = _ref5.compiler;
|
|
76
|
+
_context3.next = 3;
|
|
77
|
+
return hookRunners.afterCreateCompiler({
|
|
78
|
+
compiler: compiler
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
case 3:
|
|
82
|
+
case "end":
|
|
83
|
+
return _context3.stop();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}, _callee3);
|
|
87
|
+
}))();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
case 5:
|
|
93
|
+
builder = _context4.sent;
|
|
94
|
+
return _context4.abrupt("return", builder.createCompiler());
|
|
95
|
+
|
|
96
|
+
case 9:
|
|
97
|
+
_context4.prev = 9;
|
|
98
|
+
_context4.t0 = _context4["catch"](1);
|
|
99
|
+
logger.log(chalk.red("Failed to compile."));
|
|
100
|
+
logger.log();
|
|
101
|
+
logger.log(_context4.t0); // FIXME: 这里最好抛出异常,执行 process.exit 的地方尽可能少或者控制在几个统一的地方比较合适
|
|
102
|
+
// eslint-disable-next-line no-process-exit
|
|
103
|
+
|
|
104
|
+
process.exit(1);
|
|
105
|
+
|
|
106
|
+
case 15:
|
|
107
|
+
case "end":
|
|
108
|
+
return _context4.stop();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}, _callee4, null, [[1, 9]]);
|
|
112
|
+
}));
|
|
113
|
+
|
|
114
|
+
return function createDevCompiler(_x) {
|
|
115
|
+
return _ref2.apply(this, arguments);
|
|
116
|
+
};
|
|
117
|
+
}();
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
3
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
4
|
+
import { Server } from '@modern-js/server';
|
|
5
|
+
var server = null;
|
|
6
|
+
export var getServer = function getServer() {
|
|
7
|
+
return server;
|
|
8
|
+
};
|
|
9
|
+
export var closeServer = /*#__PURE__*/function () {
|
|
10
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
11
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
12
|
+
while (1) {
|
|
13
|
+
switch (_context.prev = _context.next) {
|
|
14
|
+
case 0:
|
|
15
|
+
if (!server) {
|
|
16
|
+
_context.next = 4;
|
|
17
|
+
break;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
_context.next = 3;
|
|
21
|
+
return server.close();
|
|
22
|
+
|
|
23
|
+
case 3:
|
|
24
|
+
server = null;
|
|
25
|
+
|
|
26
|
+
case 4:
|
|
27
|
+
case "end":
|
|
28
|
+
return _context.stop();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}, _callee);
|
|
32
|
+
}));
|
|
33
|
+
|
|
34
|
+
return function closeServer() {
|
|
35
|
+
return _ref.apply(this, arguments);
|
|
36
|
+
};
|
|
37
|
+
}();
|
|
38
|
+
export var createServer = /*#__PURE__*/function () {
|
|
39
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options) {
|
|
40
|
+
var app;
|
|
41
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
42
|
+
while (1) {
|
|
43
|
+
switch (_context2.prev = _context2.next) {
|
|
44
|
+
case 0:
|
|
45
|
+
if (!server) {
|
|
46
|
+
_context2.next = 3;
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
_context2.next = 3;
|
|
51
|
+
return server.close();
|
|
52
|
+
|
|
53
|
+
case 3:
|
|
54
|
+
server = new Server(options);
|
|
55
|
+
_context2.next = 6;
|
|
56
|
+
return server.init();
|
|
57
|
+
|
|
58
|
+
case 6:
|
|
59
|
+
app = _context2.sent;
|
|
60
|
+
return _context2.abrupt("return", app);
|
|
61
|
+
|
|
62
|
+
case 8:
|
|
63
|
+
case "end":
|
|
64
|
+
return _context2.stop();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}, _callee2);
|
|
68
|
+
}));
|
|
69
|
+
|
|
70
|
+
return function createServer(_x) {
|
|
71
|
+
return _ref2.apply(this, arguments);
|
|
72
|
+
};
|
|
73
|
+
}();
|
|
74
|
+
export var injectDataLoaderPlugin = function injectDataLoaderPlugin(internalPlugins) {
|
|
75
|
+
var DataLoaderPlugin = require.resolve('@modern-js/plugin-data-loader/server');
|
|
76
|
+
|
|
77
|
+
return _objectSpread(_objectSpread({}, internalPlugins), {}, {
|
|
78
|
+
'@modern-js/plugin-data-loader': {
|
|
79
|
+
path: DataLoaderPlugin,
|
|
80
|
+
forced: true
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
3
|
+
import { inquirer } from '@modern-js/utils';
|
|
4
|
+
export var getSpecifiedEntries = /*#__PURE__*/function () {
|
|
5
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(entry, entrypoints) {
|
|
6
|
+
var entryNames, _yield$inquirer$promp, selected;
|
|
7
|
+
|
|
8
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
9
|
+
while (1) {
|
|
10
|
+
switch (_context.prev = _context.next) {
|
|
11
|
+
case 0:
|
|
12
|
+
entryNames = entrypoints.map(function (e) {
|
|
13
|
+
return e.entryName;
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
if (entry) {
|
|
17
|
+
_context.next = 3;
|
|
18
|
+
break;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return _context.abrupt("return", entryNames);
|
|
22
|
+
|
|
23
|
+
case 3:
|
|
24
|
+
if (!(typeof entry === 'boolean')) {
|
|
25
|
+
_context.next = 9;
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
_context.next = 6;
|
|
30
|
+
return inquirer.prompt([{
|
|
31
|
+
type: 'checkbox',
|
|
32
|
+
name: 'selected',
|
|
33
|
+
choices: entryNames,
|
|
34
|
+
message: '请选择需要构建的入口',
|
|
35
|
+
validate: function validate(answer) {
|
|
36
|
+
if (answer.length < 1) {
|
|
37
|
+
return 'You must choose at least one topping.';
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
}]);
|
|
43
|
+
|
|
44
|
+
case 6:
|
|
45
|
+
_yield$inquirer$promp = _context.sent;
|
|
46
|
+
selected = _yield$inquirer$promp.selected;
|
|
47
|
+
return _context.abrupt("return", selected);
|
|
48
|
+
|
|
49
|
+
case 9:
|
|
50
|
+
entry.forEach(function (name) {
|
|
51
|
+
if (!entryNames.includes(name)) {
|
|
52
|
+
throw new Error("can not found entry ".concat(name, ", compiler entry should in ").concat(entryNames.join(', ')));
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
return _context.abrupt("return", entry);
|
|
56
|
+
|
|
57
|
+
case 11:
|
|
58
|
+
case "end":
|
|
59
|
+
return _context.stop();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}, _callee);
|
|
63
|
+
}));
|
|
64
|
+
|
|
65
|
+
return function getSpecifiedEntries(_x, _x2) {
|
|
66
|
+
return _ref.apply(this, arguments);
|
|
67
|
+
};
|
|
68
|
+
}();
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
3
|
+
import { prettyInstructions, logger } from '@modern-js/utils';
|
|
4
|
+
export var printInstructions = /*#__PURE__*/function () {
|
|
5
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(hookRunners, appContext, config) {
|
|
6
|
+
var message, _yield$hookRunners$be, instructions;
|
|
7
|
+
|
|
8
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
9
|
+
while (1) {
|
|
10
|
+
switch (_context.prev = _context.next) {
|
|
11
|
+
case 0:
|
|
12
|
+
message = prettyInstructions(appContext, config); // call beforePrintInstructions hook.
|
|
13
|
+
|
|
14
|
+
_context.next = 3;
|
|
15
|
+
return hookRunners.beforePrintInstructions({
|
|
16
|
+
instructions: message
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
case 3:
|
|
20
|
+
_yield$hookRunners$be = _context.sent;
|
|
21
|
+
instructions = _yield$hookRunners$be.instructions;
|
|
22
|
+
logger.info(instructions);
|
|
23
|
+
|
|
24
|
+
case 6:
|
|
25
|
+
case "end":
|
|
26
|
+
return _context.stop();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}, _callee);
|
|
30
|
+
}));
|
|
31
|
+
|
|
32
|
+
return function printInstructions(_x, _x2, _x3) {
|
|
33
|
+
return _ref.apply(this, arguments);
|
|
34
|
+
};
|
|
35
|
+
}();
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { fs, ROUTE_SPEC_FILE } from '@modern-js/utils';
|
|
5
|
+
|
|
6
|
+
var generateRoutes = /*#__PURE__*/function () {
|
|
7
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(appContext) {
|
|
8
|
+
var serverRoutes, distDirectory, output;
|
|
9
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
10
|
+
while (1) {
|
|
11
|
+
switch (_context.prev = _context.next) {
|
|
12
|
+
case 0:
|
|
13
|
+
serverRoutes = appContext.serverRoutes, distDirectory = appContext.distDirectory;
|
|
14
|
+
output = JSON.stringify({
|
|
15
|
+
routes: serverRoutes
|
|
16
|
+
}, null, 2);
|
|
17
|
+
_context.next = 4;
|
|
18
|
+
return fs.outputFile(path.join(distDirectory, ROUTE_SPEC_FILE), output);
|
|
19
|
+
|
|
20
|
+
case 4:
|
|
21
|
+
case "end":
|
|
22
|
+
return _context.stop();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}, _callee);
|
|
26
|
+
}));
|
|
27
|
+
|
|
28
|
+
return function generateRoutes(_x) {
|
|
29
|
+
return _ref.apply(this, arguments);
|
|
30
|
+
};
|
|
31
|
+
}();
|
|
32
|
+
|
|
33
|
+
export { generateRoutes };
|
|
File without changes
|
|
@@ -2,6 +2,7 @@ export declare const JS_EXTENSIONS: string[];
|
|
|
2
2
|
export declare const INDEX_FILE_NAME = "index";
|
|
3
3
|
export declare const APP_FILE_NAME = "App";
|
|
4
4
|
export declare const PAGES_DIR_NAME = "pages";
|
|
5
|
+
export declare const NESTED_ROUTES_DIR = "routes";
|
|
5
6
|
export declare const FILE_SYSTEM_ROUTES_FILE_NAME = "routes.js";
|
|
6
7
|
export declare const ENTRY_POINT_FILE_NAME = "index.js";
|
|
7
8
|
export declare const ENTRY_BOOTSTRAP_FILE_NAME = "bootstrap.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { IAppContext, NormalizedConfig, PluginAPI, ImportStatement } from '@modern-js/core';
|
|
2
2
|
import type { Entrypoint } from '@modern-js/types';
|
|
3
3
|
export declare const createImportStatements: (statements: ImportStatement[]) => string;
|
|
4
4
|
export declare const generateCode: (appContext: IAppContext, config: NormalizedConfig, entrypoints: Entrypoint[], api: PluginAPI) => Promise<void>;
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import type { Entrypoint,
|
|
2
|
-
export type { Route };
|
|
3
|
-
export interface Identifier {
|
|
4
|
-
name: string;
|
|
5
|
-
path: string;
|
|
6
|
-
}
|
|
1
|
+
import type { Entrypoint, NestedRoute, PageRoute } from '@modern-js/types';
|
|
7
2
|
export declare const getClientRoutes: ({
|
|
8
3
|
entrypoint,
|
|
9
4
|
srcDirectory,
|
|
@@ -16,4 +11,4 @@ export declare const getClientRoutes: ({
|
|
|
16
11
|
srcAlias: string;
|
|
17
12
|
internalDirectory: string;
|
|
18
13
|
internalDirAlias: string;
|
|
19
|
-
}) =>
|
|
14
|
+
}) => (NestedRoute | PageRoute)[];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Entrypoint, RouteLegacy } from '@modern-js/types';
|
|
2
|
+
export type { RouteLegacy as Route };
|
|
3
|
+
export declare const getClientRoutes: ({
|
|
4
|
+
entrypoint,
|
|
5
|
+
srcDirectory,
|
|
6
|
+
srcAlias,
|
|
7
|
+
internalDirectory,
|
|
8
|
+
internalDirAlias
|
|
9
|
+
}: {
|
|
10
|
+
entrypoint: Entrypoint;
|
|
11
|
+
srcDirectory: string;
|
|
12
|
+
srcAlias: string;
|
|
13
|
+
internalDirectory: string;
|
|
14
|
+
internalDirAlias: string;
|
|
15
|
+
}) => RouteLegacy[];
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
declare const debug: import("@modern-js/utils/compiled/debug").Debugger;
|
|
2
|
+
export { debug };
|
|
3
|
+
export declare const findLayout: (dir: string) => string | false;
|
|
4
|
+
export declare const getRouteWeight: (route: string) => number;
|
|
5
|
+
export declare const shouldSkip: (file: string) => boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CliPlugin, RuntimePlugin, ImportStatement } from '@modern-js/core';
|
|
2
|
-
import type {
|
|
2
|
+
import type { RouteLegacy, Entrypoint, ServerRoute, HtmlPartials, NestedRoute, PageRoute } from '@modern-js/types';
|
|
3
3
|
export declare const modifyEntryImports: import("@modern-js/plugin").AsyncWaterfall<{
|
|
4
4
|
imports: ImportStatement[];
|
|
5
5
|
entrypoint: Entrypoint;
|
|
@@ -23,7 +23,7 @@ export declare const modifyAsyncEntry: import("@modern-js/plugin").AsyncWaterfal
|
|
|
23
23
|
}>;
|
|
24
24
|
export declare const modifyFileSystemRoutes: import("@modern-js/plugin").AsyncWaterfall<{
|
|
25
25
|
entrypoint: Entrypoint;
|
|
26
|
-
routes:
|
|
26
|
+
routes: RouteLegacy[] | (NestedRoute | PageRoute)[];
|
|
27
27
|
}>;
|
|
28
28
|
export declare const modifyServerRoutes: import("@modern-js/plugin").AsyncWaterfall<{
|
|
29
29
|
routes: ServerRoute[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { RuntimePlugin } from '@modern-js/core';
|
|
2
|
-
import type { Entrypoint,
|
|
2
|
+
import type { Entrypoint, NestedRoute, PageRoute, RouteLegacy } from '@modern-js/types';
|
|
3
3
|
export declare const index: ({
|
|
4
4
|
mountId,
|
|
5
5
|
imports,
|
|
@@ -25,8 +25,22 @@ export declare const html: (partials: {
|
|
|
25
25
|
head: string[];
|
|
26
26
|
body: string[];
|
|
27
27
|
}) => string;
|
|
28
|
+
export declare const routesForServer: ({
|
|
29
|
+
routes,
|
|
30
|
+
alias
|
|
31
|
+
}: {
|
|
32
|
+
routes: (NestedRoute | PageRoute)[];
|
|
33
|
+
alias: {
|
|
34
|
+
name: string;
|
|
35
|
+
basename: string;
|
|
36
|
+
};
|
|
37
|
+
}) => string;
|
|
28
38
|
export declare const fileSystemRoutes: ({
|
|
29
|
-
routes
|
|
39
|
+
routes,
|
|
40
|
+
ssrMode,
|
|
41
|
+
nestedRoutesEntry
|
|
30
42
|
}: {
|
|
31
|
-
routes:
|
|
43
|
+
routes: RouteLegacy[] | (NestedRoute | PageRoute)[];
|
|
44
|
+
ssrMode: 'string' | 'stream' | false;
|
|
45
|
+
nestedRoutesEntry?: string | undefined;
|
|
32
46
|
}) => string;
|
|
@@ -14,4 +14,5 @@ export declare const getDefaultImports: ({
|
|
|
14
14
|
internalDirAlias: string;
|
|
15
15
|
internalDirectory: string;
|
|
16
16
|
}) => ImportStatement[];
|
|
17
|
-
export declare const isRouteComponentFile: (filePath: string) => boolean;
|
|
17
|
+
export declare const isRouteComponentFile: (filePath: string) => boolean;
|
|
18
|
+
export declare const replaceWithAlias: (base: string, filePath: string, alias: string) => string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { BuilderPlugin } from '@modern-js/builder-shared';
|
|
2
|
+
import type { BuilderPluginAPI } from '@modern-js/builder-webpack-provider';
|
|
3
|
+
import type { IAppContext, NormalizedConfig } from '@modern-js/core';
|
|
4
|
+
declare type Parameter<T extends (arg: any) => void> = Parameters<T>[0];
|
|
5
|
+
declare type FnParameter<T extends {
|
|
6
|
+
[p: string]: (arg: any) => void;
|
|
7
|
+
}> = { [P in keyof T]: Parameter<T[P]> };
|
|
8
|
+
export declare type PluginCompatModernOptions = FnParameter<Partial<Pick<BuilderPluginAPI, 'onAfterBuild' | 'onAfterCreateCompiler' | 'onAfterStartDevServer' | 'onBeforeBuild' | 'onBeforeCreateCompiler' | 'onBeforeStartDevServer' | 'onDevCompileDone' | 'onExit'>>>;
|
|
9
|
+
/**
|
|
10
|
+
* Provides default configuration consistent with `@modern-js/webpack`
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export declare const PluginCompatModern: (appContext: IAppContext, modernConfig: NormalizedConfig, options?: PluginCompatModernOptions) => BuilderPlugin<BuilderPluginAPI>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { BuilderConfig } from '@modern-js/builder-webpack-provider';
|
|
2
|
+
import type { IAppContext, NormalizedConfig } from '@modern-js/core';
|
|
3
|
+
export declare function createHtmlConfig(normalizedConfig: NormalizedConfig, appContext: IAppContext): BuilderConfig['html'];
|
|
4
|
+
export declare function createBuilderAppIcon(configDir: NormalizedConfig['source']['configDir'], appContext: IAppContext): string | undefined;
|
|
5
|
+
export declare function createBuilderCrossorigin(scriptExt: NormalizedConfig['output']['scriptExt']): "anonymous" | "use-credentials" | undefined;
|
|
6
|
+
export declare function createBuilderFavicon(favicon: NormalizedConfig['output']['favicon'], configDir: NormalizedConfig['source']['configDir'], appContext: IAppContext): string | undefined;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { BuilderConfig } from '@modern-js/builder-webpack-provider';
|
|
2
|
+
import type { IAppContext, NormalizedConfig } from '@modern-js/core';
|
|
3
|
+
export declare function createOutputConfig(normalizedConfig: NormalizedConfig, appContext: IAppContext): BuilderConfig['output'];
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { BuilderConfig } from '@modern-js/builder-webpack-provider';
|
|
2
|
+
import { IAppContext, NormalizedConfig } from '@modern-js/core';
|
|
3
|
+
export declare function createSourceConfig(normalizedConfig: NormalizedConfig, appContext: IAppContext): BuilderConfig['source'];
|
|
4
|
+
export declare function createBuilderInclude(include: NormalizedConfig['source']['include'], appContext: IAppContext): (string | RegExp)[];
|
|
5
|
+
export declare function createBuilderModuleScope(moduleScopes: NormalizedConfig['source']['moduleScopes']): any[] | undefined;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { BuilderConfig } from '@modern-js/builder-webpack-provider';
|
|
2
|
+
import type { NormalizedConfig } from '@modern-js/core';
|
|
3
|
+
export declare function createToolsConfig(normalizedConfig: NormalizedConfig): BuilderConfig['tools'];
|
|
4
|
+
export declare function createBuilderTsChecker(output: NormalizedConfig['output']): false | {
|
|
5
|
+
issue: {
|
|
6
|
+
include: {
|
|
7
|
+
file: string;
|
|
8
|
+
}[];
|
|
9
|
+
exclude: {
|
|
10
|
+
file: string;
|
|
11
|
+
}[];
|
|
12
|
+
};
|
|
13
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { BuilderInstance, BuilderTarget, CreateBuilderOptions } from '@modern-js/builder';
|
|
2
|
+
import type { IAppContext, NormalizedConfig } from '@modern-js/core';
|
|
3
|
+
import { PluginCompatModernOptions } from './builderPlugins/compatModern';
|
|
4
|
+
export declare type BuilderOptions = {
|
|
5
|
+
target?: BuilderTarget | BuilderTarget[];
|
|
6
|
+
normalizedConfig: NormalizedConfig;
|
|
7
|
+
appContext: IAppContext;
|
|
8
|
+
compatPluginConfig?: PluginCompatModernOptions;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
declare const _default: ({
|
|
12
|
+
target,
|
|
13
|
+
normalizedConfig,
|
|
14
|
+
appContext,
|
|
15
|
+
compatPluginConfig
|
|
16
|
+
}: BuilderOptions) => Promise<BuilderInstance>;
|
|
17
|
+
|
|
18
|
+
export default _default;
|
|
19
|
+
export declare function createBuilderOptions(target: BuilderTarget | BuilderTarget[], appContext: IAppContext): CreateBuilderOptions;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { WebpackChain } from '@modern-js/builder-webpack-provider';
|
|
3
|
+
import { IAppContext, NormalizedConfig } from '@modern-js/core';
|
|
4
|
+
export declare function createCopyPattern(appContext: IAppContext, config: NormalizedConfig, patternsType: 'upload' | 'public', chain?: WebpackChain): {
|
|
5
|
+
info: (file: {
|
|
6
|
+
sourceFilename: string;
|
|
7
|
+
}) => {
|
|
8
|
+
minimized: boolean;
|
|
9
|
+
};
|
|
10
|
+
from: string;
|
|
11
|
+
to: string;
|
|
12
|
+
context: string;
|
|
13
|
+
noErrorOnMissing: boolean;
|
|
14
|
+
transform: (content: Buffer, absoluteFrom: string) => string | Buffer;
|
|
15
|
+
} | {
|
|
16
|
+
info: (file: {
|
|
17
|
+
sourceFilename: string;
|
|
18
|
+
}) => {
|
|
19
|
+
minimized: boolean;
|
|
20
|
+
};
|
|
21
|
+
from: string;
|
|
22
|
+
to: string;
|
|
23
|
+
context: string;
|
|
24
|
+
noErrorOnMissing: boolean;
|
|
25
|
+
transform?: undefined;
|
|
26
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { webpack } from '@modern-js/builder-webpack-provider';
|
|
2
|
+
import type HtmlWebpackPlugin from '@modern-js/builder-webpack-provider/html-webpack-plugin';
|
|
3
|
+
export declare class HtmlAsyncChunkPlugin {
|
|
4
|
+
name: string;
|
|
5
|
+
htmlWebpackPlugin: typeof HtmlWebpackPlugin;
|
|
6
|
+
constructor(htmlWebpackPlugin: typeof HtmlWebpackPlugin);
|
|
7
|
+
apply(compiler: webpack.Compiler): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { webpack } from '@modern-js/builder-webpack-provider';
|
|
2
|
+
import type HtmlWebpackPlugin from '@modern-js/builder-webpack-provider/html-webpack-plugin';
|
|
3
|
+
export declare class BottomTemplatePlugin {
|
|
4
|
+
htmlWebpackPlugin: typeof HtmlWebpackPlugin;
|
|
5
|
+
bottomTemplateReg: RegExp;
|
|
6
|
+
bodyRegExp: RegExp;
|
|
7
|
+
name: string;
|
|
8
|
+
constructor(htmlWebpackPlugin: typeof HtmlWebpackPlugin);
|
|
9
|
+
apply(compiler: webpack.Compiler): void;
|
|
10
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { PluginAPI } from '@modern-js/core';
|
|
2
2
|
import type { BuildOptions } from '../utils/types';
|
|
3
|
-
|
|
3
|
+
import type { AppHooks } from '../hooks';
|
|
4
|
+
export declare const build: (api: PluginAPI<AppHooks>, options?: BuildOptions) => Promise<void>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { PluginAPI } from '@modern-js/core';
|
|
2
2
|
import { DevOptions } from '../utils/types';
|
|
3
|
-
|
|
3
|
+
import type { AppHooks } from '../hooks';
|
|
4
|
+
export declare const dev: (api: PluginAPI<AppHooks>, options: DevOptions) => Promise<void>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { PluginAPI, NormalizedConfig, IAppContext } from '@modern-js/core';
|
|
1
|
+
import type { PluginAPI } from '@modern-js/core';
|
|
3
2
|
import type { InspectOptions } from '../utils/types';
|
|
4
|
-
export declare const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
export declare const inspect: (api: PluginAPI, options: InspectOptions) => Promise<{
|
|
4
|
+
builderConfig: string;
|
|
5
|
+
bundlerConfigs: string[];
|
|
6
|
+
}>;
|