@modern-js/app-tools 2.53.1-alpha.3 → 2.54.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/bin/modern.js +0 -2
- package/dist/cjs/builder/shared/builderPlugins/adapterHtml.js +2 -1
- package/dist/cjs/builder/shared/builderPlugins/adapterSSR.js +2 -2
- package/dist/cjs/commands/build.js +2 -0
- package/dist/cjs/commands/deploy.js +2 -2
- package/dist/cjs/commands/dev.js +19 -5
- package/dist/cjs/commands/index.js +113 -7
- package/dist/cjs/commands/serve.js +19 -5
- package/dist/cjs/hooks.js +5 -0
- package/dist/cjs/index.js +14 -83
- package/dist/cjs/plugins/analyze/constants.js +56 -0
- package/dist/cjs/{analyze → plugins/analyze}/generateCode.js +11 -84
- package/dist/cjs/{analyze → plugins/analyze}/getBundleEntry.js +11 -20
- package/dist/cjs/{analyze → plugins/analyze}/getFileSystemEntry.js +33 -47
- package/dist/cjs/{analyze → plugins/analyze}/getServerRoutes.js +1 -1
- package/dist/cjs/{analyze → plugins/analyze}/index.js +9 -24
- package/dist/cjs/plugins/analyze/templates.js +101 -0
- package/dist/cjs/{analyze → plugins/analyze}/utils.js +12 -55
- package/dist/cjs/plugins/deploy/dependencies/index.js +16 -25
- package/dist/cjs/plugins/deploy/dependencies/utils.js +1 -2
- package/dist/cjs/plugins/deploy/platforms/netlify.js +5 -9
- package/dist/cjs/plugins/deploy/platforms/node.js +5 -13
- package/dist/cjs/plugins/deploy/platforms/vercel.js +5 -9
- package/dist/cjs/{initialize → plugins/initialize}/index.js +1 -1
- package/dist/cjs/plugins/serverBuild.js +10 -4
- package/dist/cjs/utils/createServer.js +1 -1
- package/dist/cjs/utils/{getServerInternalPlugins.js → loadPlugins.js} +18 -11
- package/dist/esm/builder/shared/builderPlugins/adapterHtml.js +4 -1
- package/dist/esm/builder/shared/builderPlugins/adapterSSR.js +2 -2
- package/dist/esm/commands/build.js +16 -9
- package/dist/esm/commands/deploy.js +2 -2
- package/dist/esm/commands/dev.js +13 -9
- package/dist/esm/commands/index.js +411 -3
- package/dist/esm/commands/serve.js +12 -8
- package/dist/esm/hooks.js +5 -0
- package/dist/esm/index.js +12 -394
- package/dist/esm/plugins/analyze/constants.js +24 -0
- package/dist/esm/{analyze → plugins/analyze}/generateCode.js +27 -169
- package/dist/esm/plugins/analyze/getBundleEntry.js +101 -0
- package/dist/esm/plugins/analyze/getFileSystemEntry.js +195 -0
- package/dist/esm/{analyze → plugins/analyze}/getServerRoutes.js +1 -1
- package/dist/esm/{analyze → plugins/analyze}/index.js +42 -70
- package/dist/esm/plugins/analyze/templates.js +22 -0
- package/dist/esm/{analyze → plugins/analyze}/utils.js +13 -135
- package/dist/esm/plugins/deploy/dependencies/index.js +69 -94
- package/dist/esm/plugins/deploy/dependencies/utils.js +3 -4
- package/dist/esm/plugins/deploy/platforms/netlify.js +8 -10
- package/dist/esm/plugins/deploy/platforms/node.js +8 -14
- package/dist/esm/plugins/deploy/platforms/vercel.js +8 -10
- package/dist/esm/{initialize → plugins/initialize}/index.js +1 -1
- package/dist/esm/plugins/serverBuild.js +13 -6
- package/dist/esm/utils/createServer.js +2 -2
- package/dist/esm/utils/loadPlugins.js +64 -0
- package/dist/esm-node/builder/shared/builderPlugins/adapterHtml.js +2 -1
- package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.js +2 -2
- package/dist/esm-node/commands/build.js +2 -0
- package/dist/esm-node/commands/deploy.js +2 -2
- package/dist/esm-node/commands/dev.js +11 -7
- package/dist/esm-node/commands/index.js +92 -3
- package/dist/esm-node/commands/serve.js +10 -6
- package/dist/esm-node/hooks.js +5 -0
- package/dist/esm-node/index.js +12 -79
- package/dist/esm-node/plugins/analyze/constants.js +24 -0
- package/dist/esm-node/{analyze → plugins/analyze}/generateCode.js +14 -87
- package/dist/esm-node/{analyze → plugins/analyze}/getBundleEntry.js +11 -20
- package/dist/esm-node/plugins/analyze/getFileSystemEntry.js +75 -0
- package/dist/esm-node/{analyze → plugins/analyze}/getServerRoutes.js +1 -1
- package/dist/esm-node/{analyze → plugins/analyze}/index.js +10 -25
- package/dist/esm-node/plugins/analyze/templates.js +75 -0
- package/dist/esm-node/{analyze → plugins/analyze}/utils.js +13 -52
- package/dist/esm-node/plugins/deploy/dependencies/index.js +18 -27
- package/dist/esm-node/plugins/deploy/dependencies/utils.js +1 -2
- package/dist/esm-node/plugins/deploy/platforms/netlify.js +6 -10
- package/dist/esm-node/plugins/deploy/platforms/node.js +6 -14
- package/dist/esm-node/plugins/deploy/platforms/vercel.js +6 -10
- package/dist/esm-node/{initialize → plugins/initialize}/index.js +1 -1
- package/dist/esm-node/plugins/serverBuild.js +11 -5
- package/dist/esm-node/utils/createServer.js +2 -2
- package/dist/esm-node/utils/loadPlugins.js +21 -0
- package/dist/types/builder/builder-webpack/createCopyPattern.d.ts +2 -2
- package/dist/types/commands/index.d.ts +10 -3
- package/dist/types/config/initialize/inits.d.ts +1 -1
- package/dist/types/exports/server.d.ts +4 -0
- package/dist/types/index.d.ts +2 -5
- package/dist/types/plugins/analyze/constants.d.ts +9 -0
- package/dist/types/{analyze → plugins/analyze}/generateCode.d.ts +1 -1
- package/dist/types/plugins/analyze/getBundleEntry.d.ts +4 -0
- package/dist/types/plugins/analyze/getFileSystemEntry.d.ts +5 -0
- package/dist/types/{analyze → plugins/analyze}/getHtmlTemplate.d.ts +1 -1
- package/dist/types/{analyze → plugins/analyze}/getServerRoutes.d.ts +1 -1
- package/dist/types/{analyze → plugins/analyze}/index.d.ts +1 -1
- package/dist/types/plugins/analyze/templates.d.ts +19 -0
- package/dist/types/{analyze → plugins/analyze}/utils.d.ts +4 -6
- package/dist/types/plugins/deploy/dependencies/index.d.ts +1 -9
- package/dist/types/plugins/deploy/dependencies/utils.d.ts +1 -7
- package/dist/types/{initialize → plugins/initialize}/index.d.ts +1 -1
- package/dist/types/types/hooks.d.ts +11 -1
- package/dist/types/utils/loadPlugins.d.ts +5 -0
- package/package.json +22 -30
- package/dist/cjs/analyze/constants.js +0 -122
- package/dist/cjs/analyze/getClientRoutes/getRoutes.js +0 -197
- package/dist/cjs/analyze/getClientRoutes/getRoutesLegacy.js +0 -195
- package/dist/cjs/analyze/getClientRoutes/index.js +0 -31
- package/dist/cjs/analyze/getClientRoutes/utils.js +0 -59
- package/dist/cjs/analyze/makeLegalIdentifier.js +0 -37
- package/dist/cjs/analyze/nestedRoutes.js +0 -295
- package/dist/cjs/analyze/templates.js +0 -444
- package/dist/cjs/plugins/deploy/exports.js +0 -28
- package/dist/esm/analyze/constants.js +0 -76
- package/dist/esm/analyze/getBundleEntry.js +0 -75
- package/dist/esm/analyze/getClientRoutes/getRoutes.js +0 -185
- package/dist/esm/analyze/getClientRoutes/getRoutesLegacy.js +0 -183
- package/dist/esm/analyze/getClientRoutes/index.js +0 -6
- package/dist/esm/analyze/getClientRoutes/utils.js +0 -28
- package/dist/esm/analyze/getFileSystemEntry.js +0 -113
- package/dist/esm/analyze/makeLegalIdentifier.js +0 -15
- package/dist/esm/analyze/nestedRoutes.js +0 -398
- package/dist/esm/analyze/templates.js +0 -435
- package/dist/esm/plugins/deploy/exports.js +0 -4
- package/dist/esm/utils/getServerInternalPlugins.js +0 -40
- package/dist/esm-node/analyze/constants.js +0 -76
- package/dist/esm-node/analyze/getClientRoutes/getRoutes.js +0 -163
- package/dist/esm-node/analyze/getClientRoutes/getRoutesLegacy.js +0 -161
- package/dist/esm-node/analyze/getClientRoutes/index.js +0 -6
- package/dist/esm-node/analyze/getClientRoutes/utils.js +0 -22
- package/dist/esm-node/analyze/getFileSystemEntry.js +0 -89
- package/dist/esm-node/analyze/makeLegalIdentifier.js +0 -13
- package/dist/esm-node/analyze/nestedRoutes.js +0 -259
- package/dist/esm-node/analyze/templates.js +0 -405
- package/dist/esm-node/plugins/deploy/exports.js +0 -4
- package/dist/esm-node/utils/getServerInternalPlugins.js +0 -15
- package/dist/js/modern/analyze/constants.js +0 -15
- package/dist/js/modern/analyze/generateCode.js +0 -179
- package/dist/js/modern/analyze/getBundleEntry.js +0 -75
- package/dist/js/modern/analyze/getClientRoutes.js +0 -219
- package/dist/js/modern/analyze/getFileSystemEntry.js +0 -74
- package/dist/js/modern/analyze/getHtmlTemplate.js +0 -82
- package/dist/js/modern/analyze/getServerRoutes.js +0 -192
- package/dist/js/modern/analyze/index.js +0 -148
- package/dist/js/modern/analyze/isDefaultExportFunction.js +0 -32
- package/dist/js/modern/analyze/makeLegalIdentifier.js +0 -16
- package/dist/js/modern/analyze/templates.js +0 -88
- package/dist/js/modern/analyze/utils.js +0 -92
- package/dist/js/modern/commands/build.js +0 -154
- package/dist/js/modern/commands/deploy.js +0 -5
- package/dist/js/modern/commands/dev.js +0 -95
- package/dist/js/modern/commands/index.js +0 -3
- package/dist/js/modern/commands/inspect.js +0 -69
- package/dist/js/modern/commands/start.js +0 -31
- package/dist/js/modern/exports/server.js +0 -1
- package/dist/js/modern/hooks.js +0 -21
- package/dist/js/modern/index.js +0 -109
- package/dist/js/modern/locale/en.js +0 -35
- package/dist/js/modern/locale/index.js +0 -9
- package/dist/js/modern/locale/zh.js +0 -35
- package/dist/js/modern/utils/config.js +0 -78
- package/dist/js/modern/utils/createCompiler.js +0 -61
- package/dist/js/modern/utils/createServer.js +0 -18
- package/dist/js/modern/utils/getSpecifiedEntries.js +0 -36
- package/dist/js/modern/utils/language.js +0 -5
- package/dist/js/modern/utils/printInstructions.js +0 -11
- package/dist/js/modern/utils/routes.js +0 -15
- package/dist/js/modern/utils/types.js +0 -0
- package/dist/js/node/analyze/constants.js +0 -36
- package/dist/js/node/analyze/generateCode.js +0 -208
- package/dist/js/node/analyze/getBundleEntry.js +0 -89
- package/dist/js/node/analyze/getClientRoutes.js +0 -241
- package/dist/js/node/analyze/getFileSystemEntry.js +0 -90
- package/dist/js/node/analyze/getHtmlTemplate.js +0 -106
- package/dist/js/node/analyze/getServerRoutes.js +0 -208
- package/dist/js/node/analyze/index.js +0 -178
- package/dist/js/node/analyze/isDefaultExportFunction.js +0 -50
- package/dist/js/node/analyze/makeLegalIdentifier.js +0 -24
- package/dist/js/node/analyze/templates.js +0 -106
- package/dist/js/node/analyze/utils.js +0 -113
- package/dist/js/node/commands/build.js +0 -174
- package/dist/js/node/commands/deploy.js +0 -14
- package/dist/js/node/commands/dev.js +0 -120
- package/dist/js/node/commands/index.js +0 -44
- package/dist/js/node/commands/inspect.js +0 -98
- package/dist/js/node/commands/start.js +0 -47
- package/dist/js/node/exports/server.js +0 -13
- package/dist/js/node/hooks.js +0 -39
- package/dist/js/node/index.js +0 -141
- package/dist/js/node/locale/en.js +0 -42
- package/dist/js/node/locale/index.js +0 -20
- package/dist/js/node/locale/zh.js +0 -42
- package/dist/js/node/utils/config.js +0 -103
- package/dist/js/node/utils/createCompiler.js +0 -81
- package/dist/js/node/utils/createServer.js +0 -35
- package/dist/js/node/utils/getSpecifiedEntries.js +0 -46
- package/dist/js/node/utils/language.js +0 -13
- package/dist/js/node/utils/printInstructions.js +0 -22
- package/dist/js/node/utils/routes.js +0 -25
- package/dist/js/node/utils/types.js +0 -0
- package/dist/types/analyze/constants.d.ts +0 -42
- package/dist/types/analyze/getBundleEntry.d.ts +0 -3
- package/dist/types/analyze/getClientRoutes/getRoutes.d.ts +0 -8
- package/dist/types/analyze/getClientRoutes/getRoutesLegacy.d.ts +0 -9
- package/dist/types/analyze/getClientRoutes/index.d.ts +0 -2
- package/dist/types/analyze/getClientRoutes/utils.d.ts +0 -5
- package/dist/types/analyze/getFileSystemEntry.d.ts +0 -4
- package/dist/types/analyze/makeLegalIdentifier.d.ts +0 -1
- package/dist/types/analyze/nestedRoutes.d.ts +0 -7
- package/dist/types/analyze/templates.d.ts +0 -30
- package/dist/types/plugins/deploy/exports.d.ts +0 -1
- package/dist/types/utils/getServerInternalPlugins.d.ts +0 -2
- /package/dist/cjs/{analyze → plugins/analyze}/getHtmlTemplate.js +0 -0
- /package/dist/cjs/{analyze → plugins/analyze}/isDefaultExportFunction.js +0 -0
- /package/dist/esm/{analyze → plugins/analyze}/getHtmlTemplate.js +0 -0
- /package/dist/esm/{analyze → plugins/analyze}/isDefaultExportFunction.js +0 -0
- /package/dist/esm-node/{analyze → plugins/analyze}/getHtmlTemplate.js +0 -0
- /package/dist/esm-node/{analyze → plugins/analyze}/isDefaultExportFunction.js +0 -0
- /package/dist/types/{analyze → plugins/analyze}/isDefaultExportFunction.d.ts +0 -0
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.safeReplacer = exports.emitResolvedConfig = exports.defineServerConfig = exports.buildServerConfig = void 0;
|
|
7
|
-
|
|
8
|
-
var path = _interopRequireWildcard(require("path"));
|
|
9
|
-
|
|
10
|
-
var _nodeBundleRequire = require("@modern-js/node-bundle-require");
|
|
11
|
-
|
|
12
|
-
var _utils = require("@modern-js/utils");
|
|
13
|
-
|
|
14
|
-
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
|
-
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
|
-
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
|
-
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
|
-
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
|
-
const defineServerConfig = config => config;
|
|
25
|
-
|
|
26
|
-
exports.defineServerConfig = defineServerConfig;
|
|
27
|
-
|
|
28
|
-
const buildServerConfig = async ({
|
|
29
|
-
appDirectory,
|
|
30
|
-
distDirectory,
|
|
31
|
-
configFile,
|
|
32
|
-
options
|
|
33
|
-
}) => {
|
|
34
|
-
const configFilePath = await (0, _utils.getServerConfig)(appDirectory, configFile);
|
|
35
|
-
|
|
36
|
-
const getOutputFile = async filepath => path.resolve(distDirectory, `${filepath.replace(new RegExp(_utils.CONFIG_FILE_EXTENSIONS.join('|')), '')}.js`);
|
|
37
|
-
|
|
38
|
-
if (configFilePath) {
|
|
39
|
-
const configHelperFilePath = path.normalize(path.join(distDirectory, './config-helper.js'));
|
|
40
|
-
const helperCode = `
|
|
41
|
-
export const defineConfig = (config) => config;
|
|
42
|
-
`;
|
|
43
|
-
await _utils.fs.ensureDir(distDirectory);
|
|
44
|
-
await _utils.fs.writeFile(configHelperFilePath, helperCode);
|
|
45
|
-
await (0, _nodeBundleRequire.bundle)(configFilePath, _objectSpread(_objectSpread({}, options), {}, {
|
|
46
|
-
getOutputFile,
|
|
47
|
-
esbuildPlugins: [{
|
|
48
|
-
name: 'native-build-config',
|
|
49
|
-
|
|
50
|
-
setup(ctx) {
|
|
51
|
-
ctx.onResolve({
|
|
52
|
-
filter: /app-tools\/server/
|
|
53
|
-
}, () => {
|
|
54
|
-
return {
|
|
55
|
-
path: configHelperFilePath
|
|
56
|
-
};
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
}]
|
|
61
|
-
}));
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
/**
|
|
65
|
-
*
|
|
66
|
-
* 处理循环引用的 replacer
|
|
67
|
-
*/
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
exports.buildServerConfig = buildServerConfig;
|
|
71
|
-
|
|
72
|
-
const safeReplacer = () => {
|
|
73
|
-
const cache = [];
|
|
74
|
-
const keyCache = [];
|
|
75
|
-
return function (key, value) {
|
|
76
|
-
if (typeof value === 'object' && value !== null) {
|
|
77
|
-
const index = cache.indexOf(value);
|
|
78
|
-
|
|
79
|
-
if (index !== -1) {
|
|
80
|
-
return `[Circular ${keyCache[index]}]`;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
cache.push(value);
|
|
84
|
-
keyCache.push(key || 'root');
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
return value;
|
|
88
|
-
};
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
exports.safeReplacer = safeReplacer;
|
|
92
|
-
|
|
93
|
-
const emitResolvedConfig = async (appDirectory, resolvedConfig) => {
|
|
94
|
-
var _resolvedConfig$outpu;
|
|
95
|
-
|
|
96
|
-
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
|
-
await _utils.fs.writeJSON(outputPath, resolvedConfig, {
|
|
98
|
-
spaces: 2,
|
|
99
|
-
replacer: safeReplacer()
|
|
100
|
-
});
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
exports.emitResolvedConfig = emitResolvedConfig;
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createCompiler = void 0;
|
|
7
|
-
|
|
8
|
-
var _webpack = require("@modern-js/webpack");
|
|
9
|
-
|
|
10
|
-
var _utils = require("@modern-js/utils");
|
|
11
|
-
|
|
12
|
-
var _printInstructions = require("./printInstructions");
|
|
13
|
-
|
|
14
|
-
const createCompiler = async ({
|
|
15
|
-
api,
|
|
16
|
-
webpackConfigs,
|
|
17
|
-
// TODO: params
|
|
18
|
-
userConfig,
|
|
19
|
-
appContext
|
|
20
|
-
}) => {
|
|
21
|
-
try {
|
|
22
|
-
const hookRunners = api.useHookRunners();
|
|
23
|
-
await hookRunners.beforeCreateCompiler({
|
|
24
|
-
webpackConfigs
|
|
25
|
-
});
|
|
26
|
-
const compiler = (0, _webpack.webpack)(webpackConfigs);
|
|
27
|
-
await hookRunners.afterCreateCompiler({
|
|
28
|
-
compiler
|
|
29
|
-
});
|
|
30
|
-
let isFirstCompile = true;
|
|
31
|
-
compiler.hooks.invalid.tap('invalid', () => {
|
|
32
|
-
(0, _utils.clearConsole)();
|
|
33
|
-
|
|
34
|
-
_utils.logger.log('Compiling...');
|
|
35
|
-
});
|
|
36
|
-
compiler.hooks.done.tap('done', async stats => {
|
|
37
|
-
const statsData = stats.toJson({
|
|
38
|
-
preset: 'errors-warnings'
|
|
39
|
-
});
|
|
40
|
-
const {
|
|
41
|
-
errors,
|
|
42
|
-
warnings
|
|
43
|
-
} = (0, _utils.formatWebpackMessages)(statsData);
|
|
44
|
-
|
|
45
|
-
if (errors.length) {
|
|
46
|
-
_utils.logger.log(_utils.chalk.red(`Failed to compile.\n`));
|
|
47
|
-
|
|
48
|
-
_utils.logger.log(errors.join('\n\n'));
|
|
49
|
-
|
|
50
|
-
_utils.logger.log();
|
|
51
|
-
} else if (process.stdout.isTTY || isFirstCompile) {
|
|
52
|
-
await hookRunners.afterDev();
|
|
53
|
-
|
|
54
|
-
if (warnings.length) {
|
|
55
|
-
_utils.logger.log(_utils.chalk.yellow(`Compiled with warnings.\n`));
|
|
56
|
-
|
|
57
|
-
_utils.logger.log(warnings.join('\n\n'));
|
|
58
|
-
|
|
59
|
-
_utils.logger.log();
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
await (0, _printInstructions.printInstructions)(hookRunners, appContext, userConfig);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
isFirstCompile = false;
|
|
66
|
-
});
|
|
67
|
-
return compiler;
|
|
68
|
-
} catch (err) {
|
|
69
|
-
_utils.logger.log(_utils.chalk.red(`Failed to compile.`));
|
|
70
|
-
|
|
71
|
-
_utils.logger.log();
|
|
72
|
-
|
|
73
|
-
_utils.logger.log(err); // FIXME: 这里最好抛出异常,执行 process.exit 的地方尽可能少或者控制在几个统一的地方比较合适
|
|
74
|
-
// eslint-disable-next-line no-process-exit
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
process.exit(1);
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
exports.createCompiler = createCompiler;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getServer = exports.createServer = exports.closeServer = void 0;
|
|
7
|
-
|
|
8
|
-
var _server = require("@modern-js/server");
|
|
9
|
-
|
|
10
|
-
let server = null;
|
|
11
|
-
|
|
12
|
-
const getServer = () => server;
|
|
13
|
-
|
|
14
|
-
exports.getServer = getServer;
|
|
15
|
-
|
|
16
|
-
const closeServer = async () => {
|
|
17
|
-
if (server) {
|
|
18
|
-
await server.close();
|
|
19
|
-
server = null;
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
exports.closeServer = closeServer;
|
|
24
|
-
|
|
25
|
-
const createServer = async options => {
|
|
26
|
-
if (server) {
|
|
27
|
-
await server.close();
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
server = new _server.Server(options);
|
|
31
|
-
const app = await server.init();
|
|
32
|
-
return app;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
exports.createServer = createServer;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getSpecifiedEntries = void 0;
|
|
7
|
-
|
|
8
|
-
var _utils = require("@modern-js/utils");
|
|
9
|
-
|
|
10
|
-
const getSpecifiedEntries = async (entry, entrypoints) => {
|
|
11
|
-
const entryNames = entrypoints.map(e => e.entryName);
|
|
12
|
-
|
|
13
|
-
if (!entry) {
|
|
14
|
-
return entryNames;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
if (typeof entry === 'boolean') {
|
|
18
|
-
const {
|
|
19
|
-
selected
|
|
20
|
-
} = await _utils.inquirer.prompt([{
|
|
21
|
-
type: 'checkbox',
|
|
22
|
-
name: 'selected',
|
|
23
|
-
choices: entryNames,
|
|
24
|
-
message: '请选择需要构建的入口',
|
|
25
|
-
|
|
26
|
-
validate(answer) {
|
|
27
|
-
if (answer.length < 1) {
|
|
28
|
-
return 'You must choose at least one topping.';
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return true;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
}]);
|
|
35
|
-
return selected;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
entry.forEach(name => {
|
|
39
|
-
if (!entryNames.includes(name)) {
|
|
40
|
-
throw new Error(`can not found entry ${name}, compiler entry should in ${entryNames.join(', ')}`);
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
return entry;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
exports.getSpecifiedEntries = getSpecifiedEntries;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getLocaleLanguage = getLocaleLanguage;
|
|
7
|
-
|
|
8
|
-
var _languageDetector = require("@modern-js/plugin-i18n/language-detector");
|
|
9
|
-
|
|
10
|
-
function getLocaleLanguage() {
|
|
11
|
-
const detector = new _languageDetector.I18CLILanguageDetector();
|
|
12
|
-
return detector.detect();
|
|
13
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.printInstructions = void 0;
|
|
7
|
-
|
|
8
|
-
var _utils = require("@modern-js/utils");
|
|
9
|
-
|
|
10
|
-
const printInstructions = async (hookRunners, appContext, config) => {
|
|
11
|
-
const message = (0, _utils.prettyInstructions)(appContext, config); // call beforePrintInstructions hook.
|
|
12
|
-
|
|
13
|
-
const {
|
|
14
|
-
instructions
|
|
15
|
-
} = await hookRunners.beforePrintInstructions({
|
|
16
|
-
instructions: message
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
_utils.logger.log(instructions);
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
exports.printInstructions = printInstructions;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.generateRoutes = void 0;
|
|
7
|
-
|
|
8
|
-
var _path = _interopRequireDefault(require("path"));
|
|
9
|
-
|
|
10
|
-
var _utils = require("@modern-js/utils");
|
|
11
|
-
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
|
-
const generateRoutes = async appContext => {
|
|
15
|
-
const {
|
|
16
|
-
serverRoutes,
|
|
17
|
-
distDirectory
|
|
18
|
-
} = appContext;
|
|
19
|
-
const output = JSON.stringify({
|
|
20
|
-
routes: serverRoutes
|
|
21
|
-
}, null, 2);
|
|
22
|
-
await _utils.fs.outputFile(_path.default.join(distDirectory, _utils.ROUTE_SPEC_FILE), output);
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
exports.generateRoutes = generateRoutes;
|
|
File without changes
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
export declare const JS_EXTENSIONS: string[];
|
|
2
|
-
export declare const INDEX_FILE_NAME = "index";
|
|
3
|
-
export declare const APP_FILE_NAME = "App";
|
|
4
|
-
export declare const PAGES_DIR_NAME = "pages";
|
|
5
|
-
export declare const NESTED_ROUTES_DIR = "routes";
|
|
6
|
-
export declare const FILE_SYSTEM_ROUTES_FILE_NAME = "routes.js";
|
|
7
|
-
export declare const LOADER_EXPORT_NAME = "loader";
|
|
8
|
-
export declare const ACTION_EXPORT_NAME = "action";
|
|
9
|
-
export declare const TEMP_LOADERS_DIR = "__loaders__";
|
|
10
|
-
export declare const ENTRY_POINT_FILE_NAME = "index.jsx";
|
|
11
|
-
export declare const ENTRY_BOOTSTRAP_FILE_NAME = "bootstrap.jsx";
|
|
12
|
-
export declare const FILE_SYSTEM_ROUTES_DYNAMIC_REGEXP: RegExp;
|
|
13
|
-
export declare const FILE_SYSTEM_ROUTES_LAYOUT = "_layout";
|
|
14
|
-
export declare const FILE_SYSTEM_ROUTES_GLOBAL_LAYOUT = "_app";
|
|
15
|
-
export declare const FILE_SYSTEM_ROUTES_INDEX = "index";
|
|
16
|
-
export declare const FILE_SYSTEM_ROUTES_IGNORED_REGEX: RegExp;
|
|
17
|
-
export declare const HTML_PARTIALS_FOLDER = "html";
|
|
18
|
-
export declare const HTML_PARTIALS_EXTENSIONS: string[];
|
|
19
|
-
export declare const FILE_SYSTEM_ROUTES_COMPONENTS_DIR = "internal_components";
|
|
20
|
-
export declare const NESTED_ROUTE: {
|
|
21
|
-
LAYOUT_FILE: string;
|
|
22
|
-
LAYOUT_CONFIG_FILE: string;
|
|
23
|
-
LAYOUT_LOADER_FILE: string;
|
|
24
|
-
LAYOUT_DATA_FILE: string;
|
|
25
|
-
LAYOUT_CLIENT_LOADER: string;
|
|
26
|
-
PAGE_FILE: string;
|
|
27
|
-
PAGE_CONFIG_FILE: string;
|
|
28
|
-
PAGE_LOADER_FILE: string;
|
|
29
|
-
PAGE_DATA_FILE: string;
|
|
30
|
-
PAGE_CLIENT_LOADER: string;
|
|
31
|
-
SPLATE_FILE: string;
|
|
32
|
-
SPLATE_CONFIG_FILE: string;
|
|
33
|
-
SPLATE_LOADER_FILE: string;
|
|
34
|
-
SPLATE_DATA_FILE: string;
|
|
35
|
-
SPLATE_CLIENT_DATA: string;
|
|
36
|
-
LOADING_FILE: string;
|
|
37
|
-
ERROR_FILE: string;
|
|
38
|
-
LOADER_FILE: string;
|
|
39
|
-
};
|
|
40
|
-
export declare const APP_CONFIG_NAME = "config";
|
|
41
|
-
export declare const APP_INIT_EXPORTED = "init";
|
|
42
|
-
export declare const APP_INIT_IMPORTED = "appInit";
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { Entrypoint, NestedRouteForCli, PageRoute } from '@modern-js/types';
|
|
2
|
-
export declare const getClientRoutes: ({ entrypoint, srcDirectory, srcAlias, internalDirectory, internalDirAlias, }: {
|
|
3
|
-
entrypoint: Entrypoint;
|
|
4
|
-
srcDirectory: string;
|
|
5
|
-
srcAlias: string;
|
|
6
|
-
internalDirectory: string;
|
|
7
|
-
internalDirAlias: string;
|
|
8
|
-
}) => (NestedRouteForCli | PageRoute)[];
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { Entrypoint, RouteLegacy } from '@modern-js/types';
|
|
2
|
-
export type { RouteLegacy as Route };
|
|
3
|
-
export declare const getClientRoutes: ({ entrypoint, srcDirectory, srcAlias, internalDirectory, internalDirAlias, }: {
|
|
4
|
-
entrypoint: Entrypoint;
|
|
5
|
-
srcDirectory: string;
|
|
6
|
-
srcAlias: string;
|
|
7
|
-
internalDirectory: string;
|
|
8
|
-
internalDirAlias: string;
|
|
9
|
-
}) => RouteLegacy[];
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
declare const debug: import("@modern-js/utils/compiled/debug").Debugger;
|
|
2
|
-
export { debug };
|
|
3
|
-
export declare const findLayout: (dir: string) => string | false;
|
|
4
|
-
export declare const getRouteWeight: (route: string) => number;
|
|
5
|
-
export declare const shouldSkip: (file: string) => boolean;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { Entrypoint } from '@modern-js/types';
|
|
2
|
-
import type { AppNormalizedConfig, IAppContext } from '../types';
|
|
3
|
-
export type { Entrypoint };
|
|
4
|
-
export declare const getFileSystemEntry: (appContext: IAppContext, config: AppNormalizedConfig<'shared'>) => Entrypoint[];
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function makeLegalIdentifier(str: string): string;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { NestedRouteForCli } from '@modern-js/types';
|
|
2
|
-
export declare const getRouteId: (componentPath: string, routesDir: string, entryName: string, isMainEntry: boolean) => string;
|
|
3
|
-
export declare const optimizeRoute: (routeTree: NestedRouteForCli) => NestedRouteForCli[];
|
|
4
|
-
export declare const walk: (dirname: string, rootDir: string, alias: {
|
|
5
|
-
name: string;
|
|
6
|
-
basename: string;
|
|
7
|
-
}, entryName: string, isMainEntry: boolean, oldVersion: boolean) => Promise<NestedRouteForCli | NestedRouteForCli[] | null>;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { Entrypoint, NestedRouteForCli, PageRoute, RouteLegacy, SSRMode } from '@modern-js/types';
|
|
2
|
-
import type { AppNormalizedConfig, IAppContext, RuntimePlugin } from '../types';
|
|
3
|
-
export declare const index: ({ mountId, imports, renderFunction, exportStatement, }: {
|
|
4
|
-
mountId: string;
|
|
5
|
-
imports: string;
|
|
6
|
-
exportStatement: string;
|
|
7
|
-
renderFunction: string;
|
|
8
|
-
}) => string;
|
|
9
|
-
export declare const renderFunction: ({ plugins, customBootstrap, fileSystemRoutes, }: {
|
|
10
|
-
plugins: RuntimePlugin[];
|
|
11
|
-
customBootstrap?: string | false | undefined;
|
|
12
|
-
fileSystemRoutes: Entrypoint['fileSystemRoutes'];
|
|
13
|
-
}) => string;
|
|
14
|
-
export declare const html: (partials: {
|
|
15
|
-
top: string[];
|
|
16
|
-
head: string[];
|
|
17
|
-
body: string[];
|
|
18
|
-
}) => string;
|
|
19
|
-
export declare const routesForServer: ({ routes, }: {
|
|
20
|
-
routes: (NestedRouteForCli | PageRoute)[];
|
|
21
|
-
}) => string;
|
|
22
|
-
export declare const fileSystemRoutes: ({ routes, ssrMode, nestedRoutesEntry, entryName, internalDirectory, splitRouteChunks, }: {
|
|
23
|
-
routes: RouteLegacy[] | (NestedRouteForCli | PageRoute)[];
|
|
24
|
-
ssrMode?: SSRMode | undefined;
|
|
25
|
-
nestedRoutesEntry?: string | undefined;
|
|
26
|
-
entryName: string;
|
|
27
|
-
internalDirectory: string;
|
|
28
|
-
splitRouteChunks?: boolean | undefined;
|
|
29
|
-
}) => Promise<string>;
|
|
30
|
-
export declare function ssrLoaderCombinedModule(entrypoints: Entrypoint[], entrypoint: Entrypoint, config: AppNormalizedConfig<'shared'>, appContext: IAppContext): string | null;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { handleDependencies } from './dependencies';
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|