@modern-js/module-tools 2.10.1-beta.0 → 2.10.1-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/dist/build.js +29 -9
- package/dist/build.js.map +1 -1
- package/dist/builder/build.js +86 -48
- package/dist/builder/build.js.map +1 -1
- package/dist/builder/clear.js +29 -9
- package/dist/builder/clear.js.map +1 -1
- package/dist/builder/copy.js +78 -39
- package/dist/builder/copy.js.map +1 -1
- package/dist/builder/dts/rollup.js +61 -26
- package/dist/builder/dts/rollup.js.map +1 -1
- package/dist/builder/dts/tsc.js +77 -37
- package/dist/builder/dts/tsc.js.map +1 -1
- package/dist/builder/index.js +36 -16
- package/dist/builder/index.js.map +1 -1
- package/dist/builder/platform.js +33 -13
- package/dist/builder/platform.js.map +1 -1
- package/dist/cli.js +45 -23
- package/dist/cli.js.map +1 -1
- package/dist/command.js +76 -39
- package/dist/command.js.map +1 -1
- package/dist/config/defineConfig.js +18 -2
- package/dist/config/defineConfig.js.map +1 -1
- package/dist/config/normalize.js +73 -45
- package/dist/config/normalize.js.map +1 -1
- package/dist/config/transformLegacyConfig.js +130 -90
- package/dist/config/transformLegacyConfig.js.map +1 -1
- package/dist/constants/buildPresets.js +23 -14
- package/dist/constants/buildPresets.js.map +1 -1
- package/dist/dev.js +43 -19
- package/dist/dev.js.map +1 -1
- package/dist/error.js +2 -7
- package/dist/error.js.map +1 -1
- package/dist/hooks/index.js +15 -6
- package/dist/hooks/index.js.map +1 -1
- package/dist/utils/builder.js +27 -7
- package/dist/utils/builder.js.map +1 -1
- package/dist/utils/common.js +19 -3
- package/dist/utils/common.js.map +1 -1
- package/dist/utils/config.js +83 -57
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/context.js +23 -3
- package/dist/utils/context.js.map +1 -1
- package/dist/utils/dts.js +64 -25
- package/dist/utils/dts.js.map +1 -1
- package/dist/utils/input.js +34 -14
- package/dist/utils/input.js.map +1 -1
- package/dist/utils/language.js +23 -3
- package/dist/utils/language.js.map +1 -1
- package/dist/utils/libuildPlugins.js +29 -9
- package/dist/utils/libuildPlugins.js.map +1 -1
- package/dist/utils/log.js +23 -3
- package/dist/utils/log.js.map +1 -1
- package/dist/utils/onExit.js +26 -6
- package/dist/utils/onExit.js.map +1 -1
- package/dist/utils/path.js +23 -3
- package/dist/utils/path.js.map +1 -1
- package/dist/utils/print.js +24 -4
- package/dist/utils/print.js.map +1 -1
- package/dist/utils/style.js +52 -29
- package/dist/utils/style.js.map +1 -1
- package/lib/types.d.ts +0 -98
- package/package.json +5 -5
package/dist/builder/dts/tsc.js
CHANGED
|
@@ -1,9 +1,26 @@
|
|
|
1
1
|
var __create = Object.create;
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
8
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
9
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __spreadValues = (a, b) => {
|
|
13
|
+
for (var prop in b || (b = {}))
|
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
if (__getOwnPropSymbols)
|
|
17
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
+
if (__propIsEnum.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
}
|
|
21
|
+
return a;
|
|
22
|
+
};
|
|
23
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
7
24
|
var __export = (target, all) => {
|
|
8
25
|
for (var name in all)
|
|
9
26
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -25,51 +42,74 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
25
42
|
mod
|
|
26
43
|
));
|
|
27
44
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
45
|
+
var __async = (__this, __arguments, generator) => {
|
|
46
|
+
return new Promise((resolve, reject) => {
|
|
47
|
+
var fulfilled = (value) => {
|
|
48
|
+
try {
|
|
49
|
+
step(generator.next(value));
|
|
50
|
+
} catch (e) {
|
|
51
|
+
reject(e);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
var rejected = (value) => {
|
|
55
|
+
try {
|
|
56
|
+
step(generator.throw(value));
|
|
57
|
+
} catch (e) {
|
|
58
|
+
reject(e);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
62
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
63
|
+
});
|
|
64
|
+
};
|
|
28
65
|
var tsc_exports = {};
|
|
29
66
|
__export(tsc_exports, {
|
|
30
67
|
getProjectTsconfig: () => getProjectTsconfig,
|
|
31
68
|
runTsc: () => runTsc
|
|
32
69
|
});
|
|
33
70
|
module.exports = __toCommonJS(tsc_exports);
|
|
34
|
-
const getProjectTsconfig =
|
|
35
|
-
const { json5, fs } =
|
|
71
|
+
const getProjectTsconfig = (tsconfigPath) => __async(void 0, null, function* () {
|
|
72
|
+
const { json5, fs } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
36
73
|
if (!fs.existsSync(tsconfigPath)) {
|
|
37
74
|
return {};
|
|
38
75
|
}
|
|
39
76
|
return json5.parse(fs.readFileSync(tsconfigPath, "utf-8"));
|
|
40
|
-
};
|
|
41
|
-
const resolveLog =
|
|
42
|
-
|
|
43
|
-
const {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
77
|
+
});
|
|
78
|
+
const resolveLog = (childProgress, options) => __async(void 0, null, function* () {
|
|
79
|
+
var _a, _b, _c;
|
|
80
|
+
const { watch = false, watchFn = () => __async(void 0, null, function* () {
|
|
81
|
+
return void 0;
|
|
82
|
+
}) } = options;
|
|
83
|
+
const { SectionTitleStatus, BundlelessDtsLogPrefix } = yield Promise.resolve().then(() => __toESM(require("../../constants/log")));
|
|
84
|
+
const { watchSectionTitle } = yield Promise.resolve().then(() => __toESM(require("../../utils/log")));
|
|
85
|
+
const { watchDoneText } = yield Promise.resolve().then(() => __toESM(require("../../constants/dts")));
|
|
86
|
+
(_a = childProgress.stdout) == null ? void 0 : _a.on("data", (data) => __async(void 0, null, function* () {
|
|
47
87
|
if (watch) {
|
|
48
88
|
console.info(
|
|
49
|
-
|
|
89
|
+
yield watchSectionTitle(BundlelessDtsLogPrefix, SectionTitleStatus.Log)
|
|
50
90
|
);
|
|
51
91
|
console.info(data.toString());
|
|
52
92
|
if (data.toString().includes(watchDoneText)) {
|
|
53
|
-
|
|
93
|
+
yield watchFn();
|
|
54
94
|
}
|
|
55
95
|
}
|
|
56
|
-
});
|
|
57
|
-
childProgress.stdout
|
|
96
|
+
}));
|
|
97
|
+
(_b = childProgress.stdout) == null ? void 0 : _b.on("error", (error) => {
|
|
58
98
|
console.error(error.message);
|
|
59
99
|
});
|
|
60
|
-
childProgress.stderr
|
|
100
|
+
(_c = childProgress.stderr) == null ? void 0 : _c.on("data", (chunk) => {
|
|
61
101
|
console.error(chunk.toString());
|
|
62
102
|
});
|
|
63
|
-
};
|
|
64
|
-
const generatorDts =
|
|
65
|
-
const { execa } =
|
|
66
|
-
const { InternalDTSError } =
|
|
67
|
-
const { generatorTsConfig } =
|
|
68
|
-
const { getTscBinPath } =
|
|
103
|
+
});
|
|
104
|
+
const generatorDts = (api, config) => __async(void 0, null, function* () {
|
|
105
|
+
const { execa } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
106
|
+
const { InternalDTSError } = yield Promise.resolve().then(() => __toESM(require("../../error")));
|
|
107
|
+
const { generatorTsConfig } = yield Promise.resolve().then(() => __toESM(require("../../utils/dts")));
|
|
108
|
+
const { getTscBinPath } = yield Promise.resolve().then(() => __toESM(require("../../utils/dts")));
|
|
69
109
|
const { tsconfigPath, appDirectory, watch = false } = config;
|
|
70
|
-
const userTsconfig =
|
|
71
|
-
const result =
|
|
72
|
-
const tscBinFile =
|
|
110
|
+
const userTsconfig = yield getProjectTsconfig(tsconfigPath);
|
|
111
|
+
const result = yield generatorTsConfig(config);
|
|
112
|
+
const tscBinFile = yield getTscBinPath(appDirectory);
|
|
73
113
|
const watchParams = watch ? ["-w"] : [];
|
|
74
114
|
const childProgress = execa(
|
|
75
115
|
tscBinFile,
|
|
@@ -90,14 +130,14 @@ const generatorDts = async (api, config) => {
|
|
|
90
130
|
const runner = api.useHookRunners();
|
|
91
131
|
resolveLog(childProgress, {
|
|
92
132
|
watch,
|
|
93
|
-
watchFn:
|
|
94
|
-
const { resolveAlias } =
|
|
95
|
-
|
|
133
|
+
watchFn: () => __async(void 0, null, function* () {
|
|
134
|
+
const { resolveAlias } = yield Promise.resolve().then(() => __toESM(require("../../utils/dts")));
|
|
135
|
+
yield resolveAlias(config, __spreadProps(__spreadValues({}, result), { userTsconfig }));
|
|
96
136
|
runner.buildWatchDts({ buildType: "bundleless" });
|
|
97
|
-
}
|
|
137
|
+
})
|
|
98
138
|
});
|
|
99
139
|
try {
|
|
100
|
-
|
|
140
|
+
yield childProgress;
|
|
101
141
|
} catch (e) {
|
|
102
142
|
if (e instanceof Error) {
|
|
103
143
|
throw new InternalDTSError(e, {
|
|
@@ -105,15 +145,15 @@ const generatorDts = async (api, config) => {
|
|
|
105
145
|
});
|
|
106
146
|
}
|
|
107
147
|
}
|
|
108
|
-
return {
|
|
109
|
-
};
|
|
110
|
-
const runTsc =
|
|
111
|
-
const { resolveAlias } =
|
|
112
|
-
const { addDtsFiles } =
|
|
113
|
-
const result =
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
};
|
|
148
|
+
return __spreadProps(__spreadValues({}, result), { userTsconfig });
|
|
149
|
+
});
|
|
150
|
+
const runTsc = (api, config) => __async(void 0, null, function* () {
|
|
151
|
+
const { resolveAlias } = yield Promise.resolve().then(() => __toESM(require("../../utils/dts")));
|
|
152
|
+
const { addDtsFiles } = yield Promise.resolve().then(() => __toESM(require("../../utils/print")));
|
|
153
|
+
const result = yield generatorDts(api, config);
|
|
154
|
+
yield resolveAlias(config, result);
|
|
155
|
+
yield addDtsFiles(config.distAbsPath, config.appDirectory);
|
|
156
|
+
});
|
|
117
157
|
// Annotate the CommonJS export names for ESM import in node:
|
|
118
158
|
0 && (module.exports = {
|
|
119
159
|
getProjectTsconfig,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":"
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQO,MAAM,qBAAqB,CAChC,iBACuB;AACvB,QAAM,EAAE,OAAO,GAAG,IAAI,MAAM,6CAAO,kBAAkB;AACrD,MAAI,CAAC,GAAG,WAAW,YAAY,GAAG;AAChC,WAAO,CAAC;AAAA,EACV;AAEA,SAAO,MAAM,MAAM,GAAG,aAAa,cAAc,OAAO,CAAC;AAC3D;AAEA,MAAM,aAAa,CACjB,eACA,YAIG;AAzBL;AA0BE,QAAM,EAAE,QAAQ,OAAO,UAAU,MAAS;AAAG;AAAA,KAAU,IAAI;AAC3D,QAAM,EAAE,oBAAoB,uBAAuB,IAAI,MAAM,6CAC3D,qBACF;AACA,QAAM,EAAE,kBAAkB,IAAI,MAAM,6CAAO,iBAAiB;AAC5D,QAAM,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xB;AAAA,IACA,SAAS,MAAY;AACnB,YAAM,EAAE,aAAa,IAAI,MAAM,6CAAO,iBAAiB;AACvD,YAAM,aAAa,QAAQ,iCAAK,SAAL,EAAa,aAAa,EAAC;AACtD,aAAO,cAAc,EAAE,WAAW,aAAa,CAAC;AAAA,IAClD;AAAA,EACF,CAAC;AAED,MAAI;AACF,UAAM;AAAA,EACR,SAAS,GAAP;AACA,QAAI,aAAa,OAAO;AACtB,YAAM,IAAI,iBAAiB,GAAG;AAAA,QAC5B,WAAW;AAAA,MACb,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO,iCAAK,SAAL,EAAa,aAAa;AACnC;AAEO,MAAM,SAAS,CACpB,KACA,WACG;AACH,QAAM,EAAE,aAAa,IAAI,MAAM,6CAAO,iBAAiB;AACvD,QAAM,EAAE,YAAY,IAAI,MAAM,6CAAO,mBAAmB;AACxD,QAAM,SAAS,MAAM,aAAa,KAAK,MAAM;AAC7C,QAAM,aAAa,QAAQ,MAAM;AACjC,QAAM,YAAY,OAAO,aAAa,OAAO,YAAY;AAC3D;;;;;;","names":[],"sources":["../../../src/builder/dts/tsc.ts"],"sourcesContent":["import type { ChildProcess } from 'child_process';\nimport type {\n BundlelessGeneratorDtsConfig,\n ITsconfig,\n PluginAPI,\n ModuleTools,\n} from '../../types';\n\nexport const getProjectTsconfig = async (\n tsconfigPath: string,\n): Promise<ITsconfig> => {\n const { json5, fs } = await import('@modern-js/utils');\n if (!fs.existsSync(tsconfigPath)) {\n return {};\n }\n\n return json5.parse(fs.readFileSync(tsconfigPath, 'utf-8'));\n};\n\nconst resolveLog = async (\n childProgress: ChildProcess,\n options: {\n watch: boolean;\n watchFn: () => Promise<void>;\n },\n) => {\n const { watch = false, watchFn = async () => undefined } = options;\n const { SectionTitleStatus, BundlelessDtsLogPrefix } = await import(\n '../../constants/log'\n );\n const { watchSectionTitle } = await import('../../utils/log');\n const { watchDoneText } = await import('../../constants/dts');\n\n /**\n * tsc 所有的log信息都是从stdout data 事件中获取\n * 正常模式下,如果有报错信息,交给 resolveLog 后面的逻辑来处理\n * watch 模式下,则使用这里的信息\n */\n childProgress.stdout?.on('data', async data => {\n if (watch) {\n console.info(\n await watchSectionTitle(BundlelessDtsLogPrefix, SectionTitleStatus.Log),\n );\n console.info(data.toString());\n if (data.toString().includes(watchDoneText)) {\n await watchFn();\n }\n }\n });\n // 正常以下内容都不会触发,因为tsc 不会产生以下类型的log信息,不过防止意外情况\n childProgress.stdout?.on('error', error => {\n console.error(error.message);\n });\n childProgress.stderr?.on('data', chunk => {\n console.error(chunk.toString());\n });\n};\n\nconst generatorDts = async (\n api: PluginAPI<ModuleTools>,\n config: BundlelessGeneratorDtsConfig,\n) => {\n const { execa } = await import('@modern-js/utils');\n const { InternalDTSError } = await import('../../error');\n const { generatorTsConfig } = await import('../../utils/dts');\n const { getTscBinPath } = await import('../../utils/dts');\n const { tsconfigPath, appDirectory, watch = false } = config;\n const userTsconfig = await getProjectTsconfig(tsconfigPath);\n const result = await generatorTsConfig(config);\n\n const tscBinFile = await getTscBinPath(appDirectory);\n\n const watchParams = watch ? ['-w'] : [];\n const childProgress = execa(\n tscBinFile,\n [\n '-p',\n result.tempTsconfigPath,\n /* Required parameter, use it stdout have color */\n '--pretty',\n // https://github.com/microsoft/TypeScript/issues/21824\n '--preserveWatchOutput',\n ...watchParams,\n ],\n {\n stdio: 'pipe',\n cwd: appDirectory,\n },\n );\n\n const runner = api.useHookRunners();\n resolveLog(childProgress, {\n watch,\n watchFn: async () => {\n const { resolveAlias } = await import('../../utils/dts');\n await resolveAlias(config, { ...result, userTsconfig });\n runner.buildWatchDts({ buildType: 'bundleless' });\n },\n });\n\n try {\n await childProgress;\n } catch (e) {\n if (e instanceof Error) {\n throw new InternalDTSError(e, {\n buildType: 'bundleless',\n });\n }\n }\n\n return { ...result, userTsconfig };\n};\n\nexport const runTsc = async (\n api: PluginAPI<ModuleTools>,\n config: BundlelessGeneratorDtsConfig,\n) => {\n const { resolveAlias } = await import('../../utils/dts');\n const { addDtsFiles } = await import('../../utils/print');\n const result = await generatorDts(api, config);\n await resolveAlias(config, result);\n await addDtsFiles(config.distAbsPath, config.appDirectory);\n};\n"]}
|
package/dist/builder/index.js
CHANGED
|
@@ -25,30 +25,50 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
25
25
|
mod
|
|
26
26
|
));
|
|
27
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var __async = (__this, __arguments, generator) => {
|
|
29
|
+
return new Promise((resolve, reject) => {
|
|
30
|
+
var fulfilled = (value) => {
|
|
31
|
+
try {
|
|
32
|
+
step(generator.next(value));
|
|
33
|
+
} catch (e) {
|
|
34
|
+
reject(e);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
var rejected = (value) => {
|
|
38
|
+
try {
|
|
39
|
+
step(generator.throw(value));
|
|
40
|
+
} catch (e) {
|
|
41
|
+
reject(e);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
45
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
46
|
+
});
|
|
47
|
+
};
|
|
28
48
|
var builder_exports = {};
|
|
29
49
|
__export(builder_exports, {
|
|
30
50
|
run: () => run
|
|
31
51
|
});
|
|
32
52
|
module.exports = __toCommonJS(builder_exports);
|
|
33
|
-
const run =
|
|
34
|
-
const { chalk } =
|
|
53
|
+
const run = (options, api) => __async(void 0, null, function* () {
|
|
54
|
+
const { chalk } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
35
55
|
const { resolvedBuildConfig, context, cmdOptions } = options;
|
|
36
56
|
const runner = api.useHookRunners();
|
|
37
57
|
let totalDuration = 0;
|
|
38
58
|
if (resolvedBuildConfig.length !== 0) {
|
|
39
59
|
totalDuration = Date.now();
|
|
40
|
-
const { runBuildTask } =
|
|
41
|
-
const { default: pMap } =
|
|
42
|
-
const { clearBuildConfigPaths, clearDtsTemp } =
|
|
43
|
-
|
|
44
|
-
|
|
60
|
+
const { runBuildTask } = yield Promise.resolve().then(() => __toESM(require("./build")));
|
|
61
|
+
const { default: pMap } = yield Promise.resolve().then(() => __toESM(require("../../compiled/p-map")));
|
|
62
|
+
const { clearBuildConfigPaths, clearDtsTemp } = yield Promise.resolve().then(() => __toESM(require("./clear")));
|
|
63
|
+
yield clearBuildConfigPaths(resolvedBuildConfig);
|
|
64
|
+
yield clearDtsTemp();
|
|
45
65
|
if (cmdOptions.watch) {
|
|
46
66
|
console.info(chalk.blue.underline("start build in watch mode...\n"));
|
|
47
67
|
}
|
|
48
68
|
try {
|
|
49
|
-
|
|
50
|
-
const buildConfig =
|
|
51
|
-
|
|
69
|
+
yield pMap(resolvedBuildConfig, (config) => __async(void 0, null, function* () {
|
|
70
|
+
const buildConfig = yield runner.beforeBuildTask(config);
|
|
71
|
+
yield runBuildTask(
|
|
52
72
|
{
|
|
53
73
|
buildConfig,
|
|
54
74
|
buildCmdOptions: cmdOptions,
|
|
@@ -56,10 +76,10 @@ const run = async (options, api) => {
|
|
|
56
76
|
},
|
|
57
77
|
api
|
|
58
78
|
);
|
|
59
|
-
|
|
60
|
-
});
|
|
79
|
+
yield runner.afterBuildTask({ status: "success", config });
|
|
80
|
+
}));
|
|
61
81
|
} catch (e) {
|
|
62
|
-
const { isInternalError, ModuleBuildError } =
|
|
82
|
+
const { isInternalError, ModuleBuildError } = yield Promise.resolve().then(() => __toESM(require("../error")));
|
|
63
83
|
if (isInternalError(e)) {
|
|
64
84
|
throw new ModuleBuildError(e);
|
|
65
85
|
} else {
|
|
@@ -68,7 +88,7 @@ const run = async (options, api) => {
|
|
|
68
88
|
}
|
|
69
89
|
totalDuration = Date.now() - totalDuration;
|
|
70
90
|
if (!cmdOptions.watch) {
|
|
71
|
-
const { printFileSize, printSucceed } =
|
|
91
|
+
const { printFileSize, printSucceed } = yield Promise.resolve().then(() => __toESM(require("../utils/print")));
|
|
72
92
|
printSucceed(totalDuration);
|
|
73
93
|
printFileSize();
|
|
74
94
|
}
|
|
@@ -79,13 +99,13 @@ const run = async (options, api) => {
|
|
|
79
99
|
)
|
|
80
100
|
);
|
|
81
101
|
}
|
|
82
|
-
|
|
102
|
+
yield runner.afterBuild({
|
|
83
103
|
status: "success",
|
|
84
104
|
config: resolvedBuildConfig,
|
|
85
105
|
commandOptions: cmdOptions,
|
|
86
106
|
totalDuration
|
|
87
107
|
});
|
|
88
|
-
};
|
|
108
|
+
});
|
|
89
109
|
// Annotate the CommonJS export names for ESM import in node:
|
|
90
110
|
0 && (module.exports = {
|
|
91
111
|
run
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":"
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAQO,MAAM,MAAM,CACjB,SAKA,QACG;AACH,QAAM,EAAE,MAAM,IAAI,MAAM,6CAAO,kBAAkB;AACjD,QAAM,EAAE,qBAAqB,SAAS,WAAW,IAAI;AACrD,QAAM,SAAS,IAAI,eAAe;AAElC,MAAI,gBAAgB;AAEpB,MAAI,oBAAoB,WAAW,GAAG;AACpC,oBAAgB,KAAK,IAAI;AAEzB,UAAM,EAAE,aAAa,IAAI,MAAM,6CAAO,SAAS;AAC/C,UAAM,EAAE,SAAS,KAAK,IAAI,MAAM,6CAAO,sBAAsB;AAE7D,UAAM,EAAE,uBAAuB,aAAa,IAAI,MAAM,6CAAO,SAAS;AACtE,UAAM,sBAAsB,mBAAmB;AAC/C,UAAM,aAAa;AAEnB,QAAI,WAAW,OAAO;AACpB,cAAQ,KAAK,MAAM,KAAK,UAAU,gCAAgC,CAAC;AAAA,IACrE;AAEA,QAAI;AACF,YAAM,KAAK,qBAAqB,CAAM,WAAU;AAC9C,cAAM,cAAc,MAAM,OAAO,gBAAgB,MAAM;AAEvD,cAAM;AAAA,UACJ;AAAA,YACE;AAAA,YACA,iBAAiB;AAAA,YACjB;AAAA,UACF;AAAA,UACA;AAAA,QACF;AACA,cAAM,OAAO,eAAe,EAAE,QAAQ,WAAW,OAAO,CAAC;AAAA,MAC3D,EAAC;AAAA,IACH,SAAS,GAAP;AACA,YAAM,EAAE,iBAAiB,iBAAiB,IAAI,MAAM,6CAAO,UAAU;AACrE,UAAI,gBAAgB,CAAC,GAAG;AACtB,cAAM,IAAI,iBAAiB,CAAC;AAAA,MAC9B,OAAO;AACL,cAAM;AAAA,MACR;AAAA,IACF;AACA,oBAAgB,KAAK,IAAI,IAAI;AAC7B,QAAI,CAAC,WAAW,OAAO;AACrB,YAAM,EAAE,eAAe,aAAa,IAAI,MAAM,6CAAO,gBAAgB;AACrE,mBAAa,aAAa;AAC1B,oBAAc;AAAA,IAChB;AAAA,EACF,OAAO;AACL,YAAQ;AAAA,MACN,MAAM;AAAA,QACJ;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,QAAM,OAAO,WAAW;AAAA,IACtB,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,gBAAgB;AAAA,IAChB;AAAA,EACF,CAAC;AACH;;;;;","names":[],"sources":["../../src/builder/index.ts"],"sourcesContent":["import type { PluginAPI } from '@modern-js/core';\nimport type { ModuleContext } from '../types/context';\nimport type {\n BuildCommandOptions,\n BaseBuildConfig,\n ModuleTools,\n} from '../types';\n\nexport const run = async (\n options: {\n cmdOptions: BuildCommandOptions;\n resolvedBuildConfig: BaseBuildConfig[];\n context: ModuleContext;\n },\n api: PluginAPI<ModuleTools>,\n) => {\n const { chalk } = await import('@modern-js/utils');\n const { resolvedBuildConfig, context, cmdOptions } = options;\n const runner = api.useHookRunners();\n\n let totalDuration = 0;\n\n if (resolvedBuildConfig.length !== 0) {\n totalDuration = Date.now();\n\n const { runBuildTask } = await import('./build');\n const { default: pMap } = await import('../../compiled/p-map');\n\n const { clearBuildConfigPaths, clearDtsTemp } = await import('./clear');\n await clearBuildConfigPaths(resolvedBuildConfig);\n await clearDtsTemp();\n\n if (cmdOptions.watch) {\n console.info(chalk.blue.underline('start build in watch mode...\\n'));\n }\n\n try {\n await pMap(resolvedBuildConfig, async config => {\n const buildConfig = await runner.beforeBuildTask(config);\n\n await runBuildTask(\n {\n buildConfig,\n buildCmdOptions: cmdOptions,\n context,\n },\n api,\n );\n await runner.afterBuildTask({ status: 'success', config });\n });\n } catch (e) {\n const { isInternalError, ModuleBuildError } = await import('../error');\n if (isInternalError(e)) {\n throw new ModuleBuildError(e);\n } else {\n throw e;\n }\n }\n totalDuration = Date.now() - totalDuration;\n if (!cmdOptions.watch) {\n const { printFileSize, printSucceed } = await import('../utils/print');\n printSucceed(totalDuration);\n printFileSize();\n }\n } else {\n console.warn(\n chalk.yellow(\n `No build configuration found! Please configure \\`buildConfig\\` or \\`buildPreset\\``,\n ),\n );\n }\n\n await runner.afterBuild({\n status: 'success',\n config: resolvedBuildConfig,\n commandOptions: cmdOptions,\n totalDuration,\n });\n};\n"]}
|
package/dist/builder/platform.js
CHANGED
|
@@ -25,16 +25,36 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
25
25
|
mod
|
|
26
26
|
));
|
|
27
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var __async = (__this, __arguments, generator) => {
|
|
29
|
+
return new Promise((resolve, reject) => {
|
|
30
|
+
var fulfilled = (value) => {
|
|
31
|
+
try {
|
|
32
|
+
step(generator.next(value));
|
|
33
|
+
} catch (e) {
|
|
34
|
+
reject(e);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
var rejected = (value) => {
|
|
38
|
+
try {
|
|
39
|
+
step(generator.throw(value));
|
|
40
|
+
} catch (e) {
|
|
41
|
+
reject(e);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
45
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
46
|
+
});
|
|
47
|
+
};
|
|
28
48
|
var platform_exports = {};
|
|
29
49
|
__export(platform_exports, {
|
|
30
50
|
buildPlatform: () => buildPlatform
|
|
31
51
|
});
|
|
32
52
|
module.exports = __toCommonJS(platform_exports);
|
|
33
|
-
const buildPlatform =
|
|
34
|
-
const { chalk } =
|
|
35
|
-
const { blue, gray } =
|
|
53
|
+
const buildPlatform = (options, api, context) => __async(void 0, null, function* () {
|
|
54
|
+
const { chalk } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
55
|
+
const { blue, gray } = yield Promise.resolve().then(() => __toESM(require("../constants/colors")));
|
|
36
56
|
const runner = api.useHookRunners();
|
|
37
|
-
const platformBuilders =
|
|
57
|
+
const platformBuilders = yield runner.registerBuildPlatform();
|
|
38
58
|
if (platformBuilders.length === 0) {
|
|
39
59
|
if (options.platform === true) {
|
|
40
60
|
console.info("No executable platform build tasks");
|
|
@@ -51,7 +71,7 @@ const buildPlatform = async (options, api, context) => {
|
|
|
51
71
|
}
|
|
52
72
|
return;
|
|
53
73
|
}
|
|
54
|
-
|
|
74
|
+
yield runner.beforeBuildPlatform(platformBuilders);
|
|
55
75
|
let errorMsg = null;
|
|
56
76
|
try {
|
|
57
77
|
if (options.platform === true) {
|
|
@@ -62,8 +82,8 @@ const buildPlatform = async (options, api, context) => {
|
|
|
62
82
|
`Running [${currentPlatform}] build task:`
|
|
63
83
|
)
|
|
64
84
|
);
|
|
65
|
-
|
|
66
|
-
|
|
85
|
+
yield runner.buildPlatform({ platform: currentPlatform });
|
|
86
|
+
yield platformBuilder.build(currentPlatform, {
|
|
67
87
|
isTsProject: context.isTsProject
|
|
68
88
|
});
|
|
69
89
|
console.info(chalk.rgb(...gray)(`Done for [${currentPlatform}] task`));
|
|
@@ -83,8 +103,8 @@ const buildPlatform = async (options, api, context) => {
|
|
|
83
103
|
console.info(
|
|
84
104
|
chalk.underline.rgb(...blue)(`Running [${targetPlatform}] build task:`)
|
|
85
105
|
);
|
|
86
|
-
|
|
87
|
-
|
|
106
|
+
yield runner.buildPlatform({ platform: targetPlatform });
|
|
107
|
+
yield selectPlatformBuilder.build(targetPlatform, {
|
|
88
108
|
isTsProject: context.isTsProject
|
|
89
109
|
});
|
|
90
110
|
console.info(chalk.rgb(...gray)(`Done for [${targetPlatform}] task`));
|
|
@@ -103,8 +123,8 @@ const buildPlatform = async (options, api, context) => {
|
|
|
103
123
|
console.info(
|
|
104
124
|
chalk.underline.rgb(...blue)(`Running [${platform}] build task:`)
|
|
105
125
|
);
|
|
106
|
-
|
|
107
|
-
|
|
126
|
+
yield runner.buildPlatform({ platform });
|
|
127
|
+
yield foundBuilder.build(platform, {
|
|
108
128
|
isTsProject: context.isTsProject
|
|
109
129
|
});
|
|
110
130
|
console.info(chalk.rgb(...gray)(`Done for [${platform}] task`));
|
|
@@ -117,11 +137,11 @@ const buildPlatform = async (options, api, context) => {
|
|
|
117
137
|
errorMsg = String(e);
|
|
118
138
|
}
|
|
119
139
|
}
|
|
120
|
-
|
|
140
|
+
yield runner.afterBuildPlatform({
|
|
121
141
|
status: errorMsg === null ? "success" : "fail",
|
|
122
142
|
message: errorMsg
|
|
123
143
|
});
|
|
124
|
-
};
|
|
144
|
+
});
|
|
125
145
|
// Annotate the CommonJS export names for ESM import in node:
|
|
126
146
|
0 && (module.exports = {
|
|
127
147
|
buildPlatform
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":"
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIO,MAAM,gBAAgB,CAC3B,SACA,KACA,YACG;AACH,QAAM,EAAE,MAAM,IAAI,MAAM,6CAAO,kBAAkB;AACjD,QAAM,EAAE,MAAM,KAAK,IAAI,MAAM,6CAAO,qBAAqB;AACzD,QA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AA,IACb,OAAO;AACL,iBAAW,OAAO,CAAC;AAAA,IACrB;AAAA,EACF;AAEA,QAAM,OAAO,mBAAmB;AAAA,IAC9B,QAAQ,aAAa,OAAO,YAAY;AAAA,IACxC,SAAS;AAAA,EACX,CAAC;AACH;;;;;","names":[],"sources":["../../src/builder/platform.ts"],"sourcesContent":["import { PluginAPI } from '@modern-js/core';\nimport { ModuleContext } from '../types/context';\nimport { BuildCommandOptions, ModuleTools } from '../types';\n\nexport const buildPlatform = async (\n options: BuildCommandOptions,\n api: PluginAPI<ModuleTools>,\n context: ModuleContext,\n) => {\n const { chalk } = await import('@modern-js/utils');\n const { blue, gray } = await import('../constants/colors');\n const runner = api.useHookRunners();\n const platformBuilders = await runner.registerBuildPlatform();\n if (platformBuilders.length === 0) {\n if (options.platform === true) {\n console.info('No executable platform build tasks');\n } else if (\n Array.isArray(options.platform) &&\n options.platform.length === 1\n ) {\n console.info(\n `No build tasks with platform \"${options.platform[0]}\" found`,\n );\n } else if (Array.isArray(options.platform) && options.platform.length > 1) {\n console.info(\n `No build tasks with platform ${options.platform.join(',')} found`,\n );\n } else {\n console.info('Unknown platform', JSON.stringify(options.platform));\n }\n\n return;\n }\n\n await runner.beforeBuildPlatform(platformBuilders);\n let errorMsg: string | Error | null = null;\n try {\n if (options.platform === true) {\n for (const platformBuilder of platformBuilders) {\n const currentPlatform = Array.isArray(platformBuilder.platform)\n ? platformBuilder.platform[0]\n : platformBuilder.platform;\n\n console.info(\n chalk.underline.rgb(...blue)(\n `Running [${currentPlatform}] build task:`,\n ),\n );\n\n await runner.buildPlatform({ platform: currentPlatform });\n await platformBuilder.build(currentPlatform, {\n isTsProject: context.isTsProject,\n });\n\n console.info(chalk.rgb(...gray)(`Done for [${currentPlatform}] task`));\n }\n } else if (\n Array.isArray(options.platform) &&\n options.platform.length === 1\n ) {\n const targetPlatform = options.platform[0];\n const selectPlatformBuilder = platformBuilders.find(builder => {\n if (Array.isArray(builder.platform)) {\n return builder.platform.includes(targetPlatform);\n }\n\n return builder.platform === targetPlatform;\n });\n\n if (!selectPlatformBuilder) {\n console.info(`The specified \"${targetPlatform}\" build does not exist`);\n return;\n }\n\n console.info(\n chalk.underline.rgb(...blue)(`Running [${targetPlatform}] build task:`),\n );\n\n await runner.buildPlatform({ platform: targetPlatform });\n await selectPlatformBuilder.build(targetPlatform, {\n isTsProject: context.isTsProject,\n });\n\n console.info(chalk.rgb(...gray)(`Done for [${targetPlatform}] task`));\n } else if (Array.isArray(options.platform) && options.platform.length > 1) {\n for (const platform of options.platform) {\n const foundBuilder = platformBuilders.find(builder => {\n if (Array.isArray(builder.platform)) {\n return builder.platform.includes(platform);\n }\n\n return builder.platform === platform;\n });\n\n if (!foundBuilder) {\n console.info(`skip ${platform} build, because it does not exist`);\n continue;\n }\n\n console.info(\n chalk.underline.rgb(...blue)(`Running [${platform}] build task:`),\n );\n\n await runner.buildPlatform({ platform });\n await foundBuilder.build(platform, {\n isTsProject: context.isTsProject,\n });\n\n console.info(chalk.rgb(...gray)(`Done for [${platform}] task`));\n }\n }\n } catch (e) {\n if (e instanceof Error) {\n errorMsg = e;\n } else {\n errorMsg = String(e);\n }\n }\n\n await runner.afterBuildPlatform({\n status: errorMsg === null ? 'success' : 'fail',\n message: errorMsg,\n });\n};\n"]}
|
package/dist/cli.js
CHANGED
|
@@ -25,6 +25,26 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
25
25
|
mod
|
|
26
26
|
));
|
|
27
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var __async = (__this, __arguments, generator) => {
|
|
29
|
+
return new Promise((resolve, reject) => {
|
|
30
|
+
var fulfilled = (value) => {
|
|
31
|
+
try {
|
|
32
|
+
step(generator.next(value));
|
|
33
|
+
} catch (e) {
|
|
34
|
+
reject(e);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
var rejected = (value) => {
|
|
38
|
+
try {
|
|
39
|
+
step(generator.throw(value));
|
|
40
|
+
} catch (e) {
|
|
41
|
+
reject(e);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
45
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
46
|
+
});
|
|
47
|
+
};
|
|
28
48
|
var cli_exports = {};
|
|
29
49
|
__export(cli_exports, {
|
|
30
50
|
cli: () => cli
|
|
@@ -38,39 +58,41 @@ const cli = () => ({
|
|
|
38
58
|
usePlugins: (0, import_plugins.getPlugins)(process.argv.slice(2)[0]),
|
|
39
59
|
setup
|
|
40
60
|
});
|
|
41
|
-
const setup =
|
|
42
|
-
const prepare =
|
|
43
|
-
const { initLocalLanguage } =
|
|
44
|
-
|
|
61
|
+
const setup = (api) => __async(void 0, null, function* () {
|
|
62
|
+
const prepare = () => __async(void 0, null, function* () {
|
|
63
|
+
const { initLocalLanguage } = yield Promise.resolve().then(() => __toESM(require("./utils/language")));
|
|
64
|
+
yield initLocalLanguage();
|
|
45
65
|
const appContext = api.useAppContext();
|
|
46
|
-
const { fs, dotenv } =
|
|
66
|
+
const { fs, dotenv } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
47
67
|
dotenv.config();
|
|
48
|
-
|
|
68
|
+
yield fs.emptydir(appContext.internalDirectory);
|
|
49
69
|
const hookRunners = api.useHookRunners();
|
|
50
|
-
|
|
51
|
-
const { addExitListener } =
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
});
|
|
55
|
-
};
|
|
56
|
-
const validateSchema =
|
|
57
|
-
const { schema, legacySchema } =
|
|
58
|
-
const { isLegacyUserConfig } =
|
|
70
|
+
yield hookRunners.addRuntimeExports();
|
|
71
|
+
const { addExitListener } = yield Promise.resolve().then(() => __toESM(require("./utils/onExit")));
|
|
72
|
+
yield addExitListener(() => __async(void 0, null, function* () {
|
|
73
|
+
yield hookRunners.afterDev();
|
|
74
|
+
}));
|
|
75
|
+
});
|
|
76
|
+
const validateSchema = () => __async(void 0, null, function* () {
|
|
77
|
+
const { schema, legacySchema } = yield Promise.resolve().then(() => __toESM(require("./config/schema")));
|
|
78
|
+
const { isLegacyUserConfig } = yield Promise.resolve().then(() => __toESM(require("./utils/config")));
|
|
59
79
|
const userConfig = api.useConfigContext();
|
|
60
80
|
return isLegacyUserConfig(userConfig) ? legacySchema : schema;
|
|
61
|
-
};
|
|
81
|
+
});
|
|
62
82
|
return {
|
|
63
83
|
prepare,
|
|
64
84
|
validateSchema,
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
85
|
+
commands(_0) {
|
|
86
|
+
return __async(this, arguments, function* ({ program }) {
|
|
87
|
+
const { buildCommand, devCommand, newCommand, upgradCommand } = yield Promise.resolve().then(() => __toESM(require("./command")));
|
|
88
|
+
yield buildCommand(program, api);
|
|
89
|
+
yield devCommand(program, api);
|
|
90
|
+
yield newCommand(program);
|
|
91
|
+
yield upgradCommand(program);
|
|
92
|
+
});
|
|
71
93
|
}
|
|
72
94
|
};
|
|
73
|
-
};
|
|
95
|
+
});
|
|
74
96
|
// Annotate the CommonJS export names for ESM import in node:
|
|
75
97
|
0 && (module.exports = {
|
|
76
98
|
cli
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":"
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAA6B;AAC7B,qBAA2B;AAEpB,MAAM,MAAM,OAA+B;AAAA,EAChD,MAAM;AAAA,EACN;AAAA,EACA,gBAAY,2BAAW,QAAQ,KAAK,MAAM,CAAC,EAAE,CAAC,CAAC;AAAA,EAC/C;AACF;AAEA,MAAM,QAAyC,CAAM,QAAO;AAC1D,QAAM,UAAU,MAAY;AAC1B,UAAM,EAAE,kBAAkB,IAAI,MAAM,6CAAO,kBAAkB;AAC7D,UAAM,kBAAkB;AAExB,UAAM,aAAa,IAAI,cAAc;AACrC,UAAM,EAAE,IAAI,OAAO,IAAI,MAAM,6CAAO,kBAAkB;AACtD,WAAO,OAAO;AAEd,UAAM,GAAG,SAAS,WAAW,iBAAiB;AAE9C,UAAM,cAAc,IAAI,eAAe;AACvC,UAAM,YAAY,kBAAkB;AAEpC,UAAM,EAAE,gBAAgB,IAAI,MAAM,6CAAO,gBAAgB;AACzD,UAAM,gBAAgB,MAAY;AAChC,YAAM,YAAY,SAAS;AAAA,IAC7B,EAAC;AAAA,EACH;AAEA,QAAM,iBAAiB,MAAY;AACjC,UAAM,EAAE,QAAQ,aAAa,IAAI,MAAM,6CAAO,iBAAiB;AAC/D,UAAM,EAAE,mBAAmB,IAAI,MAAM,6CAAO,gBAAgB;AAC5D,UAAM,aAAa,IAAI,iBAAiB;AACxC,WAAO,mBAAmB,UAAkC,IACxD,eACA;AAAA,EACN;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACM,SAAS,IAAa;AAAA,iDAAb,EAAE,QAAQ,GAAG;AAC1B,cAAM,EAAE,cAAc,YAAY,YAAY,cAAc,IAC1D,MAAM,6CAAO,WAAW;AAC1B,cAAM,aAAa,SAAS,GAAG;AAC/B,cAAM,WAAW,SAAS,GAAG;AAC7B,cAAM,WAAW,OAAO;AACxB,cAAM,cAAc,OAAO;AAAA,MAC7B;AAAA;AAAA,EACF;AACF;;;;;","names":[],"sources":["../src/cli.ts"],"sourcesContent":["import type { CliPlugin } from '@modern-js/core';\nimport type { ModuleTools } from './types';\nimport { registerHook } from './hooks';\nimport { getPlugins } from './plugins';\n\nexport const cli = (): CliPlugin<ModuleTools> => ({\n name: '@modern-js/module-tools',\n registerHook,\n usePlugins: getPlugins(process.argv.slice(2)[0]),\n setup,\n});\n\nconst setup: CliPlugin<ModuleTools>['setup'] = async api => {\n const prepare = async () => {\n const { initLocalLanguage } = await import('./utils/language');\n await initLocalLanguage();\n\n const appContext = api.useAppContext();\n const { fs, dotenv } = await import('@modern-js/utils');\n dotenv.config();\n // remove '/node_modules/.modern-js'\n await fs.emptydir(appContext.internalDirectory);\n\n const hookRunners = api.useHookRunners();\n await hookRunners.addRuntimeExports();\n\n const { addExitListener } = await import('./utils/onExit');\n await addExitListener(async () => {\n await hookRunners.afterDev();\n });\n };\n\n const validateSchema = async () => {\n const { schema, legacySchema } = await import('./config/schema');\n const { isLegacyUserConfig } = await import('./utils/config');\n const userConfig = api.useConfigContext();\n return isLegacyUserConfig(userConfig as { legacy?: boolean })\n ? legacySchema\n : schema;\n };\n\n return {\n prepare,\n validateSchema,\n async commands({ program }) {\n const { buildCommand, devCommand, newCommand, upgradCommand } =\n await import('./command');\n await buildCommand(program, api);\n await devCommand(program, api);\n await newCommand(program);\n await upgradCommand(program);\n },\n };\n};\n"]}
|