@modern-js/app-tools 2.0.0-beta.0 → 2.0.0-beta.2
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 +375 -0
- package/dist/js/modern/analyze/generateCode.js +30 -38
- package/dist/js/modern/analyze/getBundleEntry.js +5 -13
- 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 +5 -18
- package/dist/js/modern/analyze/getHtmlTemplate.js +3 -10
- package/dist/js/modern/analyze/getServerRoutes.js +25 -38
- package/dist/js/modern/analyze/index.js +90 -48
- 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 +41 -58
- package/dist/js/modern/builder/index.js +56 -37
- package/dist/js/modern/builder/share.js +1 -5
- 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 +12 -46
- package/dist/js/modern/commands/dev.js +20 -23
- package/dist/js/modern/commands/inspect.js +4 -19
- package/dist/js/modern/commands/start.js +1 -2
- package/dist/js/modern/config/default.js +207 -0
- package/dist/js/modern/config/index.js +2 -0
- package/dist/js/modern/config/initial/createHtmlConfig.js +32 -0
- package/dist/js/modern/{builder → config/initial}/createOutputConfig.js +19 -18
- package/dist/js/modern/config/initial/createSourceConfig.js +32 -0
- package/dist/js/modern/config/initial/createToolsConfig.js +41 -0
- package/dist/js/modern/config/initial/index.js +11 -0
- package/dist/js/modern/config/initial/inits.js +117 -0
- package/dist/js/modern/config/initial/transformNormalizedConfig.js +40 -0
- package/dist/js/modern/defineConfig.js +12 -0
- package/dist/js/modern/hooks.js +23 -19
- package/dist/js/modern/index.js +12 -19
- package/dist/js/modern/initialize/index.js +72 -0
- package/dist/js/modern/schema/Schema.js +39 -0
- package/dist/js/modern/schema/index.js +139 -0
- package/dist/js/modern/schema/legacy.js +284 -0
- package/dist/js/modern/types/config/deploy.js +0 -0
- package/dist/js/modern/types/config/dev.js +0 -0
- package/dist/js/modern/types/config/experiments.js +0 -0
- package/dist/js/modern/types/config/html.js +0 -0
- package/dist/js/modern/types/config/index.js +2 -0
- package/dist/js/modern/types/config/output.js +0 -0
- package/dist/js/modern/types/config/performance.js +0 -0
- package/dist/js/modern/types/config/security.js +0 -0
- package/dist/js/modern/types/config/source.js +0 -0
- package/dist/js/modern/types/config/tools.js +0 -0
- package/dist/js/modern/types/hooks.js +0 -0
- package/dist/js/modern/types/index.js +4 -0
- package/dist/js/modern/types/legacyConfig/deploy.js +0 -0
- package/dist/js/modern/types/legacyConfig/dev.js +0 -0
- package/dist/js/modern/types/legacyConfig/index.js +0 -0
- package/dist/js/modern/types/legacyConfig/output.js +1 -0
- package/dist/js/modern/types/legacyConfig/source.js +0 -0
- package/dist/js/modern/types/legacyConfig/tools.js +0 -0
- package/dist/js/modern/utils/config.js +2 -13
- package/dist/js/modern/utils/createFileWatcher.js +82 -0
- 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/restart.js +17 -0
- package/dist/js/modern/utils/routes.js +0 -2
- package/dist/js/node/analyze/generateCode.js +30 -61
- package/dist/js/node/analyze/getBundleEntry.js +5 -19
- 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 +5 -26
- package/dist/js/node/analyze/getHtmlTemplate.js +3 -24
- package/dist/js/node/analyze/getServerRoutes.js +24 -46
- package/dist/js/node/analyze/index.js +91 -70
- 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 +41 -69
- package/dist/js/node/builder/index.js +57 -51
- package/dist/js/node/builder/share.js +1 -13
- 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 +10 -57
- package/dist/js/node/commands/deploy.js +0 -2
- package/dist/js/node/commands/dev.js +19 -34
- package/dist/js/node/commands/index.js +0 -6
- package/dist/js/node/commands/inspect.js +4 -26
- package/dist/js/node/commands/start.js +1 -11
- package/dist/js/node/config/default.js +214 -0
- package/dist/js/node/config/index.js +31 -0
- package/dist/js/node/config/initial/createHtmlConfig.js +38 -0
- package/dist/js/node/{builder → config/initial}/createOutputConfig.js +19 -20
- package/dist/js/node/config/initial/createSourceConfig.js +38 -0
- package/dist/js/node/config/initial/createToolsConfig.js +47 -0
- package/dist/js/node/config/initial/index.js +24 -0
- package/dist/js/node/config/initial/inits.js +127 -0
- package/dist/js/node/config/initial/transformNormalizedConfig.js +46 -0
- package/dist/js/node/defineConfig.js +20 -0
- package/dist/js/node/exports/server.js +0 -1
- package/dist/js/node/hooks.js +23 -30
- package/dist/js/node/index.js +35 -48
- package/dist/js/node/initialize/index.js +79 -0
- package/dist/js/node/locale/index.js +0 -4
- package/dist/js/node/schema/Schema.js +46 -0
- package/dist/js/node/schema/index.js +152 -0
- package/dist/js/node/schema/legacy.js +291 -0
- package/dist/js/node/types/config/deploy.js +0 -0
- package/dist/js/node/types/config/dev.js +0 -0
- package/dist/js/node/types/config/experiments.js +0 -0
- package/dist/js/node/types/config/html.js +0 -0
- package/dist/js/node/types/config/index.js +16 -0
- package/dist/js/node/types/config/output.js +0 -0
- package/dist/js/node/types/config/performance.js +0 -0
- package/dist/js/node/types/config/security.js +0 -0
- package/dist/js/node/types/config/source.js +0 -0
- package/dist/js/node/types/config/tools.js +0 -0
- package/dist/js/node/types/hooks.js +0 -0
- package/dist/js/node/types/index.js +38 -0
- package/dist/js/node/types/legacyConfig/deploy.js +0 -0
- package/dist/js/node/types/legacyConfig/dev.js +0 -0
- package/dist/js/node/types/legacyConfig/index.js +0 -0
- package/dist/js/node/types/legacyConfig/output.js +5 -0
- package/dist/js/node/types/legacyConfig/source.js +0 -0
- package/dist/js/node/types/legacyConfig/tools.js +0 -0
- package/dist/js/node/utils/commands.js +0 -2
- package/dist/js/node/utils/config.js +2 -26
- package/dist/js/node/utils/createFileWatcher.js +90 -0
- 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/restart.js +23 -0
- package/dist/js/node/utils/routes.js +0 -5
- package/dist/js/treeshaking/analyze/generateCode.js +58 -101
- package/dist/js/treeshaking/analyze/getBundleEntry.js +12 -20
- 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 +5 -18
- package/dist/js/treeshaking/analyze/getHtmlTemplate.js +3 -27
- package/dist/js/treeshaking/analyze/getServerRoutes.js +29 -41
- package/dist/js/treeshaking/analyze/index.js +195 -91
- 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 +50 -68
- package/dist/js/treeshaking/builder/index.js +69 -65
- package/dist/js/treeshaking/builder/share.js +1 -5
- 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 +41 -116
- package/dist/js/treeshaking/commands/deploy.js +0 -3
- package/dist/js/treeshaking/commands/dev.js +38 -46
- package/dist/js/treeshaking/commands/inspect.js +9 -27
- package/dist/js/treeshaking/commands/start.js +1 -9
- package/dist/js/treeshaking/config/default.js +200 -0
- package/dist/js/treeshaking/config/index.js +2 -0
- package/dist/js/treeshaking/config/initial/createHtmlConfig.js +31 -0
- package/dist/js/treeshaking/config/initial/createOutputConfig.js +67 -0
- package/dist/js/treeshaking/config/initial/createSourceConfig.js +41 -0
- package/dist/js/treeshaking/config/initial/createToolsConfig.js +38 -0
- package/dist/js/treeshaking/config/initial/index.js +11 -0
- package/dist/js/treeshaking/config/initial/inits.js +114 -0
- package/dist/js/treeshaking/config/initial/transformNormalizedConfig.js +38 -0
- package/dist/js/treeshaking/defineConfig.js +14 -0
- package/dist/js/treeshaking/hooks.js +23 -19
- package/dist/js/treeshaking/index.js +8 -43
- package/dist/js/treeshaking/initialize/index.js +121 -0
- package/dist/js/treeshaking/schema/Schema.js +75 -0
- package/dist/js/treeshaking/schema/index.js +138 -0
- package/dist/js/treeshaking/schema/legacy.js +273 -0
- package/dist/js/treeshaking/types/config/deploy.js +0 -0
- package/dist/js/treeshaking/types/config/dev.js +0 -0
- package/dist/js/treeshaking/types/config/experiments.js +0 -0
- package/dist/js/treeshaking/types/config/html.js +0 -0
- package/dist/js/treeshaking/types/config/index.js +2 -0
- package/dist/js/treeshaking/types/config/output.js +0 -0
- package/dist/js/treeshaking/types/config/performance.js +0 -0
- package/dist/js/treeshaking/types/config/security.js +0 -0
- package/dist/js/treeshaking/types/config/source.js +0 -0
- package/dist/js/treeshaking/types/config/tools.js +0 -0
- package/dist/js/treeshaking/types/hooks.js +0 -0
- package/dist/js/treeshaking/types/index.js +4 -0
- package/dist/js/treeshaking/types/legacyConfig/deploy.js +0 -0
- package/dist/js/treeshaking/types/legacyConfig/dev.js +0 -0
- package/dist/js/treeshaking/types/legacyConfig/index.js +0 -0
- package/dist/js/treeshaking/types/legacyConfig/output.js +1 -0
- package/dist/js/treeshaking/types/legacyConfig/source.js +0 -0
- package/dist/js/treeshaking/types/legacyConfig/tools.js +0 -0
- package/dist/js/treeshaking/utils/config.js +2 -18
- package/dist/js/treeshaking/utils/createFileWatcher.js +123 -0
- 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/restart.js +45 -0
- package/dist/js/treeshaking/utils/routes.js +0 -4
- package/dist/types/analyze/generateCode.d.ts +3 -2
- package/dist/types/analyze/getBundleEntry.d.ts +2 -2
- package/dist/types/analyze/getFileSystemEntry.d.ts +2 -2
- package/dist/types/analyze/getHtmlTemplate.d.ts +3 -3
- package/dist/types/analyze/getServerRoutes.d.ts +3 -2
- package/dist/types/analyze/index.d.ts +3 -42
- package/dist/types/analyze/nestedRoutes.d.ts +1 -1
- package/dist/types/analyze/templates.d.ts +4 -2
- package/dist/types/analyze/utils.d.ts +1 -1
- package/dist/types/builder/builderPlugins/compatModern.d.ts +2 -3
- package/dist/types/builder/index.d.ts +7 -8
- package/dist/types/builder/share.d.ts +2 -2
- package/dist/types/builder/webpackPlugins/routerPlugin.d.ts +10 -0
- package/dist/types/commands/build.d.ts +2 -2
- package/dist/types/commands/deploy.d.ts +2 -2
- package/dist/types/commands/dev.d.ts +2 -2
- package/dist/types/commands/inspect.d.ts +6 -1
- package/dist/types/commands/start.d.ts +2 -2
- package/dist/types/config/default.d.ts +3 -0
- package/dist/types/config/index.d.ts +2 -0
- package/dist/types/config/initial/createHtmlConfig.d.ts +2 -0
- package/dist/types/config/initial/createOutputConfig.d.ts +2 -0
- package/dist/types/config/initial/createSourceConfig.d.ts +2 -0
- package/dist/types/config/initial/createToolsConfig.d.ts +2 -0
- package/dist/types/config/initial/index.d.ts +4 -0
- package/dist/types/config/initial/inits.d.ts +4 -0
- package/dist/types/config/initial/transformNormalizedConfig.d.ts +2 -0
- package/dist/types/defineConfig.d.ts +7 -0
- package/dist/types/hooks.d.ts +2 -42
- package/dist/types/index.d.ts +5 -7
- package/dist/types/initialize/index.d.ts +3 -0
- package/dist/types/schema/Schema.d.ts +14 -0
- package/dist/types/schema/index.d.ts +4 -0
- package/dist/types/schema/legacy.d.ts +3 -0
- package/dist/types/types/config/deploy.d.ts +9 -0
- package/dist/types/types/config/dev.d.ts +13 -0
- package/dist/types/types/config/experiments.d.ts +4 -0
- package/dist/types/types/config/html.d.ts +4 -0
- package/dist/types/types/config/index.d.ts +62 -0
- package/dist/types/types/config/output.d.ts +23 -0
- package/dist/types/types/config/performance.d.ts +4 -0
- package/dist/types/types/config/security.d.ts +4 -0
- package/dist/types/types/config/source.d.ts +22 -0
- package/dist/types/types/config/tools.d.ts +15 -0
- package/dist/types/types/hooks.d.ts +80 -0
- package/dist/types/types/index.d.ts +23 -0
- package/dist/types/types/legacyConfig/deploy.d.ts +8 -0
- package/dist/types/types/legacyConfig/dev.d.ts +12 -0
- package/dist/types/types/legacyConfig/index.d.ts +33 -0
- package/dist/types/types/legacyConfig/output.d.ts +51 -0
- package/dist/types/types/legacyConfig/source.d.ts +25 -0
- package/dist/types/types/legacyConfig/tools.d.ts +16 -0
- package/dist/types/utils/config.d.ts +2 -3
- package/dist/types/utils/createFileWatcher.d.ts +3 -0
- package/dist/types/utils/printInstructions.d.ts +3 -3
- package/dist/types/utils/restart.d.ts +3 -0
- package/package.json +26 -25
- package/dist/js/modern/builder/createHtmlConfig.js +0 -58
- package/dist/js/modern/builder/createSourceConfig.js +0 -85
- package/dist/js/modern/builder/createToolsConfig.js +0 -94
- package/dist/js/modern/utils/createCompiler.js +0 -58
- package/dist/js/node/builder/createHtmlConfig.js +0 -76
- package/dist/js/node/builder/createSourceConfig.js +0 -99
- package/dist/js/node/builder/createToolsConfig.js +0 -103
- package/dist/js/node/utils/createCompiler.js +0 -75
- package/dist/js/treeshaking/builder/createHtmlConfig.js +0 -59
- package/dist/js/treeshaking/builder/createOutputConfig.js +0 -67
- package/dist/js/treeshaking/builder/createSourceConfig.js +0 -100
- package/dist/js/treeshaking/builder/createToolsConfig.js +0 -90
- package/dist/js/treeshaking/utils/createCompiler.js +0 -117
- package/dist/types/builder/createHtmlConfig.d.ts +0 -6
- package/dist/types/builder/createOutputConfig.d.ts +0 -3
- package/dist/types/builder/createSourceConfig.d.ts +0 -5
- package/dist/types/builder/createToolsConfig.d.ts +0 -13
- package/dist/types/utils/createCompiler.d.ts +0 -12
|
@@ -12,59 +12,47 @@ var LOADING_FILE = 'loading';
|
|
|
12
12
|
var ERROR_FILE = 'error';
|
|
13
13
|
var LOADER_FILE = 'loader';
|
|
14
14
|
var conventionNames = [LAYOUT_FILE, PAGE_FILE, LOADING_FILE, ERROR_FILE, LOADER_FILE];
|
|
15
|
-
|
|
16
15
|
var replaceDynamicPath = function replaceDynamicPath(routePath) {
|
|
17
16
|
return routePath.replace(/\[(.*?)\]/g, ':$1');
|
|
18
17
|
};
|
|
19
|
-
|
|
20
|
-
var createIndexRoute = function createIndexRoute(routeInfo, rootDir, filename) {
|
|
18
|
+
var createIndexRoute = function createIndexRoute(routeInfo, rootDir, filename, entryName) {
|
|
21
19
|
return createRoute(_objectSpread(_objectSpread({}, routeInfo), {}, {
|
|
22
20
|
index: true,
|
|
23
21
|
children: undefined
|
|
24
|
-
}), rootDir, filename);
|
|
22
|
+
}), rootDir, filename, entryName);
|
|
25
23
|
};
|
|
26
|
-
|
|
27
|
-
var
|
|
28
|
-
var id = getRouteId(filename, rootDir);
|
|
24
|
+
var createRoute = function createRoute(routeInfo, rootDir, filename, entryName) {
|
|
25
|
+
var id = getRouteId(filename, rootDir, entryName);
|
|
29
26
|
return _objectSpread(_objectSpread({}, routeInfo), {}, {
|
|
30
27
|
id: id,
|
|
31
28
|
type: 'nested'
|
|
32
29
|
});
|
|
33
30
|
};
|
|
34
|
-
|
|
35
31
|
export var walk = /*#__PURE__*/function () {
|
|
36
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(dirname, rootDir, alias) {
|
|
32
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(dirname, rootDir, alias, entryName) {
|
|
37
33
|
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
34
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
40
35
|
while (1) {
|
|
41
36
|
switch (_context.prev = _context.next) {
|
|
42
37
|
case 0:
|
|
43
38
|
_context.next = 2;
|
|
44
39
|
return fs.pathExists(dirname);
|
|
45
|
-
|
|
46
40
|
case 2:
|
|
47
41
|
if (_context.sent) {
|
|
48
42
|
_context.next = 4;
|
|
49
43
|
break;
|
|
50
44
|
}
|
|
51
|
-
|
|
52
45
|
return _context.abrupt("return", null);
|
|
53
|
-
|
|
54
46
|
case 4:
|
|
55
47
|
_context.next = 6;
|
|
56
48
|
return fs.stat(dirname);
|
|
57
|
-
|
|
58
49
|
case 6:
|
|
59
50
|
isDirectory = _context.sent.isDirectory();
|
|
60
|
-
|
|
61
51
|
if (isDirectory) {
|
|
62
52
|
_context.next = 9;
|
|
63
53
|
break;
|
|
64
54
|
}
|
|
65
|
-
|
|
66
55
|
return _context.abrupt("return", null);
|
|
67
|
-
|
|
68
56
|
case 9:
|
|
69
57
|
relativeDir = path.relative(rootDir, dirname);
|
|
70
58
|
pathSegments = relativeDir.split(path.sep);
|
|
@@ -73,11 +61,9 @@ export var walk = /*#__PURE__*/function () {
|
|
|
73
61
|
isPathlessLayout = lastSegment.startsWith('__');
|
|
74
62
|
isWithoutLayoutPath = lastSegment.includes('.');
|
|
75
63
|
routePath = isRoot || isPathlessLayout ? '/' : "".concat(lastSegment);
|
|
76
|
-
|
|
77
64
|
if (isWithoutLayoutPath) {
|
|
78
65
|
routePath = lastSegment.split('.').join('/');
|
|
79
66
|
}
|
|
80
|
-
|
|
81
67
|
routePath = replaceDynamicPath(routePath);
|
|
82
68
|
route = {
|
|
83
69
|
path: routePath,
|
|
@@ -85,100 +71,76 @@ export var walk = /*#__PURE__*/function () {
|
|
|
85
71
|
};
|
|
86
72
|
_context.next = 21;
|
|
87
73
|
return fs.readdir(dirname);
|
|
88
|
-
|
|
89
74
|
case 21:
|
|
90
75
|
items = _context.sent;
|
|
91
76
|
_iterator = _createForOfIteratorHelper(items);
|
|
92
77
|
_context.prev = 23;
|
|
93
|
-
|
|
94
78
|
_iterator.s();
|
|
95
|
-
|
|
96
79
|
case 25:
|
|
97
80
|
if ((_step = _iterator.n()).done) {
|
|
98
81
|
_context.next = 47;
|
|
99
82
|
break;
|
|
100
83
|
}
|
|
101
|
-
|
|
102
84
|
item = _step.value;
|
|
103
85
|
itemPath = path.join(dirname, item);
|
|
104
86
|
extname = path.extname(item);
|
|
105
87
|
itemWithoutExt = item.slice(0, -extname.length);
|
|
106
88
|
_context.next = 32;
|
|
107
89
|
return fs.stat(itemPath);
|
|
108
|
-
|
|
109
90
|
case 32:
|
|
110
91
|
_isDirectory = _context.sent.isDirectory();
|
|
111
|
-
|
|
112
92
|
if (!_isDirectory) {
|
|
113
93
|
_context.next = 38;
|
|
114
94
|
break;
|
|
115
95
|
}
|
|
116
|
-
|
|
117
96
|
_context.next = 36;
|
|
118
|
-
return walk(itemPath, rootDir, alias);
|
|
119
|
-
|
|
97
|
+
return walk(itemPath, rootDir, alias, entryName);
|
|
120
98
|
case 36:
|
|
121
99
|
childRoute = _context.sent;
|
|
122
|
-
|
|
123
100
|
if (childRoute) {
|
|
124
101
|
(_route$children = route.children) === null || _route$children === void 0 ? void 0 : _route$children.push(childRoute);
|
|
125
102
|
}
|
|
126
|
-
|
|
127
103
|
case 38:
|
|
128
104
|
if (!(extname && (!JS_EXTENSIONS.includes(extname) || !conventionNames.includes(itemWithoutExt)))) {
|
|
129
105
|
_context.next = 40;
|
|
130
106
|
break;
|
|
131
107
|
}
|
|
132
|
-
|
|
133
108
|
return _context.abrupt("continue", 45);
|
|
134
|
-
|
|
135
109
|
case 40:
|
|
136
110
|
if (itemWithoutExt === LAYOUT_FILE) {
|
|
137
111
|
route._component = replaceWithAlias(alias.basename, itemPath, alias.name);
|
|
138
112
|
}
|
|
139
|
-
|
|
140
113
|
if (itemWithoutExt === PAGE_FILE) {
|
|
141
114
|
_childRoute = createIndexRoute({
|
|
142
115
|
_component: replaceWithAlias(alias.basename, itemPath, alias.name)
|
|
143
|
-
}, rootDir, itemPath);
|
|
116
|
+
}, rootDir, itemPath, entryName);
|
|
144
117
|
(_route$children2 = route.children) === null || _route$children2 === void 0 ? void 0 : _route$children2.push(_childRoute);
|
|
145
118
|
}
|
|
146
|
-
|
|
147
119
|
if (itemWithoutExt === LOADER_FILE) {
|
|
148
120
|
route.loader = replaceWithAlias(alias.basename, itemPath, alias.name);
|
|
149
121
|
}
|
|
150
|
-
|
|
151
122
|
if (itemWithoutExt === LOADING_FILE) {
|
|
152
123
|
route.loading = replaceWithAlias(alias.basename, itemPath, alias.name);
|
|
153
124
|
}
|
|
154
|
-
|
|
155
125
|
if (itemWithoutExt === ERROR_FILE) {
|
|
156
126
|
route.error = replaceWithAlias(alias.basename, itemPath, alias.name);
|
|
157
127
|
}
|
|
158
|
-
|
|
159
128
|
case 45:
|
|
160
129
|
_context.next = 25;
|
|
161
130
|
break;
|
|
162
|
-
|
|
163
131
|
case 47:
|
|
164
132
|
_context.next = 52;
|
|
165
133
|
break;
|
|
166
|
-
|
|
167
134
|
case 49:
|
|
168
135
|
_context.prev = 49;
|
|
169
136
|
_context.t0 = _context["catch"](23);
|
|
170
|
-
|
|
171
137
|
_iterator.e(_context.t0);
|
|
172
|
-
|
|
173
138
|
case 52:
|
|
174
139
|
_context.prev = 52;
|
|
175
|
-
|
|
176
140
|
_iterator.f();
|
|
177
|
-
|
|
178
141
|
return _context.finish(52);
|
|
179
|
-
|
|
180
142
|
case 55:
|
|
181
|
-
finalRoute = createRoute(route, rootDir, path.join(dirname, "".concat(LAYOUT_FILE, ".ts")));
|
|
143
|
+
finalRoute = createRoute(route, rootDir, path.join(dirname, "".concat(LAYOUT_FILE, ".ts")), entryName);
|
|
182
144
|
/**
|
|
183
145
|
* when the url is /, the __auth/layout.tsx component should not be rendered
|
|
184
146
|
* - routes
|
|
@@ -186,13 +148,10 @@ export var walk = /*#__PURE__*/function () {
|
|
|
186
148
|
* - layout.tsx
|
|
187
149
|
* - layout.tsx
|
|
188
150
|
*/
|
|
189
|
-
|
|
190
151
|
if (isPathlessLayout) {
|
|
191
152
|
delete finalRoute.path;
|
|
192
153
|
}
|
|
193
|
-
|
|
194
154
|
return _context.abrupt("return", finalRoute);
|
|
195
|
-
|
|
196
155
|
case 58:
|
|
197
156
|
case "end":
|
|
198
157
|
return _context.stop();
|
|
@@ -200,8 +159,7 @@ export var walk = /*#__PURE__*/function () {
|
|
|
200
159
|
}
|
|
201
160
|
}, _callee, null, [[23, 49, 52, 55]]);
|
|
202
161
|
}));
|
|
203
|
-
|
|
204
|
-
return function walk(_x, _x2, _x3) {
|
|
162
|
+
return function walk(_x, _x2, _x3, _x4) {
|
|
205
163
|
return _ref.apply(this, arguments);
|
|
206
164
|
};
|
|
207
165
|
}();
|
|
@@ -2,19 +2,19 @@ import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIt
|
|
|
2
2
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
3
|
export var index = function index(_ref) {
|
|
4
4
|
var mountId = _ref.mountId,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
imports = _ref.imports,
|
|
6
|
+
renderFunction = _ref.renderFunction,
|
|
7
|
+
exportStatement = _ref.exportStatement;
|
|
8
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
9
|
};
|
|
10
10
|
export var renderFunction = function renderFunction(_ref2) {
|
|
11
11
|
var plugins = _ref2.plugins,
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
customBootstrap = _ref2.customBootstrap,
|
|
13
|
+
fileSystemRoutes = _ref2.fileSystemRoutes;
|
|
14
14
|
return "\n AppWrapper = createApp({\n plugins: [\n ".concat(plugins.map(function (_ref3) {
|
|
15
15
|
var name = _ref3.name,
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
options = _ref3.options,
|
|
17
|
+
args = _ref3.args;
|
|
18
18
|
return "".concat(name, "({...").concat(options, ", ...App?.config?.").concat(args || name, "}),");
|
|
19
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
20
|
};
|
|
@@ -23,46 +23,35 @@ export var html = function html(partials) {
|
|
|
23
23
|
};
|
|
24
24
|
export var routesForServer = function routesForServer(_ref4) {
|
|
25
25
|
var routes = _ref4.routes,
|
|
26
|
-
|
|
26
|
+
alias = _ref4.alias;
|
|
27
27
|
var name = alias.name,
|
|
28
|
-
|
|
28
|
+
basename = alias.basename;
|
|
29
29
|
var loaders = [];
|
|
30
|
-
|
|
31
30
|
var traverseRouteTree = function traverseRouteTree(route) {
|
|
32
31
|
var children;
|
|
33
|
-
|
|
34
32
|
if ('children' in route && route.children) {
|
|
35
33
|
var _route$children;
|
|
36
|
-
|
|
37
34
|
children = route === null || route === void 0 ? void 0 : (_route$children = route.children) === null || _route$children === void 0 ? void 0 : _route$children.map(traverseRouteTree);
|
|
38
35
|
}
|
|
39
|
-
|
|
40
36
|
var loader;
|
|
41
|
-
|
|
42
37
|
if (route.type === 'nested') {
|
|
43
38
|
if (route.loader) {
|
|
44
39
|
loaders.push(route.loader);
|
|
45
40
|
loader = "loader_".concat(loaders.length - 1);
|
|
46
41
|
}
|
|
47
42
|
}
|
|
48
|
-
|
|
49
43
|
var finalRoute = _objectSpread(_objectSpread({}, route), {}, {
|
|
50
44
|
loader: loader,
|
|
51
45
|
children: children
|
|
52
46
|
});
|
|
53
|
-
|
|
54
47
|
return finalRoute;
|
|
55
48
|
};
|
|
56
|
-
|
|
57
49
|
var routesCode = "\n export const routes = [\n ";
|
|
58
|
-
|
|
59
50
|
var _iterator = _createForOfIteratorHelper(routes),
|
|
60
|
-
|
|
61
|
-
|
|
51
|
+
_step;
|
|
62
52
|
try {
|
|
63
53
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
64
54
|
var route = _step.value;
|
|
65
|
-
|
|
66
55
|
if ('type' in route) {
|
|
67
56
|
var newRoute = traverseRouteTree(route);
|
|
68
57
|
routesCode += "".concat(JSON.stringify(newRoute, null, 2).replace(/"(loader_[^"])"/g, '$1'), ",");
|
|
@@ -75,7 +64,6 @@ export var routesForServer = function routesForServer(_ref4) {
|
|
|
75
64
|
} finally {
|
|
76
65
|
_iterator.f();
|
|
77
66
|
}
|
|
78
|
-
|
|
79
67
|
routesCode += "\n];";
|
|
80
68
|
var importLoadersCode = loaders.map(function (loader, index) {
|
|
81
69
|
var realLoaderPath = loader.replace(name, basename);
|
|
@@ -85,87 +73,81 @@ export var routesForServer = function routesForServer(_ref4) {
|
|
|
85
73
|
};
|
|
86
74
|
export var fileSystemRoutes = function fileSystemRoutes(_ref5) {
|
|
87
75
|
var routes = _ref5.routes,
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
76
|
+
ssrMode = _ref5.ssrMode,
|
|
77
|
+
nestedRoutesEntry = _ref5.nestedRoutesEntry,
|
|
78
|
+
entryName = _ref5.entryName;
|
|
79
|
+
// The legacy mode and pages dir routes should use loadable
|
|
80
|
+
// nested routes + renderTostring should use loadable.lazy
|
|
81
|
+
// nested routes + renderToStream should use react.lazy
|
|
82
|
+
var importLazyCode = "\n import { lazy } from \"react\";\n import loadable, { lazy as loadableLazy } from \"@modern-js/runtime/loadable\"\n ";
|
|
91
83
|
var dataLoaderPath = '';
|
|
92
|
-
|
|
93
84
|
if (ssrMode) {
|
|
94
85
|
dataLoaderPath = require.resolve("@modern-js/plugin-data-loader/loader");
|
|
95
|
-
|
|
96
86
|
if (nestedRoutesEntry) {
|
|
97
|
-
dataLoaderPath = "".concat(dataLoaderPath, "?routesDir=").concat(nestedRoutesEntry, "!");
|
|
87
|
+
dataLoaderPath = "".concat(dataLoaderPath, "?routesDir=").concat(nestedRoutesEntry, "&entryName=").concat(entryName, "!");
|
|
98
88
|
}
|
|
99
89
|
}
|
|
100
|
-
|
|
101
90
|
var loadings = [];
|
|
102
91
|
var errors = [];
|
|
103
92
|
var loaders = [];
|
|
104
|
-
|
|
105
93
|
var traverseRouteTree = function traverseRouteTree(route) {
|
|
106
94
|
var children;
|
|
107
|
-
|
|
108
95
|
if ('children' in route && route.children) {
|
|
109
96
|
var _route$children2;
|
|
110
|
-
|
|
111
97
|
children = route === null || route === void 0 ? void 0 : (_route$children2 = route.children) === null || _route$children2 === void 0 ? void 0 : _route$children2.map(traverseRouteTree);
|
|
112
98
|
}
|
|
113
|
-
|
|
114
99
|
var loading;
|
|
115
100
|
var error;
|
|
116
101
|
var loader;
|
|
117
|
-
|
|
102
|
+
var component = '';
|
|
118
103
|
if (route.type === 'nested') {
|
|
119
104
|
if (route.loading) {
|
|
120
105
|
loadings.push(route.loading);
|
|
121
106
|
loading = "loading_".concat(loadings.length - 1);
|
|
122
107
|
}
|
|
123
|
-
|
|
124
108
|
if (route.error) {
|
|
125
109
|
errors.push(route.error);
|
|
126
110
|
error = "error_".concat(errors.length - 1);
|
|
127
111
|
}
|
|
128
|
-
|
|
129
112
|
if (route.loader) {
|
|
130
113
|
loaders.push(route.loader);
|
|
131
114
|
loader = "loader_".concat(loaders.length - 1);
|
|
132
115
|
}
|
|
116
|
+
if (route._component) {
|
|
117
|
+
if (ssrMode === 'stream') {
|
|
118
|
+
component = "lazy(() => import(/* webpackChunkName: \"".concat(route.id, "\" */ /* webpackMode: \"lazy-once\" */ '").concat(route._component, "'))");
|
|
119
|
+
} else {
|
|
120
|
+
component = "loadable(() => import(/* webpackChunkName: \"".concat(route.id, "\" */ /* webpackMode: \"lazy-once\" */ '").concat(route._component, "'))");
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
} else if (route._component) {
|
|
124
|
+
component = "loadable(() => import('".concat(route._component, "'))");
|
|
133
125
|
}
|
|
134
|
-
|
|
135
126
|
var finalRoute = _objectSpread(_objectSpread({}, route), {}, {
|
|
136
127
|
loading: loading,
|
|
137
128
|
loader: loader,
|
|
138
129
|
error: error,
|
|
139
130
|
children: children
|
|
140
131
|
});
|
|
141
|
-
|
|
142
132
|
if (route._component) {
|
|
143
|
-
var component = ssrMode === 'stream' ? "lazy(() => import('".concat(route._component, "'))") : "loadable(() => import('".concat(route._component, "'))");
|
|
144
133
|
finalRoute.component = component;
|
|
145
134
|
}
|
|
146
|
-
|
|
147
135
|
return finalRoute;
|
|
148
136
|
};
|
|
149
|
-
|
|
150
137
|
var routeComponentsCode = "\n export const routes = [\n ";
|
|
151
|
-
|
|
152
138
|
var _iterator2 = _createForOfIteratorHelper(routes),
|
|
153
|
-
|
|
154
|
-
|
|
139
|
+
_step2;
|
|
155
140
|
try {
|
|
156
141
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
157
142
|
var route = _step2.value;
|
|
158
|
-
|
|
159
143
|
if ('type' in route) {
|
|
160
144
|
var newRoute = traverseRouteTree(route);
|
|
161
|
-
routeComponentsCode += "".concat(JSON.stringify(newRoute, null, 2).replace(/"(loadable
|
|
145
|
+
routeComponentsCode += "".concat(JSON.stringify(newRoute, null, 2).replace(/"(loadable.*\))"/g, '$1').replace(/"(loadableLazy.*\))"/g, '$1').replace(/"(lazy.*\))"/g, '$1').replace(/"(loading_[^"])"/g, '$1').replace(/"(loader_[^"])"/g, '$1').replace(/"(error_[^"])"/g, '$1').replace(/\\"/g, '"'), ",");
|
|
162
146
|
} else {
|
|
163
|
-
var component =
|
|
164
|
-
|
|
147
|
+
var component = "loadable(() => import('".concat(route._component, "'))");
|
|
165
148
|
var finalRoute = _objectSpread(_objectSpread({}, route), {}, {
|
|
166
149
|
component: component
|
|
167
150
|
});
|
|
168
|
-
|
|
169
151
|
routeComponentsCode += "".concat(JSON.stringify(finalRoute, null, 2).replace(/"(loadable[^"]*)"/g, '$1').replace(/"(lazy[^"]*)"/g, '$1'), ",");
|
|
170
152
|
}
|
|
171
153
|
}
|
|
@@ -174,7 +156,6 @@ export var fileSystemRoutes = function fileSystemRoutes(_ref5) {
|
|
|
174
156
|
} finally {
|
|
175
157
|
_iterator2.f();
|
|
176
158
|
}
|
|
177
|
-
|
|
178
159
|
routeComponentsCode += "\n];";
|
|
179
160
|
var importLoadingCode = loadings.map(function (loading, index) {
|
|
180
161
|
return "import loading_".concat(index, " from '").concat(loading, "';\n");
|
|
@@ -6,7 +6,6 @@ import { FILE_SYSTEM_ROUTES_FILE_NAME } from "./constants";
|
|
|
6
6
|
export var walkDirectory = function walkDirectory(dir) {
|
|
7
7
|
return fs.readdirSync(dir).reduce(function (previous, filename) {
|
|
8
8
|
var filePath = path.join(dir, filename);
|
|
9
|
-
|
|
10
9
|
if (fs.statSync(filePath).isDirectory()) {
|
|
11
10
|
return [].concat(_toConsumableArray(previous), _toConsumableArray(walkDirectory(filePath)));
|
|
12
11
|
} else {
|
|
@@ -16,14 +15,14 @@ export var walkDirectory = function walkDirectory(dir) {
|
|
|
16
15
|
};
|
|
17
16
|
export var getDefaultImports = function getDefaultImports(_ref) {
|
|
18
17
|
var entrypoint = _ref.entrypoint,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
srcDirectory = _ref.srcDirectory,
|
|
19
|
+
internalSrcAlias = _ref.internalSrcAlias,
|
|
20
|
+
internalDirAlias = _ref.internalDirAlias,
|
|
21
|
+
internalDirectory = _ref.internalDirectory;
|
|
23
22
|
var entryName = entrypoint.entryName,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
fileSystemRoutes = entrypoint.fileSystemRoutes,
|
|
24
|
+
customBootstrap = entrypoint.customBootstrap,
|
|
25
|
+
entry = entrypoint.entry;
|
|
27
26
|
var imports = [{
|
|
28
27
|
specifiers: [{
|
|
29
28
|
local: 'React'
|
|
@@ -47,7 +46,6 @@ export var getDefaultImports = function getDefaultImports(_ref) {
|
|
|
47
46
|
}],
|
|
48
47
|
value: normalizeToPosixPath(customBootstrap.replace(srcDirectory, internalSrcAlias))
|
|
49
48
|
}].filter(Boolean);
|
|
50
|
-
|
|
51
49
|
if (fileSystemRoutes) {
|
|
52
50
|
var route = {
|
|
53
51
|
specifiers: [{
|
|
@@ -55,7 +53,6 @@ export var getDefaultImports = function getDefaultImports(_ref) {
|
|
|
55
53
|
}],
|
|
56
54
|
value: normalizeToPosixPath("".concat(internalDirAlias, "/").concat(entryName, "/").concat(FILE_SYSTEM_ROUTES_FILE_NAME))
|
|
57
55
|
};
|
|
58
|
-
|
|
59
56
|
if (fileSystemRoutes.globalApp) {
|
|
60
57
|
imports.push({
|
|
61
58
|
specifiers: [{
|
|
@@ -66,7 +63,6 @@ export var getDefaultImports = function getDefaultImports(_ref) {
|
|
|
66
63
|
} else {
|
|
67
64
|
route.initialize = 'const App = false;';
|
|
68
65
|
}
|
|
69
|
-
|
|
70
66
|
imports.push(route);
|
|
71
67
|
} else {
|
|
72
68
|
imports.push({
|
|
@@ -76,18 +72,15 @@ export var getDefaultImports = function getDefaultImports(_ref) {
|
|
|
76
72
|
value: normalizeToPosixPath(entry.replace(srcDirectory, internalSrcAlias))
|
|
77
73
|
});
|
|
78
74
|
}
|
|
79
|
-
|
|
80
75
|
return imports;
|
|
81
76
|
};
|
|
82
77
|
export var isRouteComponentFile = function isRouteComponentFile(filePath) {
|
|
83
78
|
if (/\.(d|test|spec|e2e)\.(js|jsx|ts|tsx)$/.test(filePath)) {
|
|
84
79
|
return false;
|
|
85
80
|
}
|
|
86
|
-
|
|
87
81
|
if (['.js', '.jsx', '.ts', '.tsx'].includes(path.extname(filePath))) {
|
|
88
82
|
return true;
|
|
89
83
|
}
|
|
90
|
-
|
|
91
84
|
return false;
|
|
92
85
|
};
|
|
93
86
|
export var replaceWithAlias = function replaceWithAlias(base, filePath, alias) {
|