@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
|
@@ -4,27 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.build = void 0;
|
|
7
|
-
|
|
8
|
-
var _webpack = require("@modern-js/webpack");
|
|
9
|
-
|
|
10
7
|
var _core = require("@modern-js/core");
|
|
11
|
-
|
|
12
8
|
var _utils = require("@modern-js/utils");
|
|
13
|
-
|
|
14
9
|
var _routes = require("../utils/routes");
|
|
15
|
-
|
|
16
10
|
var _config = require("../utils/config");
|
|
17
|
-
|
|
18
11
|
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
12
|
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
13
|
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
|
-
// These sizes are pretty large. We'll warn for bundles exceeding them.
|
|
25
|
-
const WARN_AFTER_BUNDLE_GZIP_SIZE = 512 * 1024;
|
|
26
|
-
const WARN_AFTER_CHUNK_GZIP_SIZE = 1024 * 1024;
|
|
27
|
-
|
|
28
14
|
const build = async (api, options) => {
|
|
29
15
|
let resolvedConfig = api.useResolvedConfigContext();
|
|
30
16
|
const appContext = api.useAppContext();
|
|
@@ -32,16 +18,15 @@ const build = async (api, options) => {
|
|
|
32
18
|
const {
|
|
33
19
|
apiOnly
|
|
34
20
|
} = appContext;
|
|
35
|
-
|
|
36
21
|
if (apiOnly) {
|
|
37
22
|
const {
|
|
38
23
|
appDirectory,
|
|
39
24
|
distDirectory,
|
|
40
25
|
serverConfigFile
|
|
41
26
|
} = appContext;
|
|
42
|
-
await (0, _utils.emptyDir)(distDirectory);
|
|
43
27
|
await hookRunners.beforeBuild({
|
|
44
|
-
|
|
28
|
+
// "null" bundlerConfigs
|
|
29
|
+
bundlerConfigs: undefined
|
|
45
30
|
});
|
|
46
31
|
await (0, _config.buildServerConfig)({
|
|
47
32
|
appDirectory,
|
|
@@ -49,126 +34,34 @@ const build = async (api, options) => {
|
|
|
49
34
|
configFile: serverConfigFile
|
|
50
35
|
});
|
|
51
36
|
await (0, _routes.generateRoutes)(appContext);
|
|
52
|
-
await hookRunners.afterBuild(
|
|
37
|
+
await hookRunners.afterBuild({
|
|
38
|
+
// "null" stats
|
|
39
|
+
stats: undefined
|
|
40
|
+
});
|
|
53
41
|
return;
|
|
54
42
|
}
|
|
55
|
-
|
|
56
|
-
const webpackBuild = async (webpackConfig, type) => {
|
|
57
|
-
const compiler = (0, _webpack.webpack)(webpackConfig);
|
|
58
|
-
return new Promise((resolve, reject) => {
|
|
59
|
-
let label = process.env.NODE_ENV || '';
|
|
60
|
-
|
|
61
|
-
if (type && type !== 'legacy') {
|
|
62
|
-
label += ` ${type}`;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
_utils.logger.info(`Creating a ${label} build...`);
|
|
66
|
-
|
|
67
|
-
compiler.run((err, stats) => {
|
|
68
|
-
let messages;
|
|
69
|
-
|
|
70
|
-
if (!err) {
|
|
71
|
-
messages = (0, _utils.formatWebpackMessages)(stats.toJson({
|
|
72
|
-
all: false,
|
|
73
|
-
warnings: true,
|
|
74
|
-
errors: true
|
|
75
|
-
}));
|
|
76
|
-
|
|
77
|
-
if (messages.errors.length === 0) {
|
|
78
|
-
_utils.logger.info(`File sizes after ${label} build:\n`);
|
|
79
|
-
|
|
80
|
-
(0, _utils.printFileSizesAfterBuild)(stats, previousFileSizes, distDirectory, WARN_AFTER_BUNDLE_GZIP_SIZE, WARN_AFTER_CHUNK_GZIP_SIZE);
|
|
81
|
-
|
|
82
|
-
_utils.logger.log();
|
|
83
|
-
}
|
|
84
|
-
} // When using run or watch, call close and wait for it to finish before calling run or watch again.
|
|
85
|
-
// Concurrent compilations will corrupt the output files.
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
compiler.close(closeErr => {
|
|
89
|
-
if (closeErr) {
|
|
90
|
-
_utils.logger.error(closeErr);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (err) {
|
|
94
|
-
reject(err);
|
|
95
|
-
} else {
|
|
96
|
-
if (messages.errors.length) {
|
|
97
|
-
reject(new Error(messages.errors.join('\n\n')));
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
resolve({
|
|
102
|
-
warnings: messages.warnings
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
};
|
|
109
|
-
|
|
110
43
|
resolvedConfig = _objectSpread(_objectSpread({}, resolvedConfig), {}, {
|
|
111
44
|
cliOptions: options
|
|
112
45
|
});
|
|
113
|
-
|
|
114
46
|
_core.ResolvedConfigContext.set(resolvedConfig);
|
|
115
|
-
|
|
116
47
|
const {
|
|
117
48
|
distDirectory,
|
|
118
49
|
appDirectory,
|
|
119
50
|
serverConfigFile
|
|
120
51
|
} = appContext;
|
|
121
|
-
const previousFileSizes = await (0, _utils.measureFileSizesBeforeBuild)(distDirectory);
|
|
122
|
-
await (0, _utils.emptyDir)(distDirectory);
|
|
123
52
|
await (0, _config.buildServerConfig)({
|
|
124
53
|
appDirectory,
|
|
125
54
|
distDirectory,
|
|
126
55
|
configFile: serverConfigFile
|
|
127
56
|
});
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
})
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
type: 'modern',
|
|
137
|
-
config: (0, _webpack.getWebpackConfig)(_webpack.WebpackConfigTarget.MODERN, appContext, resolvedConfig)
|
|
138
|
-
});
|
|
57
|
+
try {
|
|
58
|
+
var _appContext$builder;
|
|
59
|
+
_utils.logger.info('Create a production build...\n');
|
|
60
|
+
await ((_appContext$builder = appContext.builder) === null || _appContext$builder === void 0 ? void 0 : _appContext$builder.build());
|
|
61
|
+
} catch (error) {
|
|
62
|
+
(0, _utils.printBuildError)(error);
|
|
63
|
+
// eslint-disable-next-line no-process-exit
|
|
64
|
+
process.exit(1);
|
|
139
65
|
}
|
|
140
|
-
|
|
141
|
-
if ((0, _utils.isUseSSRBundle)(resolvedConfig)) {
|
|
142
|
-
buildConfigs.push({
|
|
143
|
-
type: 'ssr',
|
|
144
|
-
config: (0, _webpack.getWebpackConfig)(_webpack.WebpackConfigTarget.NODE, appContext, resolvedConfig)
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
await hookRunners.beforeBuild({
|
|
149
|
-
webpackConfigs: buildConfigs.map(({
|
|
150
|
-
config
|
|
151
|
-
}) => config)
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
for (const buildConfig of buildConfigs) {
|
|
155
|
-
const {
|
|
156
|
-
type: buildType,
|
|
157
|
-
config
|
|
158
|
-
} = buildConfig;
|
|
159
|
-
|
|
160
|
-
try {
|
|
161
|
-
await webpackBuild(config, buildType);
|
|
162
|
-
} catch (error) {
|
|
163
|
-
(0, _utils.printBuildError)(error); // eslint-disable-next-line no-process-exit
|
|
164
|
-
|
|
165
|
-
process.exit(1);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
await (0, _routes.generateRoutes)(appContext);
|
|
170
|
-
await hookRunners.afterBuild();
|
|
171
|
-
await (0, _config.emitResolvedConfig)(appDirectory, resolvedConfig);
|
|
172
66
|
};
|
|
173
|
-
|
|
174
67
|
exports.build = build;
|
|
@@ -4,11 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.deploy = void 0;
|
|
7
|
-
|
|
8
7
|
const deploy = async (api, options) => {
|
|
9
8
|
const hookRunners = api.useHookRunners();
|
|
10
9
|
await hookRunners.beforeDeploy(options);
|
|
11
10
|
await hookRunners.afterDeploy(options);
|
|
12
11
|
};
|
|
13
|
-
|
|
14
12
|
exports.deploy = deploy;
|
|
@@ -4,33 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.dev = void 0;
|
|
7
|
-
|
|
8
7
|
var _utils = require("@modern-js/utils");
|
|
9
|
-
|
|
10
8
|
var _core = require("@modern-js/core");
|
|
11
|
-
|
|
12
|
-
var _createCompiler = require("../utils/createCompiler");
|
|
13
|
-
|
|
9
|
+
var _printInstructions = require("../utils/printInstructions");
|
|
14
10
|
var _createServer = require("../utils/createServer");
|
|
15
|
-
|
|
16
11
|
var _routes = require("../utils/routes");
|
|
17
|
-
|
|
18
|
-
var _printInstructions = require("../utils/printInstructions");
|
|
19
|
-
|
|
20
12
|
var _getSpecifiedEntries = require("../utils/getSpecifiedEntries");
|
|
21
|
-
|
|
22
13
|
var _config = require("../utils/config");
|
|
23
|
-
|
|
24
|
-
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); }
|
|
25
|
-
|
|
26
|
-
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; }
|
|
27
|
-
|
|
28
14
|
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; }
|
|
29
|
-
|
|
30
15
|
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; }
|
|
31
|
-
|
|
32
16
|
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; }
|
|
33
|
-
|
|
34
17
|
const dev = async (api, options) => {
|
|
35
18
|
let userConfig = api.useResolvedConfigContext();
|
|
36
19
|
const appContext = api.useAppContext();
|
|
@@ -38,25 +21,21 @@ const dev = async (api, options) => {
|
|
|
38
21
|
userConfig = _objectSpread(_objectSpread({}, userConfig), {}, {
|
|
39
22
|
cliOptions: options
|
|
40
23
|
});
|
|
41
|
-
|
|
42
24
|
_core.ResolvedConfigContext.set(userConfig);
|
|
43
|
-
|
|
44
25
|
const {
|
|
45
26
|
appDirectory,
|
|
46
27
|
distDirectory,
|
|
47
28
|
port,
|
|
48
29
|
apiOnly,
|
|
49
30
|
entrypoints,
|
|
50
|
-
serverConfigFile
|
|
31
|
+
serverConfigFile,
|
|
32
|
+
serverInternalPlugins
|
|
51
33
|
} = appContext;
|
|
52
34
|
const checkedEntries = await (0, _getSpecifiedEntries.getSpecifiedEntries)(options.entry || false, entrypoints);
|
|
53
35
|
api.setAppContext(_objectSpread(_objectSpread({}, appContext), {}, {
|
|
54
36
|
checkedEntries
|
|
55
37
|
}));
|
|
56
38
|
appContext.checkedEntries = checkedEntries;
|
|
57
|
-
|
|
58
|
-
_utils.fs.emptyDirSync(distDirectory);
|
|
59
|
-
|
|
60
39
|
await (0, _config.buildServerConfig)({
|
|
61
40
|
appDirectory,
|
|
62
41
|
distDirectory,
|
|
@@ -69,21 +48,10 @@ const dev = async (api, options) => {
|
|
|
69
48
|
});
|
|
70
49
|
await hookRunners.beforeDev();
|
|
71
50
|
let compiler = null;
|
|
72
|
-
|
|
73
51
|
if (!apiOnly) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
WebpackConfigTarget
|
|
77
|
-
} = await Promise.resolve().then(() => _interopRequireWildcard(require('@modern-js/webpack')));
|
|
78
|
-
const webpackConfigs = [(0, _utils.isSSR)(userConfig) && getWebpackConfig(WebpackConfigTarget.NODE, appContext, userConfig), getWebpackConfig(WebpackConfigTarget.CLIENT, appContext, userConfig)].filter(Boolean);
|
|
79
|
-
compiler = await (0, _createCompiler.createCompiler)({
|
|
80
|
-
api,
|
|
81
|
-
webpackConfigs,
|
|
82
|
-
userConfig,
|
|
83
|
-
appContext
|
|
84
|
-
});
|
|
52
|
+
var _appContext$builder;
|
|
53
|
+
compiler = await ((_appContext$builder = appContext.builder) === null || _appContext$builder === void 0 ? void 0 : _appContext$builder.createCompiler());
|
|
85
54
|
}
|
|
86
|
-
|
|
87
55
|
await (0, _routes.generateRoutes)(appContext);
|
|
88
56
|
const app = await (0, _createServer.createServer)({
|
|
89
57
|
dev: _objectSpread(_objectSpread({}, {
|
|
@@ -102,19 +70,17 @@ const dev = async (api, options) => {
|
|
|
102
70
|
pwd: appDirectory,
|
|
103
71
|
config: userConfig,
|
|
104
72
|
serverConfigFile,
|
|
105
|
-
|
|
73
|
+
internalPlugins: (0, _createServer.injectDataLoaderPlugin)(serverInternalPlugins)
|
|
106
74
|
});
|
|
107
75
|
app.listen(port, async err => {
|
|
108
76
|
if (err) {
|
|
109
77
|
throw err;
|
|
110
78
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
79
|
+
if (!apiOnly) {
|
|
80
|
+
_utils.logger.info(`Starting dev server...\n`);
|
|
81
|
+
} else {
|
|
82
|
+
(0, _printInstructions.printInstructions)(hookRunners, appContext, userConfig);
|
|
114
83
|
}
|
|
115
|
-
|
|
116
|
-
return _utils.logger.log(_utils.chalk.cyan(`Starting the development server...`));
|
|
117
84
|
});
|
|
118
85
|
};
|
|
119
|
-
|
|
120
86
|
exports.dev = dev;
|
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
7
6
|
var _dev = require("./dev");
|
|
8
|
-
|
|
9
7
|
Object.keys(_dev).forEach(function (key) {
|
|
10
8
|
if (key === "default" || key === "__esModule") return;
|
|
11
9
|
if (key in exports && exports[key] === _dev[key]) return;
|
|
@@ -16,9 +14,7 @@ Object.keys(_dev).forEach(function (key) {
|
|
|
16
14
|
}
|
|
17
15
|
});
|
|
18
16
|
});
|
|
19
|
-
|
|
20
17
|
var _build = require("./build");
|
|
21
|
-
|
|
22
18
|
Object.keys(_build).forEach(function (key) {
|
|
23
19
|
if (key === "default" || key === "__esModule") return;
|
|
24
20
|
if (key in exports && exports[key] === _build[key]) return;
|
|
@@ -29,9 +25,7 @@ Object.keys(_build).forEach(function (key) {
|
|
|
29
25
|
}
|
|
30
26
|
});
|
|
31
27
|
});
|
|
32
|
-
|
|
33
28
|
var _start = require("./start");
|
|
34
|
-
|
|
35
29
|
Object.keys(_start).forEach(function (key) {
|
|
36
30
|
if (key === "default" || key === "__esModule") return;
|
|
37
31
|
if (key in exports && exports[key] === _start[key]) return;
|
|
@@ -3,96 +3,16 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var _webpack = require("@modern-js/webpack");
|
|
11
|
-
|
|
12
|
-
var _utils = require("@modern-js/utils");
|
|
13
|
-
|
|
14
|
-
var _webpackChain = _interopRequireDefault(require("@modern-js/utils/webpack-chain"));
|
|
15
|
-
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
|
-
const formatWebpackConfig = (config, verbose) => {
|
|
19
|
-
const stringify = _webpackChain.default.toString;
|
|
20
|
-
return `module.exports = ${stringify(config, {
|
|
21
|
-
verbose
|
|
22
|
-
})};`;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
exports.formatWebpackConfig = formatWebpackConfig;
|
|
26
|
-
|
|
27
|
-
const inspect = (api, options) => {
|
|
28
|
-
process.env.NODE_ENV = options.env;
|
|
29
|
-
const resolvedConfig = api.useResolvedConfigContext();
|
|
6
|
+
exports.inspect = void 0;
|
|
7
|
+
var _path = require("path");
|
|
8
|
+
const inspect = async (api, options) => {
|
|
9
|
+
var _appContext$builder;
|
|
30
10
|
const appContext = api.useAppContext();
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if ((0, _utils.isUseSSRBundle)(resolvedConfig)) {
|
|
39
|
-
outputFiles.push(printInspectResult(_webpack.WebpackConfigTarget.NODE, appContext, resolvedConfig, options));
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
_utils.logger.success('Inspect succeed, you can open following files to view the full webpack config: \n');
|
|
43
|
-
|
|
44
|
-
outputFiles.forEach(file => {
|
|
45
|
-
_utils.logger.log(` - ${_utils.chalk.yellow(_path.default.relative(appContext.appDirectory, file))}`);
|
|
11
|
+
return (_appContext$builder = appContext.builder) === null || _appContext$builder === void 0 ? void 0 : _appContext$builder.inspectConfig({
|
|
12
|
+
env: options.env,
|
|
13
|
+
verbose: options.verbose,
|
|
14
|
+
outputPath: (0, _path.join)(appContext === null || appContext === void 0 ? void 0 : appContext.builder.context.distPath, options.output),
|
|
15
|
+
writeToDisk: true
|
|
46
16
|
});
|
|
47
|
-
|
|
48
|
-
_utils.logger.log();
|
|
49
17
|
};
|
|
50
|
-
|
|
51
|
-
exports.inspect = inspect;
|
|
52
|
-
|
|
53
|
-
const getTagByWebpackTarget = webpackTarget => {
|
|
54
|
-
switch (webpackTarget) {
|
|
55
|
-
case _webpack.WebpackConfigTarget.CLIENT:
|
|
56
|
-
return 'client';
|
|
57
|
-
|
|
58
|
-
case _webpack.WebpackConfigTarget.MODERN:
|
|
59
|
-
return 'modern';
|
|
60
|
-
|
|
61
|
-
case _webpack.WebpackConfigTarget.NODE:
|
|
62
|
-
return 'ssr';
|
|
63
|
-
|
|
64
|
-
default:
|
|
65
|
-
throw Error(`Unsupported webpack target: ${webpackTarget}`);
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
exports.getTagByWebpackTarget = getTagByWebpackTarget;
|
|
70
|
-
|
|
71
|
-
const printInspectResult = (webpackTarget, appContext, resolvedConfig, options) => {
|
|
72
|
-
const webpackConfig = (0, _webpack.getWebpackConfig)(webpackTarget, appContext, resolvedConfig);
|
|
73
|
-
const {
|
|
74
|
-
output,
|
|
75
|
-
verbose,
|
|
76
|
-
console = true
|
|
77
|
-
} = options;
|
|
78
|
-
const outputPath = output ? _path.default.posix.join(appContext.distDirectory, output) : appContext.distDirectory;
|
|
79
|
-
const tag = getTagByWebpackTarget(webpackTarget);
|
|
80
|
-
const outputFile = `webpack.${tag}.inspect.js`;
|
|
81
|
-
|
|
82
|
-
const outputFilePath = _path.default.posix.join(outputPath, outputFile);
|
|
83
|
-
|
|
84
|
-
const rawWebpackConfig = formatWebpackConfig(webpackConfig, verbose);
|
|
85
|
-
|
|
86
|
-
_utils.fs.outputFileSync(outputFilePath, rawWebpackConfig);
|
|
87
|
-
|
|
88
|
-
if (console) {
|
|
89
|
-
_utils.logger.log(`
|
|
90
|
-
webpack config for ${tag} build:
|
|
91
|
-
${rawWebpackConfig}
|
|
92
|
-
`);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return outputFilePath;
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
exports.printInspectResult = printInspectResult;
|
|
18
|
+
exports.inspect = inspect;
|
|
@@ -4,18 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.start = void 0;
|
|
7
|
-
|
|
8
7
|
var _utils = require("@modern-js/utils");
|
|
9
|
-
|
|
10
8
|
var _prodServer = _interopRequireDefault(require("@modern-js/prod-server"));
|
|
11
|
-
|
|
12
9
|
var _printInstructions = require("../utils/printInstructions");
|
|
13
|
-
|
|
10
|
+
var _createServer = require("../utils/createServer");
|
|
14
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
12
|
const start = async api => {
|
|
17
13
|
var _userConfig$source;
|
|
18
|
-
|
|
19
14
|
const appContext = api.useAppContext();
|
|
20
15
|
const userConfig = api.useResolvedConfigContext();
|
|
21
16
|
const hookRunners = api.useHookRunners();
|
|
@@ -24,24 +19,20 @@ const start = async api => {
|
|
|
24
19
|
port,
|
|
25
20
|
serverConfigFile
|
|
26
21
|
} = appContext;
|
|
27
|
-
|
|
28
22
|
_utils.logger.log(_utils.chalk.cyan(`Starting the modern server...`));
|
|
29
|
-
|
|
30
23
|
const apiOnly = await (0, _utils.isApiOnly)(appContext.appDirectory, userConfig === null || userConfig === void 0 ? void 0 : (_userConfig$source = userConfig.source) === null || _userConfig$source === void 0 ? void 0 : _userConfig$source.entriesDir);
|
|
31
24
|
const app = await (0, _prodServer.default)({
|
|
32
25
|
pwd: appDirectory,
|
|
33
26
|
config: userConfig,
|
|
34
|
-
plugins: appContext.plugins.filter(p => p.server).map(p => p.server),
|
|
35
27
|
serverConfigFile,
|
|
28
|
+
internalPlugins: (0, _createServer.injectDataLoaderPlugin)(appContext.serverInternalPlugins),
|
|
36
29
|
apiOnly
|
|
37
30
|
});
|
|
38
31
|
app.listen(port, async err => {
|
|
39
32
|
if (err) {
|
|
40
33
|
throw err;
|
|
41
34
|
}
|
|
42
|
-
|
|
43
35
|
await (0, _printInstructions.printInstructions)(hookRunners, appContext, userConfig);
|
|
44
36
|
});
|
|
45
37
|
};
|
|
46
|
-
|
|
47
38
|
exports.start = start;
|
package/dist/js/node/hooks.js
CHANGED
|
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.hooks = exports.beforePrintInstructions = exports.beforeDev = exports.beforeDeploy = exports.beforeCreateCompiler = exports.beforeBuild = exports.afterDev = exports.afterDeploy = exports.afterCreateCompiler = exports.afterBuild = void 0;
|
|
7
|
-
|
|
8
7
|
var _plugin = require("@modern-js/plugin");
|
|
9
|
-
|
|
10
8
|
const beforeDev = (0, _plugin.createAsyncWorkflow)();
|
|
11
9
|
exports.beforeDev = beforeDev;
|
|
12
10
|
const afterDev = (0, _plugin.createAsyncWorkflow)();
|
package/dist/js/node/index.js
CHANGED
|
@@ -10,49 +10,38 @@ Object.defineProperty(exports, "defineConfig", {
|
|
|
10
10
|
return _core.defineConfig;
|
|
11
11
|
}
|
|
12
12
|
});
|
|
13
|
-
|
|
13
|
+
Object.defineProperty(exports, "hooks", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () {
|
|
16
|
+
return _hooks.hooks;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
14
19
|
var _path = _interopRequireDefault(require("path"));
|
|
15
|
-
|
|
16
20
|
var _core = require("@modern-js/core");
|
|
17
|
-
|
|
18
|
-
var _pluginJarvis = _interopRequireDefault(require("@modern-js/plugin-jarvis"));
|
|
19
|
-
|
|
21
|
+
var _pluginLint = _interopRequireDefault(require("@modern-js/plugin-lint"));
|
|
20
22
|
var _utils = require("@modern-js/utils");
|
|
21
|
-
|
|
22
23
|
var _analyze = _interopRequireDefault(require("./analyze"));
|
|
23
|
-
|
|
24
24
|
var _hooks = require("./hooks");
|
|
25
|
-
|
|
26
25
|
var _locale = require("./locale");
|
|
27
|
-
|
|
28
26
|
var _language = require("./utils/language");
|
|
29
|
-
|
|
27
|
+
var _commands = require("./utils/commands");
|
|
30
28
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
31
|
-
|
|
32
29
|
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; }
|
|
33
|
-
|
|
34
30
|
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; }
|
|
35
|
-
|
|
36
31
|
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; }
|
|
37
|
-
|
|
38
32
|
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); }
|
|
39
|
-
|
|
40
33
|
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; }
|
|
41
|
-
|
|
42
34
|
const upgradeModel = _utils.Import.lazy('@modern-js/upgrade', require);
|
|
43
|
-
|
|
44
35
|
var _default = () => ({
|
|
45
36
|
name: '@modern-js/app-tools',
|
|
46
|
-
post: ['@modern-js/plugin-analyze', '@modern-js/plugin-ssr', '@modern-js/plugin-state', '@modern-js/plugin-router', '@modern-js/plugin-polyfill'],
|
|
37
|
+
post: ['@modern-js/plugin-analyze', '@modern-js/plugin-ssr', '@modern-js/plugin-document', '@modern-js/plugin-state', '@modern-js/plugin-router', '@modern-js/plugin-router-legacy', '@modern-js/plugin-polyfill'],
|
|
47
38
|
registerHook: _hooks.hooks,
|
|
48
|
-
usePlugins: [(0, _analyze.default)(), (0,
|
|
39
|
+
usePlugins: [(0, _analyze.default)(), (0, _pluginLint.default)()],
|
|
49
40
|
setup: api => {
|
|
50
41
|
const locale = (0, _language.getLocaleLanguage)();
|
|
51
|
-
|
|
52
42
|
_locale.i18n.changeLanguage({
|
|
53
43
|
locale
|
|
54
44
|
});
|
|
55
|
-
|
|
56
45
|
return {
|
|
57
46
|
commands({
|
|
58
47
|
program
|
|
@@ -67,9 +56,9 @@ var _default = () => ({
|
|
|
67
56
|
const {
|
|
68
57
|
build
|
|
69
58
|
} = await Promise.resolve().then(() => _interopRequireWildcard(require("./commands/build")));
|
|
70
|
-
await build(api, options);
|
|
59
|
+
await build(api, options);
|
|
60
|
+
// force exit after build.
|
|
71
61
|
// eslint-disable-next-line no-process-exit
|
|
72
|
-
|
|
73
62
|
process.exit(0);
|
|
74
63
|
});
|
|
75
64
|
program.command('start').usage('[options]').description(_locale.i18n.t(_locale.localeKeys.command.start.describe)).option('--api-only', _locale.i18n.t(_locale.localeKeys.command.dev.apiOnly)).option('-c --config <config>', _locale.i18n.t(_locale.localeKeys.command.shared.config)).action(async () => {
|
|
@@ -86,8 +75,8 @@ var _default = () => ({
|
|
|
86
75
|
const {
|
|
87
76
|
deploy
|
|
88
77
|
} = await Promise.resolve().then(() => _interopRequireWildcard(require("./commands/deploy")));
|
|
89
|
-
await deploy(api, options);
|
|
90
|
-
|
|
78
|
+
await deploy(api, options);
|
|
79
|
+
// eslint-disable-next-line no-process-exit
|
|
91
80
|
process.exit(0);
|
|
92
81
|
});
|
|
93
82
|
program.command('new').usage('[options]').description(_locale.i18n.t(_locale.localeKeys.command.new.describe)).option('-d, --debug', _locale.i18n.t(_locale.localeKeys.command.new.debug), false).option('-c, --config <config>', _locale.i18n.t(_locale.localeKeys.command.new.config)).option('--dist-tag <tag>', _locale.i18n.t(_locale.localeKeys.command.new.distTag)).option('--registry', _locale.i18n.t(_locale.localeKeys.command.new.registry)).action(async options => {
|
|
@@ -98,7 +87,7 @@ var _default = () => ({
|
|
|
98
87
|
locale
|
|
99
88
|
}));
|
|
100
89
|
});
|
|
101
|
-
program.command('inspect').description('inspect internal webpack config').option(`--env <env>`, _locale.i18n.t(_locale.localeKeys.command.inspect.env), 'development').option('--output <output>', _locale.i18n.t(_locale.localeKeys.command.inspect.output), '/').option('--
|
|
90
|
+
program.command('inspect').description('inspect internal webpack config').option(`--env <env>`, _locale.i18n.t(_locale.localeKeys.command.inspect.env), 'development').option('--output <output>', _locale.i18n.t(_locale.localeKeys.command.inspect.output), '/').option('--verbose', _locale.i18n.t(_locale.localeKeys.command.inspect.verbose)).option('-c --config <config>', _locale.i18n.t(_locale.localeKeys.command.shared.config)).action(async options => {
|
|
102
91
|
const {
|
|
103
92
|
inspect
|
|
104
93
|
} = await Promise.resolve().then(() => _interopRequireWildcard(require("./commands/inspect")));
|
|
@@ -106,7 +95,13 @@ var _default = () => ({
|
|
|
106
95
|
});
|
|
107
96
|
upgradeModel.defineCommand(program.command('upgrade'));
|
|
108
97
|
},
|
|
109
|
-
|
|
98
|
+
async prepare() {
|
|
99
|
+
const command = (0, _commands.getCommand)();
|
|
100
|
+
if (command === 'dev' || command === 'build') {
|
|
101
|
+
const appContext = api.useAppContext();
|
|
102
|
+
await (0, _utils.emptyDir)(appContext.distDirectory);
|
|
103
|
+
}
|
|
104
|
+
},
|
|
110
105
|
// 这里会被 core/initWatcher 监听的文件变动触发,如果是 src 目录下的文件变动,则不做 restart
|
|
111
106
|
async fileChange(e) {
|
|
112
107
|
const {
|
|
@@ -118,9 +113,7 @@ var _default = () => ({
|
|
|
118
113
|
appDirectory,
|
|
119
114
|
srcDirectory
|
|
120
115
|
} = appContext;
|
|
121
|
-
|
|
122
116
|
const absolutePath = _path.default.resolve(appDirectory, filename);
|
|
123
|
-
|
|
124
117
|
if (!absolutePath.includes(srcDirectory) && (eventType === 'change' || eventType === 'unlink')) {
|
|
125
118
|
const {
|
|
126
119
|
closeServer
|
|
@@ -129,13 +122,10 @@ var _default = () => ({
|
|
|
129
122
|
await _core.cli.restart();
|
|
130
123
|
}
|
|
131
124
|
},
|
|
132
|
-
|
|
133
125
|
async beforeRestart() {
|
|
134
126
|
(0, _utils.cleanRequireCache)([require.resolve("./analyze")]);
|
|
135
127
|
}
|
|
136
|
-
|
|
137
128
|
};
|
|
138
129
|
}
|
|
139
130
|
});
|
|
140
|
-
|
|
141
131
|
exports.default = _default;
|
|
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.localeKeys = exports.i18n = void 0;
|
|
7
|
-
|
|
8
7
|
var _pluginI18n = require("@modern-js/plugin-i18n");
|
|
9
|
-
|
|
10
8
|
var _zh = require("./zh");
|
|
11
|
-
|
|
12
9
|
var _en = require("./en");
|
|
13
|
-
|
|
14
10
|
const i18n = new _pluginI18n.I18n();
|
|
15
11
|
exports.i18n = i18n;
|
|
16
12
|
const localeKeys = i18n.init('zh', {
|