@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,214 @@
|
|
|
1
|
+
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
4
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
5
|
+
import * as path from 'path';
|
|
6
|
+
import { createAsyncWaterfall } from '@modern-js/plugin';
|
|
7
|
+
import { createDebugger, fs, isApiOnly } from '@modern-js/utils';
|
|
8
|
+
import { cloneDeep } from '@modern-js/utils/lodash';
|
|
9
|
+
import { isRouteComponentFile } from "./utils";
|
|
10
|
+
var debug = createDebugger('plugin-analyze');
|
|
11
|
+
export var modifyEntryImports = createAsyncWaterfall();
|
|
12
|
+
export var modifyEntryExport = createAsyncWaterfall();
|
|
13
|
+
export var addRuntimeExports = createAsyncWaterfall();
|
|
14
|
+
export var modifyEntryRuntimePlugins = createAsyncWaterfall();
|
|
15
|
+
export var modifyEntryRenderFunction = createAsyncWaterfall();
|
|
16
|
+
export var modifyAsyncEntry = createAsyncWaterfall();
|
|
17
|
+
export var modifyFileSystemRoutes = createAsyncWaterfall();
|
|
18
|
+
export var modifyServerRoutes = createAsyncWaterfall();
|
|
19
|
+
export var htmlPartials = createAsyncWaterfall();
|
|
20
|
+
export var beforeGenerateRoutes = createAsyncWaterfall();
|
|
21
|
+
export var addDefineTypes = createAsyncWaterfall();
|
|
22
|
+
export default (function () {
|
|
23
|
+
return {
|
|
24
|
+
name: '@modern-js/plugin-analyze',
|
|
25
|
+
registerHook: {
|
|
26
|
+
modifyAsyncEntry: modifyAsyncEntry,
|
|
27
|
+
modifyEntryImports: modifyEntryImports,
|
|
28
|
+
modifyEntryExport: modifyEntryExport,
|
|
29
|
+
modifyEntryRuntimePlugins: modifyEntryRuntimePlugins,
|
|
30
|
+
modifyEntryRenderFunction: modifyEntryRenderFunction,
|
|
31
|
+
modifyFileSystemRoutes: modifyFileSystemRoutes,
|
|
32
|
+
modifyServerRoutes: modifyServerRoutes,
|
|
33
|
+
htmlPartials: htmlPartials,
|
|
34
|
+
addRuntimeExports: addRuntimeExports,
|
|
35
|
+
beforeGenerateRoutes: beforeGenerateRoutes,
|
|
36
|
+
addDefineTypes: addDefineTypes
|
|
37
|
+
},
|
|
38
|
+
setup: function setup(api) {
|
|
39
|
+
var pagesDir = [];
|
|
40
|
+
var originEntrypoints = [];
|
|
41
|
+
return {
|
|
42
|
+
prepare: function prepare() {
|
|
43
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
44
|
+
var _resolvedConfig$sourc;
|
|
45
|
+
|
|
46
|
+
var appContext, resolvedConfig, hookRunners, apiOnly, _yield$hookRunners$mo, _routes, _yield$Promise$all, _yield$Promise$all2, getBundleEntry, getServerRoutes, generateCode, getHtmlTemplate, entrypoints, defaultChecked, initialRoutes, _yield$hookRunners$mo2, routes, nestedRouteEntries, htmlTemplates;
|
|
47
|
+
|
|
48
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
49
|
+
while (1) {
|
|
50
|
+
switch (_context.prev = _context.next) {
|
|
51
|
+
case 0:
|
|
52
|
+
appContext = api.useAppContext();
|
|
53
|
+
resolvedConfig = api.useResolvedConfigContext();
|
|
54
|
+
hookRunners = api.useHookRunners();
|
|
55
|
+
|
|
56
|
+
try {
|
|
57
|
+
fs.emptydirSync(appContext.internalDirectory);
|
|
58
|
+
} catch (_unused) {// FIXME:
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
_context.next = 6;
|
|
62
|
+
return isApiOnly(appContext.appDirectory, resolvedConfig === null || resolvedConfig === void 0 ? void 0 : (_resolvedConfig$sourc = resolvedConfig.source) === null || _resolvedConfig$sourc === void 0 ? void 0 : _resolvedConfig$sourc.entriesDir);
|
|
63
|
+
|
|
64
|
+
case 6:
|
|
65
|
+
apiOnly = _context.sent;
|
|
66
|
+
_context.next = 9;
|
|
67
|
+
return hookRunners.addRuntimeExports();
|
|
68
|
+
|
|
69
|
+
case 9:
|
|
70
|
+
if (!apiOnly) {
|
|
71
|
+
_context.next = 17;
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
_context.next = 12;
|
|
76
|
+
return hookRunners.modifyServerRoutes({
|
|
77
|
+
routes: []
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
case 12:
|
|
81
|
+
_yield$hookRunners$mo = _context.sent;
|
|
82
|
+
_routes = _yield$hookRunners$mo.routes;
|
|
83
|
+
debug("server routes: %o", _routes);
|
|
84
|
+
api.setAppContext(_objectSpread(_objectSpread({}, appContext), {}, {
|
|
85
|
+
apiOnly: apiOnly,
|
|
86
|
+
serverRoutes: _routes
|
|
87
|
+
}));
|
|
88
|
+
return _context.abrupt("return");
|
|
89
|
+
|
|
90
|
+
case 17:
|
|
91
|
+
_context.next = 19;
|
|
92
|
+
return Promise.all([import("./getBundleEntry"), import("./getServerRoutes"), import("./generateCode"), import("./getHtmlTemplate")]);
|
|
93
|
+
|
|
94
|
+
case 19:
|
|
95
|
+
_yield$Promise$all = _context.sent;
|
|
96
|
+
_yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 4);
|
|
97
|
+
getBundleEntry = _yield$Promise$all2[0].getBundleEntry;
|
|
98
|
+
getServerRoutes = _yield$Promise$all2[1].getServerRoutes;
|
|
99
|
+
generateCode = _yield$Promise$all2[2].generateCode;
|
|
100
|
+
getHtmlTemplate = _yield$Promise$all2[3].getHtmlTemplate;
|
|
101
|
+
entrypoints = getBundleEntry(appContext, resolvedConfig);
|
|
102
|
+
defaultChecked = entrypoints.map(function (point) {
|
|
103
|
+
return point.entryName;
|
|
104
|
+
});
|
|
105
|
+
debug("entrypoints: %o", entrypoints);
|
|
106
|
+
initialRoutes = getServerRoutes(entrypoints, {
|
|
107
|
+
appContext: appContext,
|
|
108
|
+
config: resolvedConfig
|
|
109
|
+
});
|
|
110
|
+
_context.next = 31;
|
|
111
|
+
return hookRunners.modifyServerRoutes({
|
|
112
|
+
routes: initialRoutes
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
case 31:
|
|
116
|
+
_yield$hookRunners$mo2 = _context.sent;
|
|
117
|
+
routes = _yield$hookRunners$mo2.routes;
|
|
118
|
+
debug("server routes: %o", routes);
|
|
119
|
+
api.setAppContext(_objectSpread(_objectSpread({}, appContext), {}, {
|
|
120
|
+
entrypoints: entrypoints,
|
|
121
|
+
serverRoutes: routes
|
|
122
|
+
}));
|
|
123
|
+
nestedRouteEntries = entrypoints.map(function (point) {
|
|
124
|
+
return point.nestedRoutesEntry;
|
|
125
|
+
}).filter(Boolean);
|
|
126
|
+
pagesDir = entrypoints.map(function (point) {
|
|
127
|
+
return point.entry;
|
|
128
|
+
}).filter(Boolean).concat(nestedRouteEntries);
|
|
129
|
+
originEntrypoints = cloneDeep(entrypoints);
|
|
130
|
+
_context.next = 40;
|
|
131
|
+
return generateCode(appContext, resolvedConfig, entrypoints, api);
|
|
132
|
+
|
|
133
|
+
case 40:
|
|
134
|
+
_context.next = 42;
|
|
135
|
+
return getHtmlTemplate(entrypoints, api, {
|
|
136
|
+
appContext: appContext,
|
|
137
|
+
config: resolvedConfig
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
case 42:
|
|
141
|
+
htmlTemplates = _context.sent;
|
|
142
|
+
debug("html templates: %o", htmlTemplates);
|
|
143
|
+
_context.next = 46;
|
|
144
|
+
return hookRunners.addDefineTypes();
|
|
145
|
+
|
|
146
|
+
case 46:
|
|
147
|
+
debug("add Define Types");
|
|
148
|
+
api.setAppContext(_objectSpread(_objectSpread({}, appContext), {}, {
|
|
149
|
+
entrypoints: entrypoints,
|
|
150
|
+
checkedEntries: defaultChecked,
|
|
151
|
+
apiOnly: apiOnly,
|
|
152
|
+
serverRoutes: routes,
|
|
153
|
+
htmlTemplates: htmlTemplates
|
|
154
|
+
}));
|
|
155
|
+
|
|
156
|
+
case 48:
|
|
157
|
+
case "end":
|
|
158
|
+
return _context.stop();
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}, _callee);
|
|
162
|
+
}))();
|
|
163
|
+
},
|
|
164
|
+
watchFiles: function watchFiles() {
|
|
165
|
+
return pagesDir;
|
|
166
|
+
},
|
|
167
|
+
fileChange: function fileChange(e) {
|
|
168
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
169
|
+
var appContext, appDirectory, filename, eventType, isPageFile, absoluteFilePath, isRouteComponent, resolvedConfig, _yield$import, generateCode, entrypoints;
|
|
170
|
+
|
|
171
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
172
|
+
while (1) {
|
|
173
|
+
switch (_context2.prev = _context2.next) {
|
|
174
|
+
case 0:
|
|
175
|
+
appContext = api.useAppContext();
|
|
176
|
+
appDirectory = appContext.appDirectory;
|
|
177
|
+
filename = e.filename, eventType = e.eventType;
|
|
178
|
+
|
|
179
|
+
isPageFile = function isPageFile(name) {
|
|
180
|
+
return pagesDir.some(function (pageDir) {
|
|
181
|
+
return name.includes(pageDir);
|
|
182
|
+
});
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
absoluteFilePath = path.resolve(appDirectory, filename);
|
|
186
|
+
isRouteComponent = isPageFile(absoluteFilePath) && isRouteComponentFile(absoluteFilePath);
|
|
187
|
+
|
|
188
|
+
if (!(isRouteComponent && (eventType === 'add' || eventType === 'unlink'))) {
|
|
189
|
+
_context2.next = 14;
|
|
190
|
+
break;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
resolvedConfig = api.useResolvedConfigContext();
|
|
194
|
+
_context2.next = 10;
|
|
195
|
+
return import("./generateCode");
|
|
196
|
+
|
|
197
|
+
case 10:
|
|
198
|
+
_yield$import = _context2.sent;
|
|
199
|
+
generateCode = _yield$import.generateCode;
|
|
200
|
+
entrypoints = cloneDeep(originEntrypoints);
|
|
201
|
+
generateCode(appContext, resolvedConfig, entrypoints, api);
|
|
202
|
+
|
|
203
|
+
case 14:
|
|
204
|
+
case "end":
|
|
205
|
+
return _context2.stop();
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}, _callee2);
|
|
209
|
+
}))();
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import { parse } from '@babel/parser';
|
|
3
|
+
import traverse from '@babel/traverse';
|
|
4
|
+
import * as t from '@babel/types';
|
|
5
|
+
|
|
6
|
+
var isFunction = function isFunction(node) {
|
|
7
|
+
return t.isFunctionDeclaration(node) || t.isFunctionExpression(node) || t.isArrowFunctionExpression(node);
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export var isDefaultExportFunction = function isDefaultExportFunction(file) {
|
|
11
|
+
if (!file || !fs.existsSync(file)) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
var ast = parse(fs.readFileSync(file, 'utf8'), {
|
|
16
|
+
sourceType: 'unambiguous',
|
|
17
|
+
plugins: ['jsx', 'typescript', 'classProperties', 'dynamicImport', 'exportDefaultFrom', 'exportNamespaceFrom', 'decorators-legacy', 'functionBind', 'classPrivateMethods', ['pipelineOperator', {
|
|
18
|
+
proposal: 'minimal'
|
|
19
|
+
}], 'optionalChaining', 'optionalCatchBinding', 'objectRestSpread', 'numericSeparator']
|
|
20
|
+
});
|
|
21
|
+
var isExportFunction = false;
|
|
22
|
+
traverse(ast, {
|
|
23
|
+
ExportDefaultDeclaration: function ExportDefaultDeclaration(path) {
|
|
24
|
+
var declaration = path.node.declaration;
|
|
25
|
+
|
|
26
|
+
if (isFunction(declaration)) {
|
|
27
|
+
isExportFunction = true;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
return isExportFunction;
|
|
32
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* modified from https://github.com/rollup/plugins/blob/master/packages/pluginutils
|
|
3
|
+
* license at https://github.com/rollup/plugins/blob/master/LICENSE
|
|
4
|
+
*/
|
|
5
|
+
var reservedWords = 'break case class catch const continue debugger default delete do else export extends finally for function if import in instanceof let new return super switch this throw try typeof var void while with yield enum await implements package protected static interface private public';
|
|
6
|
+
var builtins = 'arguments Infinity NaN undefined null true false eval uneval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Symbol Error EvalError InternalError RangeError ReferenceError SyntaxError TypeError URIError Number Math Date String RegExp Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array Map Set WeakMap WeakSet SIMD ArrayBuffer DataView JSON Promise Generator GeneratorFunction Reflect Proxy Intl';
|
|
7
|
+
var forbidList = new Set("".concat(reservedWords, " ").concat(builtins).split(' '));
|
|
8
|
+
export function makeLegalIdentifier(str) {
|
|
9
|
+
var identifier = str.replace(/-(\w)/g, function (_, letter) {
|
|
10
|
+
return letter.toUpperCase();
|
|
11
|
+
}).replace(/[^$_a-zA-Z0-9]/g, '_');
|
|
12
|
+
|
|
13
|
+
if (/\d/.test(identifier[0]) || forbidList.has(identifier)) {
|
|
14
|
+
return "_".concat(identifier);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return identifier || '_';
|
|
18
|
+
}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
2
|
+
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
|
3
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
4
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
5
|
+
import * as path from 'path';
|
|
6
|
+
import { fs, getRouteId } from '@modern-js/utils';
|
|
7
|
+
import { JS_EXTENSIONS } from "./constants";
|
|
8
|
+
import { replaceWithAlias } from "./utils";
|
|
9
|
+
var LAYOUT_FILE = 'layout';
|
|
10
|
+
var PAGE_FILE = 'page';
|
|
11
|
+
var LOADING_FILE = 'loading';
|
|
12
|
+
var ERROR_FILE = 'error';
|
|
13
|
+
var LOADER_FILE = 'loader';
|
|
14
|
+
var conventionNames = [LAYOUT_FILE, PAGE_FILE, LOADING_FILE, ERROR_FILE, LOADER_FILE];
|
|
15
|
+
|
|
16
|
+
var replaceDynamicPath = function replaceDynamicPath(routePath) {
|
|
17
|
+
return routePath.replace(/\[(.*?)\]/g, ':$1');
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
var createIndexRoute = function createIndexRoute(routeInfo, rootDir, filename) {
|
|
21
|
+
return createRoute(_objectSpread(_objectSpread({}, routeInfo), {}, {
|
|
22
|
+
index: true,
|
|
23
|
+
children: undefined
|
|
24
|
+
}), rootDir, filename);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
var createRoute = function createRoute(routeInfo, rootDir, filename) {
|
|
28
|
+
var id = getRouteId(filename, rootDir);
|
|
29
|
+
return _objectSpread(_objectSpread({}, routeInfo), {}, {
|
|
30
|
+
id: id,
|
|
31
|
+
type: 'nested'
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export var walk = /*#__PURE__*/function () {
|
|
36
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(dirname, rootDir, alias) {
|
|
37
|
+
var isDirectory, relativeDir, pathSegments, lastSegment, isRoot, isPathlessLayout, isWithoutLayoutPath, routePath, route, items, _iterator, _step, item, itemPath, extname, itemWithoutExt, _isDirectory, childRoute, _route$children, _route$children2, _childRoute, finalRoute;
|
|
38
|
+
|
|
39
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
40
|
+
while (1) {
|
|
41
|
+
switch (_context.prev = _context.next) {
|
|
42
|
+
case 0:
|
|
43
|
+
_context.next = 2;
|
|
44
|
+
return fs.pathExists(dirname);
|
|
45
|
+
|
|
46
|
+
case 2:
|
|
47
|
+
if (_context.sent) {
|
|
48
|
+
_context.next = 4;
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return _context.abrupt("return", null);
|
|
53
|
+
|
|
54
|
+
case 4:
|
|
55
|
+
_context.next = 6;
|
|
56
|
+
return fs.stat(dirname);
|
|
57
|
+
|
|
58
|
+
case 6:
|
|
59
|
+
isDirectory = _context.sent.isDirectory();
|
|
60
|
+
|
|
61
|
+
if (isDirectory) {
|
|
62
|
+
_context.next = 9;
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return _context.abrupt("return", null);
|
|
67
|
+
|
|
68
|
+
case 9:
|
|
69
|
+
relativeDir = path.relative(rootDir, dirname);
|
|
70
|
+
pathSegments = relativeDir.split(path.sep);
|
|
71
|
+
lastSegment = pathSegments[pathSegments.length - 1];
|
|
72
|
+
isRoot = lastSegment === '';
|
|
73
|
+
isPathlessLayout = lastSegment.startsWith('__');
|
|
74
|
+
isWithoutLayoutPath = lastSegment.includes('.');
|
|
75
|
+
routePath = isRoot || isPathlessLayout ? '/' : "".concat(lastSegment);
|
|
76
|
+
|
|
77
|
+
if (isWithoutLayoutPath) {
|
|
78
|
+
routePath = lastSegment.split('.').join('/');
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
routePath = replaceDynamicPath(routePath);
|
|
82
|
+
route = {
|
|
83
|
+
path: routePath,
|
|
84
|
+
children: []
|
|
85
|
+
};
|
|
86
|
+
_context.next = 21;
|
|
87
|
+
return fs.readdir(dirname);
|
|
88
|
+
|
|
89
|
+
case 21:
|
|
90
|
+
items = _context.sent;
|
|
91
|
+
_iterator = _createForOfIteratorHelper(items);
|
|
92
|
+
_context.prev = 23;
|
|
93
|
+
|
|
94
|
+
_iterator.s();
|
|
95
|
+
|
|
96
|
+
case 25:
|
|
97
|
+
if ((_step = _iterator.n()).done) {
|
|
98
|
+
_context.next = 47;
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
item = _step.value;
|
|
103
|
+
itemPath = path.join(dirname, item);
|
|
104
|
+
extname = path.extname(item);
|
|
105
|
+
itemWithoutExt = item.slice(0, -extname.length);
|
|
106
|
+
_context.next = 32;
|
|
107
|
+
return fs.stat(itemPath);
|
|
108
|
+
|
|
109
|
+
case 32:
|
|
110
|
+
_isDirectory = _context.sent.isDirectory();
|
|
111
|
+
|
|
112
|
+
if (!_isDirectory) {
|
|
113
|
+
_context.next = 38;
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
_context.next = 36;
|
|
118
|
+
return walk(itemPath, rootDir, alias);
|
|
119
|
+
|
|
120
|
+
case 36:
|
|
121
|
+
childRoute = _context.sent;
|
|
122
|
+
|
|
123
|
+
if (childRoute) {
|
|
124
|
+
(_route$children = route.children) === null || _route$children === void 0 ? void 0 : _route$children.push(childRoute);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
case 38:
|
|
128
|
+
if (!(extname && (!JS_EXTENSIONS.includes(extname) || !conventionNames.includes(itemWithoutExt)))) {
|
|
129
|
+
_context.next = 40;
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return _context.abrupt("continue", 45);
|
|
134
|
+
|
|
135
|
+
case 40:
|
|
136
|
+
if (itemWithoutExt === LAYOUT_FILE) {
|
|
137
|
+
route._component = replaceWithAlias(alias.basename, itemPath, alias.name);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (itemWithoutExt === PAGE_FILE) {
|
|
141
|
+
_childRoute = createIndexRoute({
|
|
142
|
+
_component: replaceWithAlias(alias.basename, itemPath, alias.name)
|
|
143
|
+
}, rootDir, itemPath);
|
|
144
|
+
(_route$children2 = route.children) === null || _route$children2 === void 0 ? void 0 : _route$children2.push(_childRoute);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (itemWithoutExt === LOADER_FILE) {
|
|
148
|
+
route.loader = replaceWithAlias(alias.basename, itemPath, alias.name);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (itemWithoutExt === LOADING_FILE) {
|
|
152
|
+
route.loading = replaceWithAlias(alias.basename, itemPath, alias.name);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (itemWithoutExt === ERROR_FILE) {
|
|
156
|
+
route.error = replaceWithAlias(alias.basename, itemPath, alias.name);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
case 45:
|
|
160
|
+
_context.next = 25;
|
|
161
|
+
break;
|
|
162
|
+
|
|
163
|
+
case 47:
|
|
164
|
+
_context.next = 52;
|
|
165
|
+
break;
|
|
166
|
+
|
|
167
|
+
case 49:
|
|
168
|
+
_context.prev = 49;
|
|
169
|
+
_context.t0 = _context["catch"](23);
|
|
170
|
+
|
|
171
|
+
_iterator.e(_context.t0);
|
|
172
|
+
|
|
173
|
+
case 52:
|
|
174
|
+
_context.prev = 52;
|
|
175
|
+
|
|
176
|
+
_iterator.f();
|
|
177
|
+
|
|
178
|
+
return _context.finish(52);
|
|
179
|
+
|
|
180
|
+
case 55:
|
|
181
|
+
finalRoute = createRoute(route, rootDir, path.join(dirname, "".concat(LAYOUT_FILE, ".ts")));
|
|
182
|
+
/**
|
|
183
|
+
* when the url is /, the __auth/layout.tsx component should not be rendered
|
|
184
|
+
* - routes
|
|
185
|
+
* - __auth
|
|
186
|
+
* - layout.tsx
|
|
187
|
+
* - layout.tsx
|
|
188
|
+
*/
|
|
189
|
+
|
|
190
|
+
if (isPathlessLayout) {
|
|
191
|
+
delete finalRoute.path;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return _context.abrupt("return", finalRoute);
|
|
195
|
+
|
|
196
|
+
case 58:
|
|
197
|
+
case "end":
|
|
198
|
+
return _context.stop();
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}, _callee, null, [[23, 49, 52, 55]]);
|
|
202
|
+
}));
|
|
203
|
+
|
|
204
|
+
return function walk(_x, _x2, _x3) {
|
|
205
|
+
return _ref.apply(this, arguments);
|
|
206
|
+
};
|
|
207
|
+
}();
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
|
2
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
|
+
export var index = function index(_ref) {
|
|
4
|
+
var mountId = _ref.mountId,
|
|
5
|
+
imports = _ref.imports,
|
|
6
|
+
renderFunction = _ref.renderFunction,
|
|
7
|
+
exportStatement = _ref.exportStatement;
|
|
8
|
+
return "\nconst IS_BROWSER = typeof window !== 'undefined' && window.name !== 'nodejs';\nconst IS_REACT18 = process.env.IS_REACT18 === 'true';\nconst MOUNT_ID = '".concat(mountId, "';\n\n").concat(imports, "\n\nlet AppWrapper = null;\n\nlet root = null;\n\nfunction render() {\n ").concat(renderFunction, "\n}\n\nAppWrapper = render();\n\n").concat(exportStatement, ";\n");
|
|
9
|
+
};
|
|
10
|
+
export var renderFunction = function renderFunction(_ref2) {
|
|
11
|
+
var plugins = _ref2.plugins,
|
|
12
|
+
customBootstrap = _ref2.customBootstrap,
|
|
13
|
+
fileSystemRoutes = _ref2.fileSystemRoutes;
|
|
14
|
+
return "\n AppWrapper = createApp({\n plugins: [\n ".concat(plugins.map(function (_ref3) {
|
|
15
|
+
var name = _ref3.name,
|
|
16
|
+
options = _ref3.options,
|
|
17
|
+
args = _ref3.args;
|
|
18
|
+
return "".concat(name, "({...").concat(options, ", ...App?.config?.").concat(args || name, "}),");
|
|
19
|
+
}).join('\n'), "\n ]\n })(").concat(fileSystemRoutes ? '' : "App", ")\n\n if (IS_BROWSER) {\n ").concat(customBootstrap ? "customBootstrap(AppWrapper);" : "bootstrap(AppWrapper, MOUNT_ID, root, ReactDOM);", "\n }\n\n return AppWrapper\n");
|
|
20
|
+
};
|
|
21
|
+
export var html = function html(partials) {
|
|
22
|
+
return "\n<!DOCTYPE html>\n<html>\n<head>\n <%= meta %>\n <title><%= title %></title>\n\n ".concat(partials.top.join('\n'), "\n\n <script>\n window.__assetPrefix__ = '<%= assetPrefix %>';\n </script>\n ").concat(partials.head.join('\n'), "\n\n <!--<?- chunksMap.css ?>-->\n</head>\n\n<body>\n <noscript>\n We're sorry but react app doesn't work properly without JavaScript enabled. Please enable it to continue.\n </noscript>\n <div id=\"<%= mountId %>\"><!--<?- html ?>--></div>\n ").concat(partials.body.join('\n'), "\n <!--<?- chunksMap.js ?>-->\n <!--<?- SSRDataScript ?>-->\n <!--<?- bottomTemplate ?>-->\n</body>\n\n</html>\n");
|
|
23
|
+
};
|
|
24
|
+
export var routesForServer = function routesForServer(_ref4) {
|
|
25
|
+
var routes = _ref4.routes,
|
|
26
|
+
alias = _ref4.alias;
|
|
27
|
+
var name = alias.name,
|
|
28
|
+
basename = alias.basename;
|
|
29
|
+
var loaders = [];
|
|
30
|
+
|
|
31
|
+
var traverseRouteTree = function traverseRouteTree(route) {
|
|
32
|
+
var children;
|
|
33
|
+
|
|
34
|
+
if ('children' in route && route.children) {
|
|
35
|
+
var _route$children;
|
|
36
|
+
|
|
37
|
+
children = route === null || route === void 0 ? void 0 : (_route$children = route.children) === null || _route$children === void 0 ? void 0 : _route$children.map(traverseRouteTree);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
var loader;
|
|
41
|
+
|
|
42
|
+
if (route.type === 'nested') {
|
|
43
|
+
if (route.loader) {
|
|
44
|
+
loaders.push(route.loader);
|
|
45
|
+
loader = "loader_".concat(loaders.length - 1);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
var finalRoute = _objectSpread(_objectSpread({}, route), {}, {
|
|
50
|
+
loader: loader,
|
|
51
|
+
children: children
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
return finalRoute;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
var routesCode = "\n export const routes = [\n ";
|
|
58
|
+
|
|
59
|
+
var _iterator = _createForOfIteratorHelper(routes),
|
|
60
|
+
_step;
|
|
61
|
+
|
|
62
|
+
try {
|
|
63
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
64
|
+
var route = _step.value;
|
|
65
|
+
|
|
66
|
+
if ('type' in route) {
|
|
67
|
+
var newRoute = traverseRouteTree(route);
|
|
68
|
+
routesCode += "".concat(JSON.stringify(newRoute, null, 2).replace(/"(loader_[^"])"/g, '$1'), ",");
|
|
69
|
+
} else {
|
|
70
|
+
routesCode += "".concat(JSON.stringify(route, null, 2));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
} catch (err) {
|
|
74
|
+
_iterator.e(err);
|
|
75
|
+
} finally {
|
|
76
|
+
_iterator.f();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
routesCode += "\n];";
|
|
80
|
+
var importLoadersCode = loaders.map(function (loader, index) {
|
|
81
|
+
var realLoaderPath = loader.replace(name, basename);
|
|
82
|
+
return "import loader_".concat(index, " from '").concat(realLoaderPath, "';\n");
|
|
83
|
+
}).join('');
|
|
84
|
+
return "\n ".concat(importLoadersCode, "\n ").concat(routesCode, "\n ");
|
|
85
|
+
};
|
|
86
|
+
export var fileSystemRoutes = function fileSystemRoutes(_ref5) {
|
|
87
|
+
var routes = _ref5.routes,
|
|
88
|
+
ssrMode = _ref5.ssrMode,
|
|
89
|
+
nestedRoutesEntry = _ref5.nestedRoutesEntry;
|
|
90
|
+
var importLazyCode = ssrMode === 'stream' ? 'import { lazy } from "react";' : "import loadable from '@modern-js/runtime/loadable'";
|
|
91
|
+
var dataLoaderPath = '';
|
|
92
|
+
|
|
93
|
+
if (ssrMode) {
|
|
94
|
+
dataLoaderPath = require.resolve("@modern-js/plugin-data-loader/loader");
|
|
95
|
+
|
|
96
|
+
if (nestedRoutesEntry) {
|
|
97
|
+
dataLoaderPath = "".concat(dataLoaderPath, "?routesDir=").concat(nestedRoutesEntry, "!");
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
var loadings = [];
|
|
102
|
+
var errors = [];
|
|
103
|
+
var loaders = [];
|
|
104
|
+
|
|
105
|
+
var traverseRouteTree = function traverseRouteTree(route) {
|
|
106
|
+
var children;
|
|
107
|
+
|
|
108
|
+
if ('children' in route && route.children) {
|
|
109
|
+
var _route$children2;
|
|
110
|
+
|
|
111
|
+
children = route === null || route === void 0 ? void 0 : (_route$children2 = route.children) === null || _route$children2 === void 0 ? void 0 : _route$children2.map(traverseRouteTree);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
var loading;
|
|
115
|
+
var error;
|
|
116
|
+
var loader;
|
|
117
|
+
|
|
118
|
+
if (route.type === 'nested') {
|
|
119
|
+
if (route.loading) {
|
|
120
|
+
loadings.push(route.loading);
|
|
121
|
+
loading = "loading_".concat(loadings.length - 1);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (route.error) {
|
|
125
|
+
errors.push(route.error);
|
|
126
|
+
error = "error_".concat(errors.length - 1);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (route.loader) {
|
|
130
|
+
loaders.push(route.loader);
|
|
131
|
+
loader = "loader_".concat(loaders.length - 1);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
var finalRoute = _objectSpread(_objectSpread({}, route), {}, {
|
|
136
|
+
loading: loading,
|
|
137
|
+
loader: loader,
|
|
138
|
+
error: error,
|
|
139
|
+
children: children
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
if (route._component) {
|
|
143
|
+
var component = ssrMode === 'stream' ? "lazy(() => import('".concat(route._component, "'))") : "loadable(() => import('".concat(route._component, "'))");
|
|
144
|
+
finalRoute.component = component;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return finalRoute;
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
var routeComponentsCode = "\n export const routes = [\n ";
|
|
151
|
+
|
|
152
|
+
var _iterator2 = _createForOfIteratorHelper(routes),
|
|
153
|
+
_step2;
|
|
154
|
+
|
|
155
|
+
try {
|
|
156
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
157
|
+
var route = _step2.value;
|
|
158
|
+
|
|
159
|
+
if ('type' in route) {
|
|
160
|
+
var newRoute = traverseRouteTree(route);
|
|
161
|
+
routeComponentsCode += "".concat(JSON.stringify(newRoute, null, 2).replace(/"(loadable[^"]*)"/g, '$1').replace(/"(lazy[^"]*)"/g, '$1').replace(/"(loading_[^"])"/g, '$1').replace(/"(loader_[^"])"/g, '$1').replace(/"(error_[^"])"/g, '$1'), ",");
|
|
162
|
+
} else {
|
|
163
|
+
var component = ssrMode === 'stream' ? "lazy(() => import('".concat(route._component, "'))") : "loadable(() => import('".concat(route._component, "'))");
|
|
164
|
+
|
|
165
|
+
var finalRoute = _objectSpread(_objectSpread({}, route), {}, {
|
|
166
|
+
component: component
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
routeComponentsCode += "".concat(JSON.stringify(finalRoute, null, 2).replace(/"(loadable[^"]*)"/g, '$1').replace(/"(lazy[^"]*)"/g, '$1'), ",");
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
} catch (err) {
|
|
173
|
+
_iterator2.e(err);
|
|
174
|
+
} finally {
|
|
175
|
+
_iterator2.f();
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
routeComponentsCode += "\n];";
|
|
179
|
+
var importLoadingCode = loadings.map(function (loading, index) {
|
|
180
|
+
return "import loading_".concat(index, " from '").concat(loading, "';\n");
|
|
181
|
+
}).join('');
|
|
182
|
+
var importErrorComponentsCode = errors.map(function (error, index) {
|
|
183
|
+
return "import error_".concat(index, " from '").concat(error, "';\n");
|
|
184
|
+
}).join('');
|
|
185
|
+
var importLoaderComponentsCode = loaders.map(function (loader, index) {
|
|
186
|
+
return "import loader_".concat(index, " from '").concat(dataLoaderPath).concat(loader, "';\n");
|
|
187
|
+
}).join('');
|
|
188
|
+
return "\n ".concat(importLazyCode, "\n ").concat(importLoadingCode, "\n ").concat(importErrorComponentsCode, "\n ").concat(importLoaderComponentsCode, "\n ").concat(routeComponentsCode, "\n ");
|
|
189
|
+
};
|