@modern-js/app-tools 1.21.5 → 2.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +319 -51
- package/dist/js/modern/analyze/constants.js +1 -0
- package/dist/js/modern/analyze/generateCode.js +126 -32
- package/dist/js/modern/analyze/getBundleEntry.js +7 -14
- package/dist/js/modern/analyze/getClientRoutes/getRoutes.js +173 -0
- package/dist/js/modern/analyze/{getClientRoutes.js → getClientRoutes/getRoutesLegacy.js} +13 -58
- package/dist/js/modern/analyze/getClientRoutes/index.js +2 -0
- package/dist/js/modern/analyze/getClientRoutes/utils.js +18 -0
- package/dist/js/modern/analyze/getFileSystemEntry.js +27 -21
- package/dist/js/modern/analyze/getHtmlTemplate.js +2 -9
- package/dist/js/modern/analyze/getServerRoutes.js +15 -32
- package/dist/js/modern/analyze/index.js +81 -23
- 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 +102 -0
- package/dist/js/modern/analyze/templates.js +151 -12
- package/dist/js/modern/analyze/utils.js +2 -8
- package/dist/js/modern/builder/builderPlugins/compatModern.js +208 -0
- package/dist/js/modern/builder/createHtmlConfig.js +58 -0
- package/dist/js/modern/builder/createOutputConfig.js +70 -0
- package/dist/js/modern/builder/createSourceConfig.js +74 -0
- package/dist/js/modern/builder/createToolsConfig.js +87 -0
- package/dist/js/modern/builder/index.js +108 -0
- package/dist/js/modern/builder/share.js +44 -0
- package/dist/js/modern/builder/webpackPlugins/htmlAsyncChunkPlugin.js +29 -0
- package/dist/js/modern/builder/webpackPlugins/htmlBottomTemplate.js +33 -0
- package/dist/js/modern/builder/webpackPlugins/routerPlugin.js +97 -0
- package/dist/js/modern/commands/build.js +16 -110
- package/dist/js/modern/commands/dev.js +12 -28
- package/dist/js/modern/commands/inspect.js +8 -66
- package/dist/js/modern/commands/start.js +2 -3
- package/dist/js/modern/index.js +17 -16
- 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/config.js +1 -12
- package/dist/js/modern/utils/createServer.js +12 -1
- package/dist/js/modern/utils/getSpecifiedEntries.js +0 -6
- package/dist/js/modern/utils/printInstructions.js +3 -2
- package/dist/js/modern/utils/routes.js +0 -2
- package/dist/js/node/analyze/constants.js +3 -1
- package/dist/js/node/analyze/generateCode.js +123 -47
- package/dist/js/node/analyze/getBundleEntry.js +7 -20
- package/dist/js/node/analyze/getClientRoutes/getRoutes.js +181 -0
- package/dist/js/node/analyze/{getClientRoutes.js → getClientRoutes/getRoutesLegacy.js} +19 -78
- package/dist/js/node/analyze/getClientRoutes/index.js +19 -0
- package/dist/js/node/analyze/getClientRoutes/utils.js +28 -0
- package/dist/js/node/analyze/getFileSystemEntry.js +26 -28
- package/dist/js/node/analyze/getHtmlTemplate.js +2 -23
- package/dist/js/node/analyze/getServerRoutes.js +14 -40
- package/dist/js/node/analyze/index.js +81 -33
- 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 +111 -0
- package/dist/js/node/analyze/templates.js +153 -21
- package/dist/js/node/analyze/utils.js +4 -20
- package/dist/js/node/builder/builderPlugins/compatModern.js +216 -0
- package/dist/js/node/builder/createHtmlConfig.js +68 -0
- package/dist/js/node/builder/createOutputConfig.js +76 -0
- package/dist/js/node/builder/createSourceConfig.js +82 -0
- package/dist/js/node/builder/createToolsConfig.js +94 -0
- package/dist/js/node/builder/index.js +117 -0
- package/dist/js/node/builder/share.js +51 -0
- package/dist/js/node/builder/webpackPlugins/htmlAsyncChunkPlugin.js +36 -0
- package/dist/js/node/builder/webpackPlugins/htmlBottomTemplate.js +40 -0
- package/dist/js/node/builder/webpackPlugins/routerPlugin.js +105 -0
- package/dist/js/node/commands/build.js +14 -121
- package/dist/js/node/commands/deploy.js +0 -2
- package/dist/js/node/commands/dev.js +10 -44
- package/dist/js/node/commands/index.js +0 -6
- package/dist/js/node/commands/inspect.js +10 -90
- package/dist/js/node/commands/start.js +2 -11
- package/dist/js/node/exports/server.js +0 -1
- package/dist/js/node/hooks.js +0 -2
- package/dist/js/node/index.js +22 -32
- package/dist/js/node/locale/en.js +0 -1
- package/dist/js/node/locale/index.js +0 -4
- package/dist/js/node/locale/zh.js +0 -1
- package/dist/js/node/utils/commands.js +12 -0
- package/dist/js/node/utils/config.js +1 -25
- package/dist/js/node/utils/createServer.js +15 -11
- 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 +3 -6
- package/dist/js/node/utils/routes.js +0 -5
- package/dist/js/treeshaking/analyze/constants.js +16 -0
- package/dist/js/treeshaking/analyze/generateCode.js +369 -0
- package/dist/js/treeshaking/analyze/getBundleEntry.js +69 -0
- package/dist/js/treeshaking/analyze/getClientRoutes/getRoutes.js +184 -0
- package/dist/js/treeshaking/analyze/getClientRoutes/getRoutesLegacy.js +185 -0
- package/dist/js/treeshaking/analyze/getClientRoutes/index.js +2 -0
- package/dist/js/treeshaking/analyze/getClientRoutes/utils.js +24 -0
- package/dist/js/treeshaking/analyze/getFileSystemEntry.js +96 -0
- package/dist/js/treeshaking/analyze/getHtmlTemplate.js +129 -0
- package/dist/js/treeshaking/analyze/getServerRoutes.js +157 -0
- package/dist/js/treeshaking/analyze/index.js +334 -0
- package/dist/js/treeshaking/analyze/isDefaultExportFunction.js +28 -0
- package/dist/js/treeshaking/analyze/makeLegalIdentifier.js +16 -0
- package/dist/js/treeshaking/analyze/nestedRoutes.js +165 -0
- package/dist/js/treeshaking/analyze/templates.js +170 -0
- package/dist/js/treeshaking/analyze/utils.js +88 -0
- package/dist/js/treeshaking/builder/builderPlugins/compatModern.js +212 -0
- package/dist/js/treeshaking/builder/createHtmlConfig.js +59 -0
- package/dist/js/treeshaking/builder/createOutputConfig.js +70 -0
- package/dist/js/treeshaking/builder/createSourceConfig.js +88 -0
- package/dist/js/treeshaking/builder/createToolsConfig.js +85 -0
- package/dist/js/treeshaking/builder/index.js +161 -0
- package/dist/js/treeshaking/builder/share.js +46 -0
- package/dist/js/treeshaking/builder/webpackPlugins/htmlAsyncChunkPlugin.js +46 -0
- package/dist/js/treeshaking/builder/webpackPlugins/htmlBottomTemplate.js +41 -0
- package/dist/js/treeshaking/builder/webpackPlugins/routerPlugin.js +121 -0
- package/dist/js/treeshaking/commands/build.js +83 -0
- package/dist/js/treeshaking/commands/deploy.js +26 -0
- package/dist/js/treeshaking/commands/dev.js +124 -0
- package/dist/js/treeshaking/commands/index.js +3 -0
- package/dist/js/treeshaking/commands/inspect.js +29 -0
- package/dist/js/treeshaking/commands/start.js +69 -0
- package/dist/js/treeshaking/exports/server.js +1 -0
- package/dist/js/treeshaking/hooks.js +21 -0
- package/dist/js/treeshaking/index.js +267 -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 +124 -0
- package/dist/js/treeshaking/utils/createServer.js +73 -0
- package/dist/js/treeshaking/utils/getSpecifiedEntries.js +58 -0
- package/dist/js/treeshaking/utils/language.js +5 -0
- package/dist/js/treeshaking/utils/printInstructions.js +30 -0
- package/dist/js/treeshaking/utils/routes.js +29 -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 +4 -5
- package/dist/types/analyze/nestedRoutes.d.ts +5 -0
- package/dist/types/analyze/templates.d.ts +19 -3
- package/dist/types/analyze/utils.d.ts +2 -1
- package/dist/types/builder/builderPlugins/compatModern.d.ts +13 -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 +15 -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/builder/webpackPlugins/routerPlugin.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 +2 -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 -4
- 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/config.d.ts +0 -1
- 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 -42
- package/dist/js/modern/utils/createCompiler.js +0 -61
- package/dist/js/node/utils/createCompiler.js +0 -81
- package/dist/types/utils/createCompiler.d.ts +0 -13
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getCommand = void 0;
|
|
7
|
+
const getCommand = () => {
|
|
8
|
+
const args = process.argv.slice(2);
|
|
9
|
+
const command = args[0];
|
|
10
|
+
return command;
|
|
11
|
+
};
|
|
12
|
+
exports.getCommand = getCommand;
|
|
@@ -4,27 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.safeReplacer = exports.emitResolvedConfig = exports.defineServerConfig = exports.buildServerConfig = void 0;
|
|
7
|
-
|
|
8
7
|
var path = _interopRequireWildcard(require("path"));
|
|
9
|
-
|
|
10
8
|
var _nodeBundleRequire = require("@modern-js/node-bundle-require");
|
|
11
|
-
|
|
12
9
|
var _utils = require("@modern-js/utils");
|
|
13
|
-
|
|
14
10
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
15
|
-
|
|
16
11
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
17
|
-
|
|
18
12
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
19
|
-
|
|
20
13
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
21
|
-
|
|
22
14
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
23
|
-
|
|
24
15
|
const defineServerConfig = config => config;
|
|
25
|
-
|
|
26
16
|
exports.defineServerConfig = defineServerConfig;
|
|
27
|
-
|
|
28
17
|
const buildServerConfig = async ({
|
|
29
18
|
appDirectory,
|
|
30
19
|
distDirectory,
|
|
@@ -32,9 +21,7 @@ const buildServerConfig = async ({
|
|
|
32
21
|
options
|
|
33
22
|
}) => {
|
|
34
23
|
const configFilePath = await (0, _utils.getServerConfig)(appDirectory, configFile);
|
|
35
|
-
|
|
36
24
|
const getOutputFile = async filepath => path.resolve(distDirectory, `${filepath.replace(new RegExp(_utils.CONFIG_FILE_EXTENSIONS.join('|')), '')}.js`);
|
|
37
|
-
|
|
38
25
|
if (configFilePath) {
|
|
39
26
|
const configHelperFilePath = path.normalize(path.join(distDirectory, './config-helper.js'));
|
|
40
27
|
const helperCode = `
|
|
@@ -46,7 +33,6 @@ const buildServerConfig = async ({
|
|
|
46
33
|
getOutputFile,
|
|
47
34
|
esbuildPlugins: [{
|
|
48
35
|
name: 'native-build-config',
|
|
49
|
-
|
|
50
36
|
setup(ctx) {
|
|
51
37
|
ctx.onResolve({
|
|
52
38
|
filter: /app-tools\/server/
|
|
@@ -56,48 +42,38 @@ const buildServerConfig = async ({
|
|
|
56
42
|
};
|
|
57
43
|
});
|
|
58
44
|
}
|
|
59
|
-
|
|
60
45
|
}]
|
|
61
46
|
}));
|
|
62
47
|
}
|
|
63
48
|
};
|
|
49
|
+
|
|
64
50
|
/**
|
|
65
51
|
*
|
|
66
52
|
* 处理循环引用的 replacer
|
|
67
53
|
*/
|
|
68
|
-
|
|
69
|
-
|
|
70
54
|
exports.buildServerConfig = buildServerConfig;
|
|
71
|
-
|
|
72
55
|
const safeReplacer = () => {
|
|
73
56
|
const cache = [];
|
|
74
57
|
const keyCache = [];
|
|
75
58
|
return function (key, value) {
|
|
76
59
|
if (typeof value === 'object' && value !== null) {
|
|
77
60
|
const index = cache.indexOf(value);
|
|
78
|
-
|
|
79
61
|
if (index !== -1) {
|
|
80
62
|
return `[Circular ${keyCache[index]}]`;
|
|
81
63
|
}
|
|
82
|
-
|
|
83
64
|
cache.push(value);
|
|
84
65
|
keyCache.push(key || 'root');
|
|
85
66
|
}
|
|
86
|
-
|
|
87
67
|
return value;
|
|
88
68
|
};
|
|
89
69
|
};
|
|
90
|
-
|
|
91
70
|
exports.safeReplacer = safeReplacer;
|
|
92
|
-
|
|
93
71
|
const emitResolvedConfig = async (appDirectory, resolvedConfig) => {
|
|
94
72
|
var _resolvedConfig$outpu;
|
|
95
|
-
|
|
96
73
|
const outputPath = path.join(appDirectory, (resolvedConfig === null || resolvedConfig === void 0 ? void 0 : (_resolvedConfig$outpu = resolvedConfig.output) === null || _resolvedConfig$outpu === void 0 ? void 0 : _resolvedConfig$outpu.path) || './dist', _utils.OUTPUT_CONFIG_FILE);
|
|
97
74
|
await _utils.fs.writeJSON(outputPath, resolvedConfig, {
|
|
98
75
|
spaces: 2,
|
|
99
76
|
replacer: safeReplacer()
|
|
100
77
|
});
|
|
101
78
|
};
|
|
102
|
-
|
|
103
79
|
exports.emitResolvedConfig = emitResolvedConfig;
|
|
@@ -3,33 +3,37 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.getServer = exports.createServer = exports.closeServer = void 0;
|
|
7
|
-
|
|
6
|
+
exports.injectDataLoaderPlugin = exports.getServer = exports.createServer = exports.closeServer = void 0;
|
|
8
7
|
var _server = require("@modern-js/server");
|
|
9
|
-
|
|
8
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
9
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
10
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
10
11
|
let server = null;
|
|
11
|
-
|
|
12
12
|
const getServer = () => server;
|
|
13
|
-
|
|
14
13
|
exports.getServer = getServer;
|
|
15
|
-
|
|
16
14
|
const closeServer = async () => {
|
|
17
15
|
if (server) {
|
|
18
16
|
await server.close();
|
|
19
17
|
server = null;
|
|
20
18
|
}
|
|
21
19
|
};
|
|
22
|
-
|
|
23
20
|
exports.closeServer = closeServer;
|
|
24
|
-
|
|
25
21
|
const createServer = async options => {
|
|
26
22
|
if (server) {
|
|
27
23
|
await server.close();
|
|
28
24
|
}
|
|
29
|
-
|
|
30
25
|
server = new _server.Server(options);
|
|
31
26
|
const app = await server.init();
|
|
32
27
|
return app;
|
|
33
28
|
};
|
|
34
|
-
|
|
35
|
-
|
|
29
|
+
exports.createServer = createServer;
|
|
30
|
+
const injectDataLoaderPlugin = internalPlugins => {
|
|
31
|
+
const DataLoaderPlugin = require.resolve('@modern-js/plugin-data-loader/server');
|
|
32
|
+
return _objectSpread(_objectSpread({}, internalPlugins), {}, {
|
|
33
|
+
'@modern-js/plugin-data-loader': {
|
|
34
|
+
path: DataLoaderPlugin,
|
|
35
|
+
forced: true
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
exports.injectDataLoaderPlugin = injectDataLoaderPlugin;
|
|
@@ -4,16 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getSpecifiedEntries = void 0;
|
|
7
|
-
|
|
8
7
|
var _utils = require("@modern-js/utils");
|
|
9
|
-
|
|
10
8
|
const getSpecifiedEntries = async (entry, entrypoints) => {
|
|
11
9
|
const entryNames = entrypoints.map(e => e.entryName);
|
|
12
|
-
|
|
13
10
|
if (!entry) {
|
|
14
11
|
return entryNames;
|
|
15
12
|
}
|
|
16
|
-
|
|
17
13
|
if (typeof entry === 'boolean') {
|
|
18
14
|
const {
|
|
19
15
|
selected
|
|
@@ -22,19 +18,15 @@ const getSpecifiedEntries = async (entry, entrypoints) => {
|
|
|
22
18
|
name: 'selected',
|
|
23
19
|
choices: entryNames,
|
|
24
20
|
message: '请选择需要构建的入口',
|
|
25
|
-
|
|
26
21
|
validate(answer) {
|
|
27
22
|
if (answer.length < 1) {
|
|
28
23
|
return 'You must choose at least one topping.';
|
|
29
24
|
}
|
|
30
|
-
|
|
31
25
|
return true;
|
|
32
26
|
}
|
|
33
|
-
|
|
34
27
|
}]);
|
|
35
28
|
return selected;
|
|
36
29
|
}
|
|
37
|
-
|
|
38
30
|
entry.forEach(name => {
|
|
39
31
|
if (!entryNames.includes(name)) {
|
|
40
32
|
throw new Error(`can not found entry ${name}, compiler entry should in ${entryNames.join(', ')}`);
|
|
@@ -42,5 +34,4 @@ const getSpecifiedEntries = async (entry, entrypoints) => {
|
|
|
42
34
|
});
|
|
43
35
|
return entry;
|
|
44
36
|
};
|
|
45
|
-
|
|
46
37
|
exports.getSpecifiedEntries = getSpecifiedEntries;
|
|
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getLocaleLanguage = getLocaleLanguage;
|
|
7
|
-
|
|
8
7
|
var _languageDetector = require("@modern-js/plugin-i18n/language-detector");
|
|
9
|
-
|
|
10
8
|
function getLocaleLanguage() {
|
|
11
9
|
const detector = new _languageDetector.I18CLILanguageDetector();
|
|
12
10
|
return detector.detect();
|
|
@@ -4,19 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.printInstructions = void 0;
|
|
7
|
-
|
|
8
7
|
var _utils = require("@modern-js/utils");
|
|
9
|
-
|
|
10
8
|
const printInstructions = async (hookRunners, appContext, config) => {
|
|
11
|
-
const message = (0, _utils.prettyInstructions)(appContext, config);
|
|
9
|
+
const message = (0, _utils.prettyInstructions)(appContext, config);
|
|
12
10
|
|
|
11
|
+
// call beforePrintInstructions hook.
|
|
13
12
|
const {
|
|
14
13
|
instructions
|
|
15
14
|
} = await hookRunners.beforePrintInstructions({
|
|
16
15
|
instructions: message
|
|
17
16
|
});
|
|
18
|
-
|
|
19
|
-
_utils.logger.log(instructions);
|
|
17
|
+
_utils.logger.info(instructions);
|
|
20
18
|
};
|
|
21
|
-
|
|
22
19
|
exports.printInstructions = printInstructions;
|
|
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.generateRoutes = void 0;
|
|
7
|
-
|
|
8
7
|
var _path = _interopRequireDefault(require("path"));
|
|
9
|
-
|
|
10
8
|
var _utils = require("@modern-js/utils");
|
|
11
|
-
|
|
12
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
10
|
const generateRoutes = async appContext => {
|
|
15
11
|
const {
|
|
16
12
|
serverRoutes,
|
|
@@ -21,5 +17,4 @@ const generateRoutes = async appContext => {
|
|
|
21
17
|
}, null, 2);
|
|
22
18
|
await _utils.fs.outputFile(_path.default.join(distDirectory, _utils.ROUTE_SPEC_FILE), output);
|
|
23
19
|
};
|
|
24
|
-
|
|
25
20
|
exports.generateRoutes = generateRoutes;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export var JS_EXTENSIONS = ['.js', '.ts', '.jsx', '.tsx'];
|
|
2
|
+
export var INDEX_FILE_NAME = 'index';
|
|
3
|
+
export var APP_FILE_NAME = 'App';
|
|
4
|
+
export var PAGES_DIR_NAME = 'pages';
|
|
5
|
+
export var NESTED_ROUTES_DIR = 'routes';
|
|
6
|
+
export var FILE_SYSTEM_ROUTES_FILE_NAME = 'routes.js';
|
|
7
|
+
export var ENTRY_POINT_FILE_NAME = 'index.js';
|
|
8
|
+
export var ENTRY_BOOTSTRAP_FILE_NAME = 'bootstrap.js';
|
|
9
|
+
export var FILE_SYSTEM_ROUTES_DYNAMIC_REGEXP = /^\[(\S+)\]([*+?]?)$/;
|
|
10
|
+
export var FILE_SYSTEM_ROUTES_LAYOUT = '_layout';
|
|
11
|
+
export var FILE_SYSTEM_ROUTES_GLOBAL_LAYOUT = '_app';
|
|
12
|
+
export var FILE_SYSTEM_ROUTES_INDEX = 'index';
|
|
13
|
+
export var FILE_SYSTEM_ROUTES_IGNORED_REGEX = /\.(d|test|spec|e2e)\.(js|jsx|ts|tsx)$/;
|
|
14
|
+
export var HTML_PARTIALS_FOLDER = 'html';
|
|
15
|
+
export var HTML_PARTIALS_EXTENSIONS = ['.htm', '.html', '.ejs'];
|
|
16
|
+
export var FILE_SYSTEM_ROUTES_COMPONENTS_DIR = 'internal_components';
|
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
2
|
+
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
3
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
4
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
5
|
+
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
|
6
|
+
import path from 'path';
|
|
7
|
+
import { fs, logger } from '@modern-js/utils';
|
|
8
|
+
import { useResolvedConfigContext } from '@modern-js/core';
|
|
9
|
+
import esbuild from 'esbuild';
|
|
10
|
+
import { getCommand } from "../utils/commands";
|
|
11
|
+
import * as templates from "./templates";
|
|
12
|
+
import { getClientRoutes, getClientRoutesLegacy } from "./getClientRoutes";
|
|
13
|
+
import { FILE_SYSTEM_ROUTES_FILE_NAME, ENTRY_POINT_FILE_NAME, ENTRY_BOOTSTRAP_FILE_NAME } from "./constants";
|
|
14
|
+
import { getDefaultImports } from "./utils";
|
|
15
|
+
import { walk } from "./nestedRoutes";
|
|
16
|
+
var createImportSpecifier = function createImportSpecifier(specifiers) {
|
|
17
|
+
var defaults = '';
|
|
18
|
+
var named = [];
|
|
19
|
+
var _iterator = _createForOfIteratorHelper(specifiers),
|
|
20
|
+
_step;
|
|
21
|
+
try {
|
|
22
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
23
|
+
var _step$value = _step.value,
|
|
24
|
+
local = _step$value.local,
|
|
25
|
+
imported = _step$value.imported;
|
|
26
|
+
if (local && imported) {
|
|
27
|
+
named.push("".concat(imported, " as ").concat(local));
|
|
28
|
+
} else if (local) {
|
|
29
|
+
defaults = local;
|
|
30
|
+
} else {
|
|
31
|
+
named.push(imported);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
} catch (err) {
|
|
35
|
+
_iterator.e(err);
|
|
36
|
+
} finally {
|
|
37
|
+
_iterator.f();
|
|
38
|
+
}
|
|
39
|
+
if (defaults && named.length) {
|
|
40
|
+
return "".concat(defaults, ", { ").concat(named.join(', '), " }");
|
|
41
|
+
} else if (defaults) {
|
|
42
|
+
return defaults;
|
|
43
|
+
} else {
|
|
44
|
+
return "{ ".concat(named.join(', '), " }");
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
export var createImportStatements = function createImportStatements(statements) {
|
|
48
|
+
// merge import statements with the same value.
|
|
49
|
+
var deDuplicated = [];
|
|
50
|
+
var seen = new Map();
|
|
51
|
+
var _iterator2 = _createForOfIteratorHelper(statements),
|
|
52
|
+
_step2;
|
|
53
|
+
try {
|
|
54
|
+
var _loop = function _loop() {
|
|
55
|
+
var _step2$value = _step2.value,
|
|
56
|
+
value = _step2$value.value,
|
|
57
|
+
specifiers = _step2$value.specifiers,
|
|
58
|
+
initialize = _step2$value.initialize;
|
|
59
|
+
if (!seen.has(value)) {
|
|
60
|
+
deDuplicated.push({
|
|
61
|
+
value: value,
|
|
62
|
+
specifiers: specifiers,
|
|
63
|
+
initialize: initialize
|
|
64
|
+
});
|
|
65
|
+
seen.set(value, specifiers);
|
|
66
|
+
} else {
|
|
67
|
+
var _seen$get, _deDuplicated$modifyI, _deDuplicated$modifyI2;
|
|
68
|
+
(_seen$get = seen.get(value)).push.apply(_seen$get, _toConsumableArray(specifiers));
|
|
69
|
+
// make "initialize" param can be connected when multiple plugins were imported from same package
|
|
70
|
+
var modifyIndex = deDuplicated.findIndex(function (v) {
|
|
71
|
+
return v.value === value;
|
|
72
|
+
});
|
|
73
|
+
var originInitialize = (_deDuplicated$modifyI = (_deDuplicated$modifyI2 = deDuplicated[modifyIndex]) === null || _deDuplicated$modifyI2 === void 0 ? void 0 : _deDuplicated$modifyI2.initialize) !== null && _deDuplicated$modifyI !== void 0 ? _deDuplicated$modifyI : '';
|
|
74
|
+
deDuplicated[modifyIndex].initialize = originInitialize.concat("\n".concat(initialize || ''));
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
78
|
+
_loop();
|
|
79
|
+
}
|
|
80
|
+
} catch (err) {
|
|
81
|
+
_iterator2.e(err);
|
|
82
|
+
} finally {
|
|
83
|
+
_iterator2.f();
|
|
84
|
+
}
|
|
85
|
+
return deDuplicated.map(function (_ref) {
|
|
86
|
+
var value = _ref.value,
|
|
87
|
+
specifiers = _ref.specifiers,
|
|
88
|
+
initialize = _ref.initialize;
|
|
89
|
+
return "import ".concat(createImportSpecifier(specifiers), " from '").concat(value, "';\n").concat(initialize || '');
|
|
90
|
+
}).join('\n');
|
|
91
|
+
};
|
|
92
|
+
var buildLoader = /*#__PURE__*/function () {
|
|
93
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(entry, outfile) {
|
|
94
|
+
var loader, EXTERNAL_REGEXP, command;
|
|
95
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
96
|
+
while (1) {
|
|
97
|
+
switch (_context.prev = _context.next) {
|
|
98
|
+
case 0:
|
|
99
|
+
loader = {
|
|
100
|
+
'.js': 'jsx',
|
|
101
|
+
'.ts': 'tsx'
|
|
102
|
+
};
|
|
103
|
+
EXTERNAL_REGEXP = /^[^./]|^\.[^./]|^\.\.[^/]/;
|
|
104
|
+
command = getCommand();
|
|
105
|
+
_context.next = 5;
|
|
106
|
+
return esbuild.build({
|
|
107
|
+
format: 'cjs',
|
|
108
|
+
platform: 'node',
|
|
109
|
+
target: 'esnext',
|
|
110
|
+
loader: loader,
|
|
111
|
+
watch: command === 'dev' && {},
|
|
112
|
+
bundle: true,
|
|
113
|
+
logLevel: 'error',
|
|
114
|
+
entryPoints: [entry],
|
|
115
|
+
outfile: outfile,
|
|
116
|
+
plugins: [{
|
|
117
|
+
name: 'make-all-packages-external',
|
|
118
|
+
setup: function setup(build) {
|
|
119
|
+
// https://github.com/evanw/esbuild/issues/619#issuecomment-751995294
|
|
120
|
+
build.onResolve({
|
|
121
|
+
filter: EXTERNAL_REGEXP
|
|
122
|
+
}, function (args) {
|
|
123
|
+
var external = true;
|
|
124
|
+
// FIXME: windows external entrypoint
|
|
125
|
+
if (args.kind === 'entry-point') {
|
|
126
|
+
external = false;
|
|
127
|
+
}
|
|
128
|
+
return {
|
|
129
|
+
path: args.path,
|
|
130
|
+
external: external
|
|
131
|
+
};
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
}]
|
|
135
|
+
});
|
|
136
|
+
case 5:
|
|
137
|
+
case "end":
|
|
138
|
+
return _context.stop();
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}, _callee);
|
|
142
|
+
}));
|
|
143
|
+
return function buildLoader(_x, _x2) {
|
|
144
|
+
return _ref2.apply(this, arguments);
|
|
145
|
+
};
|
|
146
|
+
}();
|
|
147
|
+
export var generateCode = /*#__PURE__*/function () {
|
|
148
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(appContext, config, entrypoints, api) {
|
|
149
|
+
var _config$runtime, _config$runtime$route;
|
|
150
|
+
var internalDirectory, distDirectory, srcDirectory, internalDirAlias, internalSrcAlias, hookRunners, islegacy, mountId, getRoutes, generateEntryCode, _generateEntryCode;
|
|
151
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
152
|
+
while (1) {
|
|
153
|
+
switch (_context3.prev = _context3.next) {
|
|
154
|
+
case 0:
|
|
155
|
+
_generateEntryCode = function _generateEntryCode3() {
|
|
156
|
+
_generateEntryCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(entrypoint) {
|
|
157
|
+
var entryName, isAutoMount, customBootstrap, fileSystemRoutes, initialRoutes, nestedRoute, _yield$hookRunners$mo, routes, _config, ssr, mode, hasPageRoute, _yield$hookRunners$be, _code, routesServerFile, outputRoutesServerFile, _code2, _yield$hookRunners$mo2, importStatements, _yield$hookRunners$mo3, plugins, _yield$hookRunners$mo4, renderFunction, _yield$hookRunners$mo5, exportStatement, code, entryFile, _yield$hookRunners$mo6, asyncEntryCode, bootstrapFile;
|
|
158
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
159
|
+
while (1) {
|
|
160
|
+
switch (_context2.prev = _context2.next) {
|
|
161
|
+
case 0:
|
|
162
|
+
entryName = entrypoint.entryName, isAutoMount = entrypoint.isAutoMount, customBootstrap = entrypoint.customBootstrap, fileSystemRoutes = entrypoint.fileSystemRoutes;
|
|
163
|
+
if (!isAutoMount) {
|
|
164
|
+
_context2.next = 69;
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
if (!fileSystemRoutes) {
|
|
168
|
+
_context2.next = 39;
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
initialRoutes = [];
|
|
172
|
+
nestedRoute = null;
|
|
173
|
+
if (entrypoint.entry) {
|
|
174
|
+
initialRoutes = getRoutes({
|
|
175
|
+
entrypoint: entrypoint,
|
|
176
|
+
srcDirectory: srcDirectory,
|
|
177
|
+
srcAlias: internalSrcAlias,
|
|
178
|
+
internalDirectory: internalDirectory,
|
|
179
|
+
internalDirAlias: internalDirAlias
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
if (!entrypoint.nestedRoutesEntry) {
|
|
183
|
+
_context2.next = 16;
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
if (islegacy) {
|
|
187
|
+
_context2.next = 14;
|
|
188
|
+
break;
|
|
189
|
+
}
|
|
190
|
+
_context2.next = 10;
|
|
191
|
+
return walk(entrypoint.nestedRoutesEntry, entrypoint.nestedRoutesEntry, {
|
|
192
|
+
name: internalSrcAlias,
|
|
193
|
+
basename: srcDirectory
|
|
194
|
+
}, entrypoint.entryName);
|
|
195
|
+
case 10:
|
|
196
|
+
nestedRoute = _context2.sent;
|
|
197
|
+
if (nestedRoute) {
|
|
198
|
+
initialRoutes.unshift(nestedRoute);
|
|
199
|
+
}
|
|
200
|
+
_context2.next = 16;
|
|
201
|
+
break;
|
|
202
|
+
case 14:
|
|
203
|
+
logger.error('Nested routes is not supported in legacy mode.');
|
|
204
|
+
// eslint-disable-next-line no-process-exit
|
|
205
|
+
process.exit(1);
|
|
206
|
+
case 16:
|
|
207
|
+
_context2.next = 18;
|
|
208
|
+
return hookRunners.modifyFileSystemRoutes({
|
|
209
|
+
entrypoint: entrypoint,
|
|
210
|
+
routes: initialRoutes
|
|
211
|
+
});
|
|
212
|
+
case 18:
|
|
213
|
+
_yield$hookRunners$mo = _context2.sent;
|
|
214
|
+
routes = _yield$hookRunners$mo.routes;
|
|
215
|
+
_config = useResolvedConfigContext();
|
|
216
|
+
ssr = _config === null || _config === void 0 ? void 0 : _config.server.ssr;
|
|
217
|
+
if (ssr) {
|
|
218
|
+
mode = _typeof(ssr) === 'object' ? ssr.mode || 'string' : 'string';
|
|
219
|
+
} else {
|
|
220
|
+
mode = false;
|
|
221
|
+
}
|
|
222
|
+
if (mode === 'stream') {
|
|
223
|
+
hasPageRoute = routes.some(function (route) {
|
|
224
|
+
return 'type' in route && route.type === 'page';
|
|
225
|
+
});
|
|
226
|
+
if (hasPageRoute) {
|
|
227
|
+
logger.error('streaming ssr is not supported when pages dir exists');
|
|
228
|
+
// eslint-disable-next-line no-process-exit
|
|
229
|
+
process.exit(1);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
_context2.next = 26;
|
|
233
|
+
return hookRunners.beforeGenerateRoutes({
|
|
234
|
+
entrypoint: entrypoint,
|
|
235
|
+
code: templates.fileSystemRoutes({
|
|
236
|
+
routes: routes,
|
|
237
|
+
ssrMode: mode,
|
|
238
|
+
nestedRoutesEntry: entrypoint.nestedRoutesEntry,
|
|
239
|
+
entryName: entrypoint.entryName
|
|
240
|
+
})
|
|
241
|
+
});
|
|
242
|
+
case 26:
|
|
243
|
+
_yield$hookRunners$be = _context2.sent;
|
|
244
|
+
_code = _yield$hookRunners$be.code;
|
|
245
|
+
if (!entrypoint.nestedRoutesEntry) {
|
|
246
|
+
_context2.next = 38;
|
|
247
|
+
break;
|
|
248
|
+
}
|
|
249
|
+
routesServerFile = path.join(internalDirectory, entryName, 'routes.server.js');
|
|
250
|
+
outputRoutesServerFile = path.join(distDirectory, 'loader-routes', entryName, 'index.js');
|
|
251
|
+
_code2 = templates.routesForServer({
|
|
252
|
+
routes: routes,
|
|
253
|
+
alias: {
|
|
254
|
+
name: internalSrcAlias,
|
|
255
|
+
basename: srcDirectory
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
_context2.next = 34;
|
|
259
|
+
return fs.ensureFile(routesServerFile);
|
|
260
|
+
case 34:
|
|
261
|
+
_context2.next = 36;
|
|
262
|
+
return fs.writeFile(routesServerFile, _code2);
|
|
263
|
+
case 36:
|
|
264
|
+
_context2.next = 38;
|
|
265
|
+
return buildLoader(routesServerFile, outputRoutesServerFile);
|
|
266
|
+
case 38:
|
|
267
|
+
fs.outputFileSync(path.resolve(internalDirectory, "./".concat(entryName, "/").concat(FILE_SYSTEM_ROUTES_FILE_NAME)), _code, 'utf8');
|
|
268
|
+
case 39:
|
|
269
|
+
_context2.next = 41;
|
|
270
|
+
return hookRunners.modifyEntryImports({
|
|
271
|
+
entrypoint: entrypoint,
|
|
272
|
+
imports: getDefaultImports({
|
|
273
|
+
entrypoint: entrypoint,
|
|
274
|
+
srcDirectory: srcDirectory,
|
|
275
|
+
internalSrcAlias: internalSrcAlias,
|
|
276
|
+
internalDirAlias: internalDirAlias,
|
|
277
|
+
internalDirectory: internalDirectory
|
|
278
|
+
})
|
|
279
|
+
});
|
|
280
|
+
case 41:
|
|
281
|
+
_yield$hookRunners$mo2 = _context2.sent;
|
|
282
|
+
importStatements = _yield$hookRunners$mo2.imports;
|
|
283
|
+
_context2.next = 45;
|
|
284
|
+
return hookRunners.modifyEntryRuntimePlugins({
|
|
285
|
+
entrypoint: entrypoint,
|
|
286
|
+
plugins: []
|
|
287
|
+
});
|
|
288
|
+
case 45:
|
|
289
|
+
_yield$hookRunners$mo3 = _context2.sent;
|
|
290
|
+
plugins = _yield$hookRunners$mo3.plugins;
|
|
291
|
+
_context2.next = 49;
|
|
292
|
+
return hookRunners.modifyEntryRenderFunction({
|
|
293
|
+
entrypoint: entrypoint,
|
|
294
|
+
code: templates.renderFunction({
|
|
295
|
+
plugins: plugins,
|
|
296
|
+
customBootstrap: customBootstrap,
|
|
297
|
+
fileSystemRoutes: fileSystemRoutes
|
|
298
|
+
})
|
|
299
|
+
});
|
|
300
|
+
case 49:
|
|
301
|
+
_yield$hookRunners$mo4 = _context2.sent;
|
|
302
|
+
renderFunction = _yield$hookRunners$mo4.code;
|
|
303
|
+
_context2.next = 53;
|
|
304
|
+
return hookRunners.modifyEntryExport({
|
|
305
|
+
entrypoint: entrypoint,
|
|
306
|
+
exportStatement: 'export default AppWrapper;'
|
|
307
|
+
});
|
|
308
|
+
case 53:
|
|
309
|
+
_yield$hookRunners$mo5 = _context2.sent;
|
|
310
|
+
exportStatement = _yield$hookRunners$mo5.exportStatement;
|
|
311
|
+
code = templates.index({
|
|
312
|
+
mountId: mountId,
|
|
313
|
+
imports: createImportStatements(importStatements),
|
|
314
|
+
renderFunction: renderFunction,
|
|
315
|
+
exportStatement: exportStatement
|
|
316
|
+
});
|
|
317
|
+
entryFile = path.resolve(internalDirectory, "./".concat(entryName, "/").concat(ENTRY_POINT_FILE_NAME));
|
|
318
|
+
entrypoint.entry = entryFile;
|
|
319
|
+
|
|
320
|
+
// generate entry file.
|
|
321
|
+
if (!config.source.enableAsyncEntry) {
|
|
322
|
+
_context2.next = 68;
|
|
323
|
+
break;
|
|
324
|
+
}
|
|
325
|
+
_context2.next = 61;
|
|
326
|
+
return hookRunners.modifyAsyncEntry({
|
|
327
|
+
entrypoint: entrypoint,
|
|
328
|
+
code: "import('./".concat(ENTRY_BOOTSTRAP_FILE_NAME, "');")
|
|
329
|
+
});
|
|
330
|
+
case 61:
|
|
331
|
+
_yield$hookRunners$mo6 = _context2.sent;
|
|
332
|
+
asyncEntryCode = _yield$hookRunners$mo6.code;
|
|
333
|
+
fs.outputFileSync(entryFile, asyncEntryCode, 'utf8');
|
|
334
|
+
bootstrapFile = path.resolve(internalDirectory, "./".concat(entryName, "/").concat(ENTRY_BOOTSTRAP_FILE_NAME));
|
|
335
|
+
fs.outputFileSync(bootstrapFile, code, 'utf8');
|
|
336
|
+
_context2.next = 69;
|
|
337
|
+
break;
|
|
338
|
+
case 68:
|
|
339
|
+
fs.outputFileSync(entryFile, code, 'utf8');
|
|
340
|
+
case 69:
|
|
341
|
+
case "end":
|
|
342
|
+
return _context2.stop();
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}, _callee2);
|
|
346
|
+
}));
|
|
347
|
+
return _generateEntryCode.apply(this, arguments);
|
|
348
|
+
};
|
|
349
|
+
generateEntryCode = function _generateEntryCode2(_x7) {
|
|
350
|
+
return _generateEntryCode.apply(this, arguments);
|
|
351
|
+
};
|
|
352
|
+
internalDirectory = appContext.internalDirectory, distDirectory = appContext.distDirectory, srcDirectory = appContext.srcDirectory, internalDirAlias = appContext.internalDirAlias, internalSrcAlias = appContext.internalSrcAlias;
|
|
353
|
+
hookRunners = api.useHookRunners();
|
|
354
|
+
islegacy = Boolean(config === null || config === void 0 ? void 0 : (_config$runtime = config.runtime) === null || _config$runtime === void 0 ? void 0 : (_config$runtime$route = _config$runtime.router) === null || _config$runtime$route === void 0 ? void 0 : _config$runtime$route.legacy);
|
|
355
|
+
mountId = config.output.mountId;
|
|
356
|
+
getRoutes = islegacy ? getClientRoutesLegacy : getClientRoutes;
|
|
357
|
+
_context3.next = 9;
|
|
358
|
+
return Promise.all(entrypoints.map(generateEntryCode));
|
|
359
|
+
case 9:
|
|
360
|
+
case "end":
|
|
361
|
+
return _context3.stop();
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
}, _callee3);
|
|
365
|
+
}));
|
|
366
|
+
return function generateCode(_x3, _x4, _x5, _x6) {
|
|
367
|
+
return _ref3.apply(this, arguments);
|
|
368
|
+
};
|
|
369
|
+
}();
|