@modern-js/module-tools 2.35.1 → 2.37.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/dist/build.js +43 -16
- package/dist/builder/build.d.ts +0 -10
- package/dist/builder/build.js +96 -208
- package/dist/builder/clear.d.ts +1 -4
- package/dist/builder/clear.js +32 -28
- package/dist/builder/copy.js +75 -60
- package/dist/builder/dts/index.js +27 -19
- package/dist/builder/dts/rollup.d.ts +6 -14
- package/dist/builder/dts/rollup.js +60 -37
- package/dist/builder/dts/tsc.d.ts +3 -2
- package/dist/builder/dts/tsc.js +50 -37
- package/dist/builder/esbuild/adapter.d.ts +3 -0
- package/dist/builder/esbuild/adapter.js +286 -0
- package/dist/builder/esbuild/hook.d.ts +4 -0
- package/dist/builder/esbuild/hook.js +103 -0
- package/dist/builder/esbuild/index.d.ts +35 -0
- package/dist/builder/esbuild/index.js +268 -0
- package/dist/builder/esbuild/resolve.d.ts +18 -0
- package/dist/builder/esbuild/resolve.js +140 -0
- package/dist/builder/esbuild/sourcemap.d.ts +16 -0
- package/dist/builder/esbuild/sourcemap.js +86 -0
- package/dist/builder/esbuild/transform.d.ts +7 -0
- package/dist/builder/esbuild/transform.js +45 -0
- package/dist/builder/esbuild/watch.d.ts +2 -0
- package/dist/builder/esbuild/watch.js +115 -0
- package/dist/builder/esbuild/write-file.d.ts +2 -0
- package/dist/builder/esbuild/write-file.js +89 -0
- package/dist/builder/feature/asset.d.ts +19 -0
- package/dist/builder/feature/asset.js +149 -0
- package/dist/builder/feature/format-cjs.d.ts +5 -0
- package/dist/builder/feature/format-cjs.js +53 -0
- package/dist/builder/feature/index.d.ts +2 -0
- package/dist/builder/feature/index.js +74 -0
- package/dist/builder/feature/json.d.ts +5 -0
- package/dist/builder/feature/json.js +47 -0
- package/dist/builder/feature/redirect.d.ts +5 -0
- package/dist/builder/feature/redirect.js +223 -0
- package/dist/builder/feature/style/index.d.ts +5 -0
- package/dist/builder/feature/style/index.js +94 -0
- package/dist/builder/feature/style/lessAliasPlugin.d.ts +12 -0
- package/dist/builder/feature/style/lessAliasPlugin.js +70 -0
- package/dist/builder/feature/style/lessRender.d.ts +2 -0
- package/dist/builder/feature/style/lessRender.js +64 -0
- package/dist/builder/feature/style/postcssTransformer.d.ts +6 -0
- package/dist/builder/feature/style/postcssTransformer.js +95 -0
- package/dist/builder/feature/style/postcssUrlPlugin.d.ts +6 -0
- package/dist/builder/feature/style/postcssUrlPlugin.js +58 -0
- package/dist/builder/feature/style/sassRender.d.ts +2 -0
- package/dist/builder/feature/style/sassRender.js +85 -0
- package/dist/builder/feature/style/transformStyle.d.ts +13 -0
- package/dist/builder/feature/style/transformStyle.js +101 -0
- package/dist/builder/feature/style/utils.d.ts +18 -0
- package/dist/builder/feature/style/utils.js +130 -0
- package/dist/builder/feature/swc.d.ts +9 -0
- package/dist/builder/feature/swc.js +170 -0
- package/dist/builder/feature/terser.d.ts +5 -0
- package/dist/builder/feature/terser.js +83 -0
- package/dist/builder/index.js +59 -28
- package/dist/builder/platform.js +38 -23
- package/dist/cli.js +58 -29
- package/dist/command.js +62 -38
- package/dist/config/defineConfig.js +25 -17
- package/dist/config/legacySchema.js +35 -32
- package/dist/config/merge.js +69 -36
- package/dist/config/normalize.js +63 -46
- package/dist/config/schema.d.ts +48 -0
- package/dist/config/schema.js +53 -34
- package/dist/config/transformLegacyConfig.js +67 -61
- package/dist/config/valid.d.ts +2 -2
- package/dist/config/valid.js +44 -21
- package/dist/constants/build.d.ts +5 -1
- package/dist/constants/build.js +88 -46
- package/dist/constants/color.js +27 -20
- package/dist/constants/dts.js +27 -20
- package/dist/constants/file.d.ts +2 -2
- package/dist/constants/file.js +48 -25
- package/dist/constants/legacy-preset.js +45 -32
- package/dist/constants/loader.d.ts +2 -0
- package/dist/constants/loader.js +53 -0
- package/dist/constants/log.d.ts +0 -8
- package/dist/constants/log.js +27 -41
- package/dist/constants/preset.d.ts +4 -4
- package/dist/constants/preset.js +55 -62
- package/dist/debug.d.ts +4 -0
- package/dist/debug.js +37 -0
- package/dist/dev.js +42 -25
- package/dist/error.js +49 -42
- package/dist/hooks/build.d.ts +1 -2
- package/dist/hooks/build.js +36 -28
- package/dist/hooks/dev.js +32 -17
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/index.js +31 -16
- package/dist/hooks/misc.d.ts +5 -2
- package/dist/hooks/misc.js +31 -12
- package/dist/index.d.ts +2 -1
- package/dist/index.js +39 -32
- package/dist/locale/en.js +32 -17
- package/dist/locale/index.d.ts +2 -1
- package/dist/locale/index.js +31 -24
- package/dist/locale/zh.js +32 -17
- package/dist/plugins.js +28 -13
- package/dist/types/color.js +15 -5
- package/dist/types/command.d.ts +3 -3
- package/dist/types/command.js +15 -5
- package/dist/types/config/copy.js +15 -5
- package/dist/types/config/dev.js +15 -5
- package/dist/types/config/index.d.ts +87 -52
- package/dist/types/config/index.js +24 -6
- package/dist/types/config/style.d.ts +58 -6
- package/dist/types/config/style.js +15 -5
- package/dist/types/context.js +15 -5
- package/dist/types/dts.d.ts +14 -3
- package/dist/types/dts.js +15 -5
- package/dist/types/esbuild.d.ts +107 -0
- package/dist/types/esbuild.js +32 -0
- package/dist/types/hooks.js +15 -5
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +32 -11
- package/dist/types/legacyConfig/index.js +15 -5
- package/dist/types/legacyConfig/output.d.ts +4 -4
- package/dist/types/legacyConfig/output.js +15 -5
- package/dist/types/legacyConfig/source.js +15 -5
- package/dist/types/legacyConfig/tools.js +15 -5
- package/dist/utils/assert.d.ts +5 -0
- package/dist/utils/assert.js +50 -0
- package/dist/utils/builder.d.ts +10 -14
- package/dist/utils/builder.js +59 -59
- package/dist/utils/common.d.ts +1 -1
- package/dist/utils/common.js +25 -17
- package/dist/utils/dts.d.ts +26 -9
- package/dist/utils/dts.js +98 -64
- package/dist/utils/hash.d.ts +2 -0
- package/dist/utils/hash.js +31 -0
- package/dist/utils/index.d.ts +11 -0
- package/dist/utils/index.js +42 -0
- package/dist/utils/input.js +47 -24
- package/dist/utils/log.d.ts +1 -2
- package/dist/utils/log.js +36 -20
- package/dist/utils/map.d.ts +13 -0
- package/dist/utils/map.js +58 -0
- package/dist/utils/onExit.js +35 -11
- package/dist/utils/print.d.ts +2 -2
- package/dist/utils/print.js +52 -49
- package/dist/utils/style.d.ts +5 -23
- package/dist/utils/style.js +57 -37
- package/dist/utils/tspath.js +114 -0
- package/package.json +61 -50
- package/vitest.config.ts +20 -0
- package/dist/build.js.map +0 -1
- package/dist/builder/build.js.map +0 -1
- package/dist/builder/clear.js.map +0 -1
- package/dist/builder/copy.js.map +0 -1
- package/dist/builder/dts/index.js.map +0 -1
- package/dist/builder/dts/rollup.js.map +0 -1
- package/dist/builder/dts/tsc.js.map +0 -1
- package/dist/builder/index.js.map +0 -1
- package/dist/builder/platform.js.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/command.js.map +0 -1
- package/dist/config/defineConfig.js.map +0 -1
- package/dist/config/legacySchema.js.map +0 -1
- package/dist/config/merge.js.map +0 -1
- package/dist/config/normalize.js.map +0 -1
- package/dist/config/schema.js.map +0 -1
- package/dist/config/transformLegacyConfig.js.map +0 -1
- package/dist/config/valid.js.map +0 -1
- package/dist/constants/build.js.map +0 -1
- package/dist/constants/color.js.map +0 -1
- package/dist/constants/dts.js.map +0 -1
- package/dist/constants/file.js.map +0 -1
- package/dist/constants/legacy-preset.js.map +0 -1
- package/dist/constants/log.js.map +0 -1
- package/dist/constants/preset.js.map +0 -1
- package/dist/dev.js.map +0 -1
- package/dist/error.js.map +0 -1
- package/dist/hooks/build.js.map +0 -1
- package/dist/hooks/dev.js.map +0 -1
- package/dist/hooks/index.js.map +0 -1
- package/dist/hooks/misc.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/locale/en.js.map +0 -1
- package/dist/locale/index.js.map +0 -1
- package/dist/locale/zh.js.map +0 -1
- package/dist/plugins.js.map +0 -1
- package/dist/types/color.js.map +0 -1
- package/dist/types/command.js.map +0 -1
- package/dist/types/config/copy.js.map +0 -1
- package/dist/types/config/dev.js.map +0 -1
- package/dist/types/config/index.js.map +0 -1
- package/dist/types/config/style.js.map +0 -1
- package/dist/types/context.js.map +0 -1
- package/dist/types/dts.js.map +0 -1
- package/dist/types/hooks.js.map +0 -1
- package/dist/types/index.js.map +0 -1
- package/dist/types/legacyConfig/index.js.map +0 -1
- package/dist/types/legacyConfig/output.js.map +0 -1
- package/dist/types/legacyConfig/source.js.map +0 -1
- package/dist/types/legacyConfig/tools.js.map +0 -1
- package/dist/types/utils.d.ts +0 -5
- package/dist/types/utils.js +0 -4
- package/dist/utils/builder.js.map +0 -1
- package/dist/utils/common.js.map +0 -1
- package/dist/utils/context.d.ts +0 -7
- package/dist/utils/context.js +0 -23
- package/dist/utils/context.js.map +0 -1
- package/dist/utils/dts.js.map +0 -1
- package/dist/utils/input.js.map +0 -1
- package/dist/utils/language.d.ts +0 -1
- package/dist/utils/language.js +0 -22
- package/dist/utils/language.js.map +0 -1
- package/dist/utils/libuild-plugin.d.ts +0 -3
- package/dist/utils/libuild-plugin.js +0 -31
- package/dist/utils/libuild-plugin.js.map +0 -1
- package/dist/utils/log.js.map +0 -1
- package/dist/utils/onExit.js.map +0 -1
- package/dist/utils/path.d.ts +0 -1
- package/dist/utils/path.js +0 -19
- package/dist/utils/path.js.map +0 -1
- package/dist/utils/print.js.map +0 -1
- package/dist/utils/style.js.map +0 -1
- package/dist/utils/tspathsTransform.js +0 -91
- package/dist/utils/tspathsTransform.js.map +0 -1
- /package/dist/utils/{tspathsTransform.d.ts → tspath.d.ts} +0 -0
package/dist/builder/index.js
CHANGED
|
@@ -1,20 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
9
17
|
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var builder_exports = {};
|
|
30
|
+
__export(builder_exports, {
|
|
31
|
+
run: () => run
|
|
10
32
|
});
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
33
|
+
module.exports = __toCommonJS(builder_exports);
|
|
34
|
+
var import_os = __toESM(require("os"));
|
|
35
|
+
var import_utils = require("@modern-js/utils");
|
|
36
|
+
var import_p_map = __toESM(require("../../compiled/p-map"));
|
|
37
|
+
var import_debug = require("../debug");
|
|
38
|
+
var import_build = require("./build");
|
|
39
|
+
var import_clear = require("./clear");
|
|
18
40
|
const run = async (options, api) => {
|
|
19
41
|
const { resolvedBuildConfig, context, cmdOptions } = options;
|
|
20
42
|
const { watch, clear } = cmdOptions;
|
|
@@ -22,31 +44,36 @@ const run = async (options, api) => {
|
|
|
22
44
|
let totalDuration = 0;
|
|
23
45
|
if (resolvedBuildConfig.length !== 0) {
|
|
24
46
|
totalDuration = Date.now();
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
47
|
+
if (clear) {
|
|
48
|
+
(0, import_debug.debug)("clear output paths");
|
|
49
|
+
await (0, import_clear.clearBuildConfigPaths)(resolvedBuildConfig, context.appDirectory);
|
|
50
|
+
(0, import_debug.debug)("clear output paths done");
|
|
51
|
+
}
|
|
52
|
+
await (0, import_clear.clearDtsTemp)();
|
|
30
53
|
if (watch) {
|
|
31
|
-
|
|
54
|
+
import_utils.logger.info("Start build in watch mode...");
|
|
32
55
|
}
|
|
33
56
|
try {
|
|
34
|
-
await (0,
|
|
57
|
+
await (0, import_p_map.default)(resolvedBuildConfig, async (config) => {
|
|
58
|
+
(0, import_debug.debug)("run beforeBuildTask hooks");
|
|
35
59
|
const buildConfig = await runner.beforeBuildTask(config);
|
|
36
|
-
|
|
60
|
+
(0, import_debug.debug)("run beforeBuildTask hooks done");
|
|
61
|
+
await (0, import_build.runBuildTask)({
|
|
37
62
|
buildConfig,
|
|
38
63
|
buildCmdOptions: cmdOptions,
|
|
39
64
|
context
|
|
40
65
|
}, api);
|
|
66
|
+
(0, import_debug.debug)("run afterBuildTask hooks");
|
|
41
67
|
await runner.afterBuildTask({
|
|
42
68
|
status: "success",
|
|
43
69
|
config
|
|
44
70
|
});
|
|
71
|
+
(0, import_debug.debug)("run afterBuildTask hooks done");
|
|
45
72
|
}, {
|
|
46
|
-
concurrency:
|
|
73
|
+
concurrency: import_os.default.cpus().length
|
|
47
74
|
});
|
|
48
75
|
} catch (e) {
|
|
49
|
-
const { isInternalError, ModuleBuildError } = await Promise.resolve().then(() =>
|
|
76
|
+
const { isInternalError, ModuleBuildError } = await Promise.resolve().then(() => __toESM(require("../error")));
|
|
50
77
|
if (isInternalError(e)) {
|
|
51
78
|
throw new ModuleBuildError(e);
|
|
52
79
|
} else {
|
|
@@ -55,19 +82,23 @@ const run = async (options, api) => {
|
|
|
55
82
|
}
|
|
56
83
|
totalDuration = Date.now() - totalDuration;
|
|
57
84
|
if (!watch) {
|
|
58
|
-
const { printFileSize, printSucceed } = await Promise.resolve().then(() =>
|
|
85
|
+
const { printFileSize, printSucceed } = await Promise.resolve().then(() => __toESM(require("../utils/print")));
|
|
59
86
|
printSucceed(totalDuration);
|
|
60
87
|
printFileSize();
|
|
61
88
|
}
|
|
62
89
|
} else {
|
|
63
|
-
|
|
90
|
+
import_utils.logger.warn(import_utils.chalk.yellow(`No build configuration found! Please configure \`buildConfig\` or \`buildPreset\``));
|
|
64
91
|
}
|
|
92
|
+
(0, import_debug.debug)("run afterBuild hooks");
|
|
65
93
|
await runner.afterBuild({
|
|
66
94
|
status: "success",
|
|
67
95
|
config: resolvedBuildConfig,
|
|
68
96
|
commandOptions: cmdOptions,
|
|
69
97
|
totalDuration
|
|
70
98
|
});
|
|
99
|
+
(0, import_debug.debug)("run afterBuild hooks done");
|
|
71
100
|
};
|
|
72
|
-
|
|
73
|
-
|
|
101
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
102
|
+
0 && (module.exports = {
|
|
103
|
+
run
|
|
104
|
+
});
|
package/dist/builder/platform.js
CHANGED
|
@@ -1,27 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
9
15
|
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var platform_exports = {};
|
|
20
|
+
__export(platform_exports, {
|
|
21
|
+
buildPlatform: () => buildPlatform
|
|
10
22
|
});
|
|
11
|
-
|
|
12
|
-
|
|
23
|
+
module.exports = __toCommonJS(platform_exports);
|
|
24
|
+
var import_utils = require("@modern-js/utils");
|
|
25
|
+
var import_color = require("../constants/color");
|
|
13
26
|
const buildPlatform = async (options, api, context) => {
|
|
14
27
|
const runner = api.useHookRunners();
|
|
15
28
|
const platformBuilders = await runner.registerBuildPlatform();
|
|
16
29
|
if (platformBuilders.length === 0) {
|
|
17
30
|
if (options.platform === true) {
|
|
18
|
-
|
|
31
|
+
import_utils.logger.info("No executable platform build tasks");
|
|
19
32
|
} else if (Array.isArray(options.platform) && options.platform.length === 1) {
|
|
20
|
-
|
|
33
|
+
import_utils.logger.info(`No build tasks with platform "${options.platform[0]}" found`);
|
|
21
34
|
} else if (Array.isArray(options.platform) && options.platform.length > 1) {
|
|
22
|
-
|
|
35
|
+
import_utils.logger.info(`No build tasks with platform ${options.platform.join(",")} found`);
|
|
23
36
|
} else {
|
|
24
|
-
|
|
37
|
+
import_utils.logger.info("Unknown platform", JSON.stringify(options.platform));
|
|
25
38
|
}
|
|
26
39
|
return;
|
|
27
40
|
}
|
|
@@ -31,14 +44,14 @@ const buildPlatform = async (options, api, context) => {
|
|
|
31
44
|
if (options.platform === true) {
|
|
32
45
|
for (const platformBuilder of platformBuilders) {
|
|
33
46
|
const currentPlatform = Array.isArray(platformBuilder.platform) ? platformBuilder.platform[0] : platformBuilder.platform;
|
|
34
|
-
|
|
47
|
+
import_utils.logger.info(import_utils.chalk.underline.rgb(...import_color.blue)(`Running [${currentPlatform}] build task:`));
|
|
35
48
|
await runner.buildPlatform({
|
|
36
49
|
platform: currentPlatform
|
|
37
50
|
});
|
|
38
51
|
await platformBuilder.build(currentPlatform, {
|
|
39
52
|
isTsProject: context.isTsProject
|
|
40
53
|
});
|
|
41
|
-
|
|
54
|
+
import_utils.logger.info(import_utils.chalk.rgb(...import_color.gray)(`Done for [${currentPlatform}] task`));
|
|
42
55
|
}
|
|
43
56
|
} else if (Array.isArray(options.platform) && options.platform.length === 1) {
|
|
44
57
|
const targetPlatform = options.platform[0];
|
|
@@ -49,17 +62,17 @@ const buildPlatform = async (options, api, context) => {
|
|
|
49
62
|
return builder.platform === targetPlatform;
|
|
50
63
|
});
|
|
51
64
|
if (!selectPlatformBuilder) {
|
|
52
|
-
|
|
65
|
+
import_utils.logger.info(`The specified "${targetPlatform}" build does not exist`);
|
|
53
66
|
return;
|
|
54
67
|
}
|
|
55
|
-
|
|
68
|
+
import_utils.logger.info(import_utils.chalk.underline.rgb(...import_color.blue)(`Running [${targetPlatform}] build task:`));
|
|
56
69
|
await runner.buildPlatform({
|
|
57
70
|
platform: targetPlatform
|
|
58
71
|
});
|
|
59
72
|
await selectPlatformBuilder.build(targetPlatform, {
|
|
60
73
|
isTsProject: context.isTsProject
|
|
61
74
|
});
|
|
62
|
-
|
|
75
|
+
import_utils.logger.info(import_utils.chalk.rgb(...import_color.gray)(`Done for [${targetPlatform}] task`));
|
|
63
76
|
} else if (Array.isArray(options.platform) && options.platform.length > 1) {
|
|
64
77
|
for (const platform of options.platform) {
|
|
65
78
|
const foundBuilder = platformBuilders.find((builder) => {
|
|
@@ -69,17 +82,17 @@ const buildPlatform = async (options, api, context) => {
|
|
|
69
82
|
return builder.platform === platform;
|
|
70
83
|
});
|
|
71
84
|
if (!foundBuilder) {
|
|
72
|
-
|
|
85
|
+
import_utils.logger.info(`skip ${platform} build, because it does not exist`);
|
|
73
86
|
continue;
|
|
74
87
|
}
|
|
75
|
-
|
|
88
|
+
import_utils.logger.info(import_utils.chalk.underline.rgb(...import_color.blue)(`Running [${platform}] build task:`));
|
|
76
89
|
await runner.buildPlatform({
|
|
77
90
|
platform
|
|
78
91
|
});
|
|
79
92
|
await foundBuilder.build(platform, {
|
|
80
93
|
isTsProject: context.isTsProject
|
|
81
94
|
});
|
|
82
|
-
|
|
95
|
+
import_utils.logger.info(import_utils.chalk.rgb(...import_color.gray)(`Done for [${platform}] task`));
|
|
83
96
|
}
|
|
84
97
|
}
|
|
85
98
|
} catch (e) {
|
|
@@ -94,5 +107,7 @@ const buildPlatform = async (options, api, context) => {
|
|
|
94
107
|
message: errorMsg
|
|
95
108
|
});
|
|
96
109
|
};
|
|
97
|
-
|
|
98
|
-
|
|
110
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
111
|
+
0 && (module.exports = {
|
|
112
|
+
buildPlatform
|
|
113
|
+
});
|
package/dist/cli.js
CHANGED
|
@@ -1,26 +1,48 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
9
17
|
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var cli_exports = {};
|
|
30
|
+
__export(cli_exports, {
|
|
31
|
+
moduleTools: () => moduleTools
|
|
10
32
|
});
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
33
|
+
module.exports = __toCommonJS(cli_exports);
|
|
34
|
+
var import_utils = require("@modern-js/utils");
|
|
35
|
+
var import_hooks = require("./hooks");
|
|
36
|
+
var import_plugins = require("./plugins");
|
|
37
|
+
var import_command = require("./command");
|
|
38
|
+
var import_merge = require("./config/merge");
|
|
39
|
+
var import_onExit = require("./utils/onExit");
|
|
40
|
+
var import_legacySchema = require("./config/legacySchema");
|
|
41
|
+
var import_schema = require("./config/schema");
|
|
20
42
|
const moduleTools = () => ({
|
|
21
43
|
name: "@modern-js/module-tools",
|
|
22
|
-
registerHook:
|
|
23
|
-
usePlugins: (0,
|
|
44
|
+
registerHook: import_hooks.registerHook,
|
|
45
|
+
usePlugins: (0, import_plugins.getPlugins)(process.argv.slice(2)[0]),
|
|
24
46
|
setup
|
|
25
47
|
});
|
|
26
48
|
const setup = async (api) => {
|
|
@@ -30,30 +52,37 @@ const setup = async (api) => {
|
|
|
30
52
|
toolsType: "module-tools"
|
|
31
53
|
});
|
|
32
54
|
const prepare = async () => {
|
|
33
|
-
await (
|
|
55
|
+
const local = await Promise.resolve().then(() => __toESM(require("./locale")));
|
|
56
|
+
const { getLocaleLanguage } = await Promise.resolve().then(() => __toESM(require("@modern-js/plugin-i18n/language-detector")));
|
|
57
|
+
const locale = getLocaleLanguage();
|
|
58
|
+
local.i18n.changeLanguage({
|
|
59
|
+
locale
|
|
60
|
+
});
|
|
34
61
|
const appContext2 = api.useAppContext();
|
|
35
|
-
|
|
36
|
-
await
|
|
62
|
+
import_utils.dotenv.config();
|
|
63
|
+
await import_utils.fs.emptydir(appContext2.internalDirectory);
|
|
37
64
|
const hookRunners = api.useHookRunners();
|
|
38
65
|
await hookRunners.addRuntimeExports();
|
|
39
|
-
await (0,
|
|
66
|
+
await (0, import_onExit.addExitListener)(async () => {
|
|
40
67
|
await hookRunners.afterDev();
|
|
41
68
|
});
|
|
42
69
|
};
|
|
43
70
|
const validateSchema = async () => {
|
|
44
71
|
const userConfig = api.useConfigContext();
|
|
45
|
-
return (0,
|
|
72
|
+
return (0, import_merge.isLegacyUserConfig)(userConfig) ? import_legacySchema.legacySchema : import_schema.schema;
|
|
46
73
|
};
|
|
47
74
|
return {
|
|
48
75
|
prepare,
|
|
49
76
|
validateSchema,
|
|
50
77
|
async commands({ program }) {
|
|
51
|
-
await (0,
|
|
52
|
-
await (0,
|
|
53
|
-
await (0,
|
|
54
|
-
await (0,
|
|
78
|
+
await (0, import_command.buildCommand)(program, api);
|
|
79
|
+
await (0, import_command.devCommand)(program, api);
|
|
80
|
+
await (0, import_command.newCommand)(program);
|
|
81
|
+
await (0, import_command.upgradeCommand)(program);
|
|
55
82
|
}
|
|
56
83
|
};
|
|
57
84
|
};
|
|
58
|
-
|
|
59
|
-
|
|
85
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
86
|
+
0 && (module.exports = {
|
|
87
|
+
moduleTools
|
|
88
|
+
});
|
package/dist/command.js
CHANGED
|
@@ -1,35 +1,54 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
6
9
|
for (var name in all)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return buildCommand;
|
|
15
|
-
},
|
|
16
|
-
devCommand: function() {
|
|
17
|
-
return devCommand;
|
|
18
|
-
},
|
|
19
|
-
newCommand: function() {
|
|
20
|
-
return newCommand;
|
|
21
|
-
},
|
|
22
|
-
upgradeCommand: function() {
|
|
23
|
-
return upgradeCommand;
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
24
17
|
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var command_exports = {};
|
|
30
|
+
__export(command_exports, {
|
|
31
|
+
buildCommand: () => buildCommand,
|
|
32
|
+
devCommand: () => devCommand,
|
|
33
|
+
newCommand: () => newCommand,
|
|
34
|
+
upgradeCommand: () => upgradeCommand
|
|
25
35
|
});
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const
|
|
36
|
+
module.exports = __toCommonJS(command_exports);
|
|
37
|
+
var import_locale = require("./locale");
|
|
38
|
+
const initModuleContext = async (api) => {
|
|
39
|
+
const { isTypescript } = await Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
40
|
+
const { appDirectory, srcDirectory } = api.useAppContext();
|
|
41
|
+
const isTsProject = isTypescript(appDirectory);
|
|
42
|
+
return {
|
|
43
|
+
isTsProject,
|
|
44
|
+
appDirectory,
|
|
45
|
+
srcDirectory
|
|
46
|
+
};
|
|
47
|
+
};
|
|
29
48
|
const buildCommand = async (program, api) => {
|
|
30
|
-
program.command("build").usage("[options]").description(
|
|
31
|
-
const context = await
|
|
32
|
-
const { build } = await Promise.resolve().then(() =>
|
|
49
|
+
program.command("build").usage("[options]").description(import_locale.i18n.t(import_locale.localeKeys.command.build.describe)).option("-w, --watch", import_locale.i18n.t(import_locale.localeKeys.command.build.watch), false).option("--tsconfig [tsconfig]", import_locale.i18n.t(import_locale.localeKeys.command.build.tsconfig)).option("-p, --platform [platform...]", import_locale.i18n.t(import_locale.localeKeys.command.build.platform)).option("--no-dts", import_locale.i18n.t(import_locale.localeKeys.command.build.dts)).option("--no-clear", import_locale.i18n.t(import_locale.localeKeys.command.build.noClear)).option("-c --config <config>", import_locale.i18n.t(import_locale.localeKeys.command.shared.config)).action(async (options) => {
|
|
50
|
+
const context = await initModuleContext(api);
|
|
51
|
+
const { build } = await Promise.resolve().then(() => __toESM(require("./build")));
|
|
33
52
|
await build(api, options, context);
|
|
34
53
|
});
|
|
35
54
|
};
|
|
@@ -37,9 +56,9 @@ const devCommand = async (program, api) => {
|
|
|
37
56
|
const runner = api.useHookRunners();
|
|
38
57
|
const devToolMetas = await runner.registerDev();
|
|
39
58
|
await runner.beforeDev(devToolMetas);
|
|
40
|
-
const devProgram = program.command("dev").usage("[options]").description(
|
|
41
|
-
const context = await
|
|
42
|
-
const { dev } = await Promise.resolve().then(() =>
|
|
59
|
+
const devProgram = program.command("dev").usage("[options]").description(import_locale.i18n.t(import_locale.localeKeys.command.dev.describe)).option("--tsconfig [tsconfig]", import_locale.i18n.t(import_locale.localeKeys.command.dev.tsconfig)).action(async (options) => {
|
|
60
|
+
const context = await initModuleContext(api);
|
|
61
|
+
const { dev } = await Promise.resolve().then(() => __toESM(require("./dev")));
|
|
43
62
|
await dev(options, devToolMetas, api, context);
|
|
44
63
|
});
|
|
45
64
|
for (const meta of devToolMetas) {
|
|
@@ -48,7 +67,7 @@ const devCommand = async (program, api) => {
|
|
|
48
67
|
}
|
|
49
68
|
for (const subCmd of meta.subCommands) {
|
|
50
69
|
devProgram.command(subCmd).action(async (options) => {
|
|
51
|
-
const context = await
|
|
70
|
+
const context = await initModuleContext(api);
|
|
52
71
|
await runner.beforeDevTask(meta);
|
|
53
72
|
await meta.action(options, {
|
|
54
73
|
isTsProject: context.isTsProject
|
|
@@ -58,9 +77,9 @@ const devCommand = async (program, api) => {
|
|
|
58
77
|
}
|
|
59
78
|
};
|
|
60
79
|
const newCommand = async (program) => {
|
|
61
|
-
program.command("new").usage("[options]").description(
|
|
62
|
-
const { ModuleNewAction } = await Promise.resolve().then(() =>
|
|
63
|
-
const { getLocaleLanguage } = await Promise.resolve().then(() =>
|
|
80
|
+
program.command("new").usage("[options]").description(import_locale.i18n.t(import_locale.localeKeys.command.new.describe)).option("--config-file <configFile>", import_locale.i18n.t(import_locale.localeKeys.command.shared.config)).option("--lang <lang>", import_locale.i18n.t(import_locale.localeKeys.command.new.lang)).option("-c, --config <config>", import_locale.i18n.t(import_locale.localeKeys.command.new.config)).option("-d, --debug", import_locale.i18n.t(import_locale.localeKeys.command.new.debug), false).option("--dist-tag <tag>", import_locale.i18n.t(import_locale.localeKeys.command.new.distTag)).option("--registry", import_locale.i18n.t(import_locale.localeKeys.command.new.registry)).option("--no-need-install", import_locale.i18n.t(import_locale.localeKeys.command.shared.noNeedInstall)).action(async (options) => {
|
|
81
|
+
const { ModuleNewAction } = await Promise.resolve().then(() => __toESM(require("@modern-js/new-action")));
|
|
82
|
+
const { getLocaleLanguage } = await Promise.resolve().then(() => __toESM(require("@modern-js/plugin-i18n/language-detector")));
|
|
64
83
|
const locale = getLocaleLanguage();
|
|
65
84
|
await ModuleNewAction({
|
|
66
85
|
...options,
|
|
@@ -69,8 +88,13 @@ const newCommand = async (program) => {
|
|
|
69
88
|
});
|
|
70
89
|
};
|
|
71
90
|
const upgradeCommand = async (program) => {
|
|
72
|
-
const { defineCommand } = await Promise.resolve().then(() =>
|
|
73
|
-
defineCommand(program.command("upgrade").option("-c --config <config>",
|
|
91
|
+
const { defineCommand } = await Promise.resolve().then(() => __toESM(require("@modern-js/upgrade")));
|
|
92
|
+
defineCommand(program.command("upgrade").option("-c --config <config>", import_locale.i18n.t(import_locale.localeKeys.command.shared.config)).option("--no-need-install", import_locale.i18n.t(import_locale.localeKeys.command.shared.noNeedInstall)));
|
|
74
93
|
};
|
|
75
|
-
|
|
76
|
-
|
|
94
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
95
|
+
0 && (module.exports = {
|
|
96
|
+
buildCommand,
|
|
97
|
+
devCommand,
|
|
98
|
+
newCommand,
|
|
99
|
+
upgradeCommand
|
|
100
|
+
});
|
|
@@ -1,27 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
6
7
|
for (var name in all)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return defineConfig;
|
|
15
|
-
},
|
|
16
|
-
defineLegacyConfig: function() {
|
|
17
|
-
return defineLegacyConfig;
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
15
|
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var defineConfig_exports = {};
|
|
20
|
+
__export(defineConfig_exports, {
|
|
21
|
+
defineConfig: () => defineConfig,
|
|
22
|
+
defineLegacyConfig: () => defineLegacyConfig
|
|
19
23
|
});
|
|
24
|
+
module.exports = __toCommonJS(defineConfig_exports);
|
|
20
25
|
const defineConfig = (config) => config;
|
|
21
26
|
const defineLegacyConfig = (config) => ({
|
|
22
27
|
...config,
|
|
23
28
|
legacy: true,
|
|
24
29
|
autoLoadPlugins: true
|
|
25
30
|
});
|
|
26
|
-
|
|
27
|
-
|
|
31
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
32
|
+
0 && (module.exports = {
|
|
33
|
+
defineConfig,
|
|
34
|
+
defineLegacyConfig
|
|
35
|
+
});
|
|
@@ -1,37 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
6
7
|
for (var name in all)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return targets;
|
|
15
|
-
},
|
|
16
|
-
presets: function() {
|
|
17
|
-
return presets;
|
|
18
|
-
},
|
|
19
|
-
buildSchema: function() {
|
|
20
|
-
return buildSchema;
|
|
21
|
-
},
|
|
22
|
-
outputSchema: function() {
|
|
23
|
-
return outputSchema;
|
|
24
|
-
},
|
|
25
|
-
sourceSchema: function() {
|
|
26
|
-
return sourceSchema;
|
|
27
|
-
},
|
|
28
|
-
toolsSchema: function() {
|
|
29
|
-
return toolsSchema;
|
|
30
|
-
},
|
|
31
|
-
legacySchema: function() {
|
|
32
|
-
return legacySchema;
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
33
15
|
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var legacySchema_exports = {};
|
|
20
|
+
__export(legacySchema_exports, {
|
|
21
|
+
buildSchema: () => buildSchema,
|
|
22
|
+
legacySchema: () => legacySchema,
|
|
23
|
+
outputSchema: () => outputSchema,
|
|
24
|
+
presets: () => presets,
|
|
25
|
+
sourceSchema: () => sourceSchema,
|
|
26
|
+
targets: () => targets,
|
|
27
|
+
toolsSchema: () => toolsSchema
|
|
34
28
|
});
|
|
29
|
+
module.exports = __toCommonJS(legacySchema_exports);
|
|
35
30
|
const targets = [
|
|
36
31
|
"es5",
|
|
37
32
|
"es6",
|
|
@@ -281,5 +276,13 @@ const legacySchema = [
|
|
|
281
276
|
...outputSchema,
|
|
282
277
|
...toolsSchema
|
|
283
278
|
];
|
|
284
|
-
|
|
285
|
-
|
|
279
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
280
|
+
0 && (module.exports = {
|
|
281
|
+
buildSchema,
|
|
282
|
+
legacySchema,
|
|
283
|
+
outputSchema,
|
|
284
|
+
presets,
|
|
285
|
+
sourceSchema,
|
|
286
|
+
targets,
|
|
287
|
+
toolsSchema
|
|
288
|
+
});
|