@modern-js/module-tools 2.35.1 → 2.36.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 +1 -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 +275 -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 +17 -0
- package/dist/builder/esbuild/resolve.js +125 -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 +217 -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 +124 -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.d.ts +1 -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.d.ts +1 -0
- package/dist/config/merge.js +69 -36
- package/dist/config/normalize.d.ts +1 -0
- 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.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 +64 -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/utils/style.js
CHANGED
|
@@ -1,44 +1,59 @@
|
|
|
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 getLessConfig;
|
|
15
|
-
},
|
|
16
|
-
getSassConfig: function() {
|
|
17
|
-
return getSassConfig;
|
|
18
|
-
},
|
|
19
|
-
getPostcssConfig: function() {
|
|
20
|
-
return getPostcssConfig;
|
|
21
|
-
},
|
|
22
|
-
getStyleConfig: function() {
|
|
23
|
-
return getStyleConfig;
|
|
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 style_exports = {};
|
|
30
|
+
__export(style_exports, {
|
|
31
|
+
getLessConfig: () => getLessConfig,
|
|
32
|
+
getPostcssConfig: () => getPostcssConfig,
|
|
33
|
+
getSassConfig: () => getSassConfig,
|
|
34
|
+
getStyleConfig: () => getStyleConfig
|
|
25
35
|
});
|
|
26
|
-
|
|
27
|
-
|
|
36
|
+
module.exports = __toCommonJS(style_exports);
|
|
37
|
+
var import_path = __toESM(require("path"));
|
|
38
|
+
var import_utils = require("@modern-js/utils");
|
|
39
|
+
const getCompiledPath = async (packageName) => {
|
|
40
|
+
const { slash } = await Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
41
|
+
return slash(import_path.default.join(__dirname, "../../compiled", packageName));
|
|
42
|
+
};
|
|
28
43
|
const getLessConfig = async (config) => {
|
|
29
44
|
var _config_style;
|
|
30
|
-
const mergedOptions = (0,
|
|
45
|
+
const mergedOptions = (0, import_utils.applyOptionsChain)({
|
|
31
46
|
lessOptions: {
|
|
32
47
|
javascriptEnabled: true
|
|
33
48
|
},
|
|
34
|
-
implementation: await
|
|
49
|
+
implementation: await getCompiledPath("less")
|
|
35
50
|
}, (config === null || config === void 0 ? void 0 : (_config_style = config.style) === null || _config_style === void 0 ? void 0 : _config_style.less) || {});
|
|
36
51
|
return mergedOptions;
|
|
37
52
|
};
|
|
38
53
|
const getSassConfig = async (config) => {
|
|
39
54
|
var _config_style;
|
|
40
|
-
const mergedOptions = (0,
|
|
41
|
-
implementation: await
|
|
55
|
+
const mergedOptions = (0, import_utils.applyOptionsChain)({
|
|
56
|
+
implementation: await getCompiledPath("sass")
|
|
42
57
|
}, (config === null || config === void 0 ? void 0 : (_config_style = config.style) === null || _config_style === void 0 ? void 0 : _config_style.sass) || {});
|
|
43
58
|
return mergedOptions;
|
|
44
59
|
};
|
|
@@ -56,19 +71,19 @@ const getPostcssConfig = async (config) => {
|
|
|
56
71
|
};
|
|
57
72
|
const targetLegacyBrowsers = config.target === "es5";
|
|
58
73
|
const getLegacyPostCSSPlugins = async () => [
|
|
59
|
-
require(await
|
|
60
|
-
require(await
|
|
61
|
-
require(await
|
|
62
|
-
require(await
|
|
74
|
+
require(await getCompiledPath("postcss-custom-properties")),
|
|
75
|
+
require(await getCompiledPath("postcss-initial")),
|
|
76
|
+
require(await getCompiledPath("postcss-page-break")),
|
|
77
|
+
require(await getCompiledPath("postcss-font-variant"))
|
|
63
78
|
];
|
|
64
|
-
const mergedConfig = (0,
|
|
79
|
+
const mergedConfig = (0, import_utils.applyOptionsChain)({
|
|
65
80
|
// TODO: when schema support redefine
|
|
66
81
|
// $$tools: 'module-tools',
|
|
67
82
|
plugins: [
|
|
68
83
|
...targetLegacyBrowsers ? await getLegacyPostCSSPlugins() : [],
|
|
69
|
-
require(await
|
|
70
|
-
require(await
|
|
71
|
-
require(await
|
|
84
|
+
require(await getCompiledPath("postcss-flexbugs-fixes")),
|
|
85
|
+
require(await getCompiledPath("postcss-media-minmax")),
|
|
86
|
+
require(await getCompiledPath("postcss-nesting"))
|
|
72
87
|
].filter(Boolean)
|
|
73
88
|
}, (config === null || config === void 0 ? void 0 : (_config_style = config.style) === null || _config_style === void 0 ? void 0 : _config_style.postcss) || {}, utils);
|
|
74
89
|
if (extraPlugins.length) {
|
|
@@ -86,5 +101,10 @@ const getStyleConfig = async (config) => {
|
|
|
86
101
|
postcss: postcssConfig
|
|
87
102
|
};
|
|
88
103
|
};
|
|
89
|
-
|
|
90
|
-
|
|
104
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
105
|
+
0 && (module.exports = {
|
|
106
|
+
getLessConfig,
|
|
107
|
+
getPostcssConfig,
|
|
108
|
+
getSassConfig,
|
|
109
|
+
getStyleConfig
|
|
110
|
+
});
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
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 });
|
|
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 tspath_exports = {};
|
|
30
|
+
__export(tspath_exports, {
|
|
31
|
+
transformDtsAlias: () => transformDtsAlias
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(tspath_exports);
|
|
34
|
+
var path = __toESM(require("path"));
|
|
35
|
+
var import_tsconfig_paths = require("@modern-js/utils/tsconfig-paths");
|
|
36
|
+
var import_utils = require("@modern-js/utils");
|
|
37
|
+
var parser = __toESM(require("@babel/parser"));
|
|
38
|
+
var import_generator = __toESM(require("@babel/generator"));
|
|
39
|
+
var t = __toESM(require("@babel/types"));
|
|
40
|
+
var import_traverse = __toESM(require("@babel/traverse"));
|
|
41
|
+
var import_file = require("../constants/file");
|
|
42
|
+
function mapPathString(nodePath, { filename, baseUrl, paths }) {
|
|
43
|
+
if (!t.isStringLiteral(nodePath)) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const sourcePath = nodePath.node.value;
|
|
47
|
+
const currentFile = filename;
|
|
48
|
+
const matchPath = (0, import_tsconfig_paths.createMatchPath)(baseUrl, paths, [
|
|
49
|
+
"index"
|
|
50
|
+
]);
|
|
51
|
+
const result = matchPath(sourcePath, (packageJsonPath) => {
|
|
52
|
+
if (!import_utils.fs.existsSync(packageJsonPath)) {
|
|
53
|
+
return void 0;
|
|
54
|
+
}
|
|
55
|
+
return import_utils.fs.readJSONSync(packageJsonPath);
|
|
56
|
+
}, (filePath) => import_utils.fs.existsSync(filePath), import_file.dtsAliasExts);
|
|
57
|
+
if (result) {
|
|
58
|
+
const relativePath = path.relative(path.dirname(currentFile), path.dirname(result));
|
|
59
|
+
const fileName = path.basename(result);
|
|
60
|
+
const filePath = path.normalize(`${relativePath.length === 0 ? "." : relativePath}/${fileName}`);
|
|
61
|
+
const replaceString = filePath.startsWith(".") ? filePath : `./${filePath}`;
|
|
62
|
+
nodePath.replaceWith(t.stringLiteral(replaceString));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const transformImport = (option) => (nodePath) => {
|
|
66
|
+
mapPathString(nodePath.get("source"), option);
|
|
67
|
+
};
|
|
68
|
+
const transformExport = (option) => (nodePath) => {
|
|
69
|
+
mapPathString(nodePath.get("source"), option);
|
|
70
|
+
};
|
|
71
|
+
const transformSingleFileAlias = ({ filename, baseUrl, paths }) => {
|
|
72
|
+
const sourceCode = import_utils.fs.readFileSync(filename, "utf-8");
|
|
73
|
+
const ast = parser.parse(sourceCode, {
|
|
74
|
+
sourceType: "module",
|
|
75
|
+
errorRecovery: true,
|
|
76
|
+
plugins: [
|
|
77
|
+
"typescript"
|
|
78
|
+
]
|
|
79
|
+
});
|
|
80
|
+
(0, import_traverse.default)(ast, {
|
|
81
|
+
// d.ts file content not have callExpression which can be parsed;
|
|
82
|
+
// CallExpression: transformCall({ filename, baseUrl, paths }) as any,
|
|
83
|
+
ImportDeclaration: transformImport({
|
|
84
|
+
filename,
|
|
85
|
+
baseUrl,
|
|
86
|
+
paths
|
|
87
|
+
}),
|
|
88
|
+
ExportDeclaration: transformExport({
|
|
89
|
+
filename,
|
|
90
|
+
baseUrl,
|
|
91
|
+
paths
|
|
92
|
+
})
|
|
93
|
+
});
|
|
94
|
+
return (0, import_generator.default)(ast).code;
|
|
95
|
+
};
|
|
96
|
+
const transformDtsAlias = (option) => {
|
|
97
|
+
const { filenames = [], baseUrl, paths } = option;
|
|
98
|
+
const transformResult = [];
|
|
99
|
+
for (const filename of filenames) {
|
|
100
|
+
transformResult.push({
|
|
101
|
+
path: filename,
|
|
102
|
+
content: transformSingleFileAlias({
|
|
103
|
+
filename,
|
|
104
|
+
baseUrl,
|
|
105
|
+
paths
|
|
106
|
+
})
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
return transformResult;
|
|
110
|
+
};
|
|
111
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
112
|
+
0 && (module.exports = {
|
|
113
|
+
transformDtsAlias
|
|
114
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modern-js/module-tools",
|
|
3
|
+
"version": "2.36.0",
|
|
3
4
|
"description": "Simple, powerful, high-performance modern npm package development solution.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"modern",
|
|
7
|
+
"modern.js",
|
|
8
|
+
"module-tools",
|
|
9
|
+
"lib-tools"
|
|
10
|
+
],
|
|
4
11
|
"homepage": "https://modernjs.dev/module-tools",
|
|
5
12
|
"bugs": "https://github.com/web-infra-dev/modern.js/issues",
|
|
6
13
|
"repository": {
|
|
@@ -9,19 +16,6 @@
|
|
|
9
16
|
"directory": "packages/solutions/module-tools"
|
|
10
17
|
},
|
|
11
18
|
"license": "MIT",
|
|
12
|
-
"keywords": [
|
|
13
|
-
"modern",
|
|
14
|
-
"modern.js",
|
|
15
|
-
"module-tools",
|
|
16
|
-
"lib-tools"
|
|
17
|
-
],
|
|
18
|
-
"version": "2.35.1",
|
|
19
|
-
"bin": {
|
|
20
|
-
"modern": "./bin/modern.js",
|
|
21
|
-
"modern-module": "./bin/modern.js"
|
|
22
|
-
},
|
|
23
|
-
"types": "./dist/index.d.ts",
|
|
24
|
-
"main": "./dist/index.js",
|
|
25
19
|
"exports": {
|
|
26
20
|
".": {
|
|
27
21
|
"jsnext:source": "./src/index.ts",
|
|
@@ -32,6 +26,8 @@
|
|
|
32
26
|
"default": "./dist/config/defineConfig.js"
|
|
33
27
|
}
|
|
34
28
|
},
|
|
29
|
+
"main": "./dist/index.js",
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
35
31
|
"typesVersions": {
|
|
36
32
|
"*": {
|
|
37
33
|
"types": [
|
|
@@ -45,64 +41,82 @@
|
|
|
45
41
|
]
|
|
46
42
|
}
|
|
47
43
|
},
|
|
48
|
-
"
|
|
49
|
-
"
|
|
44
|
+
"bin": {
|
|
45
|
+
"modern": "./bin/modern.js",
|
|
46
|
+
"modern-module": "./bin/modern.js"
|
|
50
47
|
},
|
|
51
48
|
"dependencies": {
|
|
52
|
-
"@
|
|
49
|
+
"@ampproject/remapping": "1.0.2",
|
|
50
|
+
"@ast-grep/napi": "0.12.0",
|
|
53
51
|
"@babel/generator": "^7.22.15",
|
|
52
|
+
"@babel/parser": "^7.22.15",
|
|
53
|
+
"@babel/traverse": "7.22.15",
|
|
54
54
|
"@babel/types": "^7.22.15",
|
|
55
|
-
"@
|
|
56
|
-
"
|
|
55
|
+
"@modern-js/swc-plugins": "0.6.4",
|
|
56
|
+
"@rollup/pluginutils": "4.1.1",
|
|
57
|
+
"@svgr/core": "8.0.0",
|
|
58
|
+
"@svgr/plugin-jsx": "8.0.1",
|
|
59
|
+
"@svgr/plugin-svgo": "8.0.1",
|
|
57
60
|
"@swc/helpers": "0.5.1",
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
61
|
+
"convert-source-map": "1.8.0",
|
|
62
|
+
"enhanced-resolve": "5.8.3",
|
|
63
|
+
"esbuild": "0.19.2",
|
|
64
|
+
"magic-string": "0.26.4",
|
|
65
|
+
"picomatch": "2.3.0",
|
|
66
|
+
"postcss": "8.4.31",
|
|
67
|
+
"postcss-modules": "4.3.0",
|
|
68
|
+
"safe-identifier": "0.4.2",
|
|
69
|
+
"source-map": "0.7.4",
|
|
70
|
+
"style-inject": "0.3.0",
|
|
71
|
+
"sucrase": "3.29.0",
|
|
72
|
+
"tapable": "2.2.1",
|
|
73
|
+
"terser": "5.19.2",
|
|
74
|
+
"tsconfig-paths-webpack-plugin": "4.1.0",
|
|
75
|
+
"@modern-js/core": "2.36.0",
|
|
76
|
+
"@modern-js/new-action": "2.36.0",
|
|
77
|
+
"@modern-js/types": "2.36.0",
|
|
78
|
+
"@modern-js/plugin": "2.36.0",
|
|
79
|
+
"@modern-js/plugin-changeset": "2.36.0",
|
|
80
|
+
"@modern-js/plugin-i18n": "2.36.0",
|
|
81
|
+
"@modern-js/plugin-lint": "2.36.0",
|
|
82
|
+
"@modern-js/upgrade": "2.36.0",
|
|
83
|
+
"@modern-js/utils": "2.36.0"
|
|
70
84
|
},
|
|
71
85
|
"devDependencies": {
|
|
72
86
|
"@types/babel__generator": "7.6.4",
|
|
73
87
|
"@types/babel__traverse": "7.18.5",
|
|
74
|
-
"@types/
|
|
75
|
-
"@types/
|
|
88
|
+
"@types/convert-source-map": "1.5.2",
|
|
89
|
+
"@types/mocha": "9.0.0",
|
|
76
90
|
"@types/node": "^14",
|
|
77
|
-
"
|
|
78
|
-
"fs-extra": "10.1.0",
|
|
79
|
-
"jest": "^29",
|
|
80
|
-
"path-browserify": "1.0.1",
|
|
81
|
-
"postcss-alias": "2.0.0",
|
|
82
|
-
"react": "^18",
|
|
91
|
+
"@types/picomatch": "2.3.0",
|
|
83
92
|
"typescript": "^5",
|
|
84
|
-
"@modern-js/
|
|
85
|
-
"@modern-js/
|
|
86
|
-
"@scripts/build": "2.
|
|
87
|
-
"@scripts/
|
|
93
|
+
"@modern-js/self": "npm:@modern-js/module-tools@2.36.0",
|
|
94
|
+
"@modern-js/builder-webpack-provider": "2.36.0",
|
|
95
|
+
"@scripts/build": "2.36.0",
|
|
96
|
+
"@scripts/vitest-config": "2.36.0"
|
|
88
97
|
},
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
"access": "public",
|
|
92
|
-
"provenance": true
|
|
98
|
+
"peerDependencies": {
|
|
99
|
+
"typescript": "^4 || ^5"
|
|
93
100
|
},
|
|
94
101
|
"peerDependenciesMeta": {
|
|
95
102
|
"typescript": {
|
|
96
103
|
"optional": true
|
|
97
104
|
}
|
|
98
105
|
},
|
|
99
|
-
"
|
|
100
|
-
"
|
|
106
|
+
"engines": {
|
|
107
|
+
"node": ">=14.0.0"
|
|
108
|
+
},
|
|
109
|
+
"publishConfig": {
|
|
110
|
+
"access": "public",
|
|
111
|
+
"provenance": true,
|
|
112
|
+
"registry": "https://registry.npmjs.org/"
|
|
101
113
|
},
|
|
102
114
|
"scripts": {
|
|
103
115
|
"build": "modern-lib build",
|
|
104
116
|
"dev": "modern-lib build --watch",
|
|
105
|
-
"
|
|
106
|
-
"
|
|
117
|
+
"new": "modern-lib new",
|
|
118
|
+
"test": "vitest run",
|
|
119
|
+
"test:ui": "vitest --ui",
|
|
120
|
+
"test:watch": "vitest dev --no-coverage"
|
|
107
121
|
}
|
|
108
122
|
}
|
package/vitest.config.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { defineConfig } from 'vitest/config';
|
|
2
|
+
import { withTestPreset } from '@scripts/vitest-config';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
|
|
5
|
+
const config = defineConfig({
|
|
6
|
+
resolve: {
|
|
7
|
+
alias: {
|
|
8
|
+
'~': path.resolve(__dirname),
|
|
9
|
+
'@': path.resolve(__dirname, 'src'),
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
test: {
|
|
13
|
+
root: __dirname,
|
|
14
|
+
environment: 'node',
|
|
15
|
+
globals: true,
|
|
16
|
+
includeSource: ['src/utils/*.ts'],
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
export default withTestPreset(config);
|
package/dist/build.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":";;;;+BAMaA;;;WAAAA;;;;uBALkB;AAG/B,MAAMC,SAAQC,0BAAe;AAEtB,MAAMF,QAAQ,OACnBG,KACAC,SACAC;AAEA,MAAID,QAAQE,UAAU;AACpB,UAAM,EAAEC,cAAa,IAAK,MAAM,iFAAO;AACvC,UAAMA,cAAcH,SAASD,KAAKE;AAClC;EACF;AAEA,QAAMG,SAASL,IAAIM,eAAc;AAEjC,QAAM,EAAEC,qBAAoB,IAAK,MAAM,iFAAO;AAC9C,QAAMC,sBAAsB,MAAMD,qBAAqBP,KAAKE,SAASD;AAErEH,QAAM,uBAAuBU;AAE7B,QAAMH,OAAOI,YAAY;IACvBC,QAAQF;IACRG,YAAYV;EACd;AACA,QAAMW,UAAU,MAAM,iFAAO;AAC7B,QAAMA,QAAQC,IAAI;IAAEC,YAAYb;IAASO;IAAqBN;EAAQ,GAAGF;AAC3E;","names":["build","debug","createDebugger","api","options","context","platform","buildPlatform","runner","useHookRunners","normalizeBuildConfig","resolvedBuildConfig","beforeBuild","config","cliOptions","builder","run","cmdOptions"],"sources":["../src/home/runner/work/modern.js/modern.js/packages/solutions/module-tools/src/build.ts"],"sourcesContent":["import type { PluginAPI } from '@modern-js/core';\nimport { createDebugger } from '@modern-js/utils';\nimport type { ModuleTools, ModuleContext, BuildCommandOptions } from './types';\n\nconst debug = createDebugger('module-tools');\n\nexport const build = async (\n api: PluginAPI<ModuleTools>,\n options: BuildCommandOptions,\n context: ModuleContext,\n) => {\n if (options.platform) {\n const { buildPlatform } = await import('./builder/platform');\n await buildPlatform(options, api, context);\n return;\n }\n\n const runner = api.useHookRunners();\n\n const { normalizeBuildConfig } = await import('./config/normalize');\n const resolvedBuildConfig = await normalizeBuildConfig(api, context, options);\n\n debug('resolvedBuildConfig', resolvedBuildConfig);\n\n await runner.beforeBuild({\n config: resolvedBuildConfig,\n cliOptions: options,\n });\n const builder = await import('./builder');\n await builder.run({ cmdOptions: options, resolvedBuildConfig, context }, api);\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":";;;;;;;;;;;;EAeaA,cAAY;WAAZA;;EAoBAC,kBAAgB;WAAhBA;;EAwBAC,kBAAgB;WAAhBA;;EAmBAC,cAAY;WAAZA;;EAqCAC,UAAQ;WAARA;;;;;sBAnHW;uBAEM;iEAUb;sBACQ;AAElB,MAAMJ,eAAe,OAC1BK,SAKAC;AAEA,QAAM,EAAEC,aAAaC,SAASC,gBAAe,IAAKJ;AAClD,QAAM,EAAEK,cAAcC,YAAW,IAAKH;AAEtC,SAAMI,mBAASL,aAAa;IAAEG;IAAcG,OAAOJ,gBAAgBI;EAAM;AAEzE,MAAIF,aAAa;AACf,UAAMV,iBAAiBI,SAASC;EAClC,OAAO;AACL,UAAMJ,iBAAiBG,SAASC;EAClC;AACF;AAEO,MAAML,mBAAmB,OAC9BI,SAKAC;AAEA,QAAM,EAAEC,aAAaE,gBAAe,IAAKJ;AACzC,QAAMS,MAAML,gBAAgBK,MAAMP,YAAYO,MAAM;AACpD,QAAMC,eAAeR,YAAYO,MAAMP,YAAYO,IAAIE,OAAO;MAChDP;AAAd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nC,UAAM,EAAEC,eAAc,IAAK,MAAM,iFAAO;AACxC,UAAMC,SAASnG,IAAIoG,eAAc;AACjC,UAAMC,sBAAsB,MAAMF,OAAOG,cAAcrG,aAAa;MAClEsG,QAAQC,OAAKA;IACf;AAEA,UAAMC,UAAU,MAAMR,UAAUS,OAAOL;AACvC,UAAMI,QAAQE,MAAK;AACnBT,mBAAeO,QAAQG,aAAaxD,MAAMnC,cAAc;AAExD,QAAIV,OAAO;AACT,YAAM,EAAEsG,kBAAiB,IAAK,MAAM,iFAAO;AAC3C,YAAM,EAAEC,mBAAkB,IAAK,MAAM,iFAAO;AAC5C,YAAMC,YAAY,IAChB9F,cAAc,WAAW,WAAW,iBACjCc,UAAUF;AAEfmF,oBAAOC,KACL,MAAMJ,kBAAkBE,WAAWD,mBAAmBI,OAAO;IAEjE;EACF,SAASC,GAAP;AACA,UAAM,EAAEC,mBAAkB,IAAK,MAAM,iFAAO;AAC5C,UAAM,IAAIA,mBAAmBD,GAAG;MAC9BtF;MACAE;MACAd;IACF;EACF;AACF;","names":["runBuildTask","buildInTsProject","buildInJsProject","generatorDts","buildLib","options","api","buildConfig","context","buildCmdOptions","appDirectory","isTsProject","copyTask","watch","dts","skipBuildLib","only","tasks","pMap","task","config","runRollup","runTsc","buildType","input","sourceDir","alias","externals","useAppContext","tsconfigPath","distPath","abortOnError","respectExternal","distDir","distAbsPath","target","sourceMap","format","outDir","asset","jsx","platform","splitting","minify","umdGlobals","umdModuleName","define","style","autoExternal","metafile","sideEffects","redirect","esbuildOptions","externalHelpers","transformImport","transformLodash","sourceType","disableSwcTransform","root","slash","outdir","assetOutDir","path","less","sass","postcss","inject","modules","autoModules","umdPlugin","swcTransformPlugin","transformPlugin","legacyTransformPlugin","es5Plugin","checkSwcHelpers","matchEs5PluginCondition","matchSwcTransformCondition","getProjectTsconfig","resolve","userTsconfig","plugins","tsTargetAtOrAboveES2022","tsUseDefineForClassFields","compilerOptions","useDefineForClassFields","tsTarget","toLowerCase","undefined","push","pluginImport","Boolean","emitDecoratorMetadata","jsc","transform","legacyDecorator","decoratorMetadata","svgr","svgrPlugin","watchPlugin","globals","external","bundle","outbase","Libuilder","addOutputChunk","runner","useHookRunners","modifiedBuildConfig","modifyLibuild","onLast","c","builder","create","build","outputChunk","watchSectionTitle","SectionTitleStatus","titleText","logger","info","Success","e","InternalBuildError"],"sources":["../../src/builder/home/runner/work/modern.js/modern.js/packages/solutions/module-tools/src/builder/build.ts"],"sourcesContent":["import { resolve } from 'path';\nimport type { CLIConfig } from '@modern-js/libuild';\nimport { slash, logger } from '@modern-js/utils';\nimport type {\n BuildCommandOptions,\n BaseBuildConfig,\n ModuleTools,\n PluginAPI,\n DTSOptions,\n ModuleContext,\n TsTarget,\n} from '../types';\nimport pMap from '../../compiled/p-map';\nimport { copyTask } from './copy';\n\nexport const runBuildTask = async (\n options: {\n buildConfig: BaseBuildConfig;\n buildCmdOptions: BuildCommandOptions;\n context: ModuleContext;\n },\n api: PluginAPI<ModuleTools>,\n) => {\n const { buildConfig, context, buildCmdOptions } = options;\n const { appDirectory, isTsProject } = context;\n\n await copyTask(buildConfig, { appDirectory, watch: buildCmdOptions.watch });\n\n if (isTsProject) {\n await buildInTsProject(options, api);\n } else {\n await buildInJsProject(options, api);\n }\n};\n\nexport const buildInTsProject = async (\n options: {\n buildConfig: BaseBuildConfig;\n buildCmdOptions: BuildCommandOptions;\n context: ModuleContext;\n },\n api: PluginAPI<ModuleTools>,\n) => {\n const { buildConfig, buildCmdOptions } = options;\n const dts = buildCmdOptions.dts ? buildConfig.dts : false;\n const skipBuildLib = buildConfig.dts ? buildConfig.dts.only : false;\n const watch = buildCmdOptions.watch ?? false;\n\n if (dts === false) {\n // --no-dts and buildConfig is `{ dts: { only: true } }`, then skip.\n !skipBuildLib && (await buildLib(buildConfig, api, { watch }));\n } else {\n const tasks = dts.only ? [generatorDts] : [buildLib, generatorDts];\n await pMap(tasks, async task => {\n await task(buildConfig, api as any, { watch, dts });\n });\n }\n};\n\nexport const buildInJsProject = async (\n options: {\n buildConfig: BaseBuildConfig;\n buildCmdOptions: BuildCommandOptions;\n context: ModuleContext;\n },\n api: PluginAPI<ModuleTools>,\n) => {\n const { buildConfig, buildCmdOptions } = options;\n const dts = buildCmdOptions.dts ? buildConfig.dts : false;\n const watch = buildCmdOptions.watch ?? false;\n\n if (dts !== false && dts.only) {\n return;\n }\n\n await buildLib(buildConfig, api, { watch });\n};\n\nexport const generatorDts = async (\n config: BaseBuildConfig,\n api: PluginAPI<ModuleTools>,\n options: {\n watch: boolean;\n dts: DTSOptions;\n },\n) => {\n const { runRollup, runTsc } = await import('./dts');\n const { watch, dts } = options;\n const { buildType, input, sourceDir, alias, externals } = config;\n const { appDirectory } = api.useAppContext();\n const { tsconfigPath, distPath, abortOnError, respectExternal } = dts;\n if (buildType === 'bundle') {\n await runRollup(api, {\n distDir: distPath,\n watch,\n externals,\n input,\n tsconfigPath,\n abortOnError,\n respectExternal,\n appDirectory,\n });\n } else {\n await runTsc(api, {\n appDirectory,\n alias,\n distAbsPath: distPath,\n watch,\n tsconfigPath,\n sourceDir,\n abortOnError,\n });\n }\n};\n\nexport const buildLib = async (\n config: BaseBuildConfig,\n api: PluginAPI<ModuleTools>,\n options: {\n watch: boolean;\n },\n) => {\n const { watch } = options;\n const {\n target,\n buildType,\n sourceMap,\n format,\n outDir: distPath,\n asset,\n jsx,\n input,\n platform,\n splitting,\n minify,\n sourceDir,\n umdGlobals,\n umdModuleName,\n define,\n alias,\n style,\n externals,\n autoExternal,\n dts,\n metafile,\n sideEffects,\n redirect,\n esbuildOptions,\n externalHelpers,\n transformImport,\n transformLodash,\n sourceType,\n disableSwcTransform,\n } = config;\n const { appDirectory } = api.useAppContext();\n const root = slash(appDirectory);\n const outdir = slash(distPath);\n const assetOutDir = asset.path ? slash(asset.path) : asset.path;\n const { less, sass, postcss, inject, modules, autoModules } = style;\n\n // support swc-transform, umd and emitDecoratorMetadata by swc\n const {\n umdPlugin,\n swcTransformPlugin,\n transformPlugin: legacyTransformPlugin,\n es5Plugin,\n } = await import('@modern-js/libuild-plugin-swc');\n const {\n checkSwcHelpers,\n matchEs5PluginCondition,\n matchSwcTransformCondition,\n } = await import('../utils/builder');\n\n const { getProjectTsconfig } = await import('../utils/dts');\n const tsconfigPath = dts\n ? dts.tsconfigPath\n : resolve(appDirectory, 'tsconfig.json');\n const userTsconfig = await getProjectTsconfig(tsconfigPath);\n\n const plugins = [];\n\n if (\n matchSwcTransformCondition({\n sourceType,\n buildType,\n format,\n disableSwcTransform,\n })\n ) {\n // TODO: refactor config plugins logic\n\n const { tsTargetAtOrAboveES2022 } = await import('../utils/dts');\n const tsUseDefineForClassFields =\n userTsconfig?.compilerOptions?.useDefineForClassFields;\n let tsTarget = userTsconfig?.compilerOptions?.target;\n tsTarget = tsTarget ? (tsTarget.toLowerCase() as TsTarget) : undefined;\n let useDefineForClassFields: boolean;\n if (tsUseDefineForClassFields !== undefined) {\n useDefineForClassFields = tsUseDefineForClassFields;\n } else if (tsTarget !== undefined) {\n useDefineForClassFields = tsTargetAtOrAboveES2022(tsTarget);\n } else {\n useDefineForClassFields = true;\n }\n\n plugins.push(\n swcTransformPlugin({\n pluginImport: transformImport,\n transformLodash,\n externalHelpers: Boolean(externalHelpers),\n emitDecoratorMetadata:\n userTsconfig?.compilerOptions?.emitDecoratorMetadata,\n useDefineForClassFields,\n }),\n );\n } else {\n if (\n matchEs5PluginCondition({\n sourceType,\n buildType,\n format,\n target,\n disableSwcTransform,\n })\n ) {\n plugins.push(es5Plugin());\n }\n\n if (userTsconfig?.compilerOptions?.emitDecoratorMetadata) {\n plugins.push(\n legacyTransformPlugin({\n jsc: {\n transform: {\n legacyDecorator: true,\n decoratorMetadata: true,\n },\n },\n }),\n );\n }\n }\n\n if (format === 'umd') {\n plugins.push(umdPlugin(umdModuleName));\n }\n\n await checkSwcHelpers({ appDirectory, externalHelpers });\n\n // support svgr\n if (asset.svgr) {\n const { svgrPlugin } = await import('@modern-js/libuild-plugin-svgr');\n const options = typeof asset.svgr === 'boolean' ? {} : asset.svgr;\n plugins.push(svgrPlugin(options));\n }\n\n // adapt module tools\n const { watchPlugin } = await import('../utils/libuild-plugin');\n plugins.push(watchPlugin(api, config));\n\n const buildConfig: CLIConfig = {\n root,\n watch,\n target,\n sourceMap,\n format,\n outdir,\n define,\n style: {\n less,\n sass,\n postcss,\n inject,\n modules,\n autoModules,\n },\n resolve: {\n alias,\n },\n asset: {\n ...asset,\n outdir: assetOutDir,\n },\n plugins,\n jsx,\n input,\n platform,\n splitting,\n minify,\n sourceDir,\n metafile: metafile && buildType === 'bundle',\n globals: umdGlobals,\n external: externals,\n autoExternal,\n redirect,\n bundle: buildType === 'bundle',\n sideEffects,\n // outbase for [dir]/[name]\n outbase: sourceDir,\n esbuildOptions,\n };\n\n try {\n const { Libuilder } = await import('@modern-js/libuild');\n const { addOutputChunk } = await import('../utils/print');\n const runner = api.useHookRunners();\n const modifiedBuildConfig = await runner.modifyLibuild(buildConfig, {\n onLast: c => c,\n });\n\n const builder = await Libuilder.create(modifiedBuildConfig);\n await builder.build();\n addOutputChunk(builder.outputChunk, root, buildType === 'bundle');\n\n if (watch) {\n const { watchSectionTitle } = await import('../utils/log');\n const { SectionTitleStatus } = await import('../constants/log');\n const titleText = `[${\n buildType === 'bundle' ? 'Bundle' : 'Bundleless'\n }: ${format}_${target}]`;\n\n logger.info(\n await watchSectionTitle(titleText, SectionTitleStatus.Success),\n );\n }\n } catch (e: any) {\n const { InternalBuildError } = await import('../error');\n throw new InternalBuildError(e, {\n target,\n format,\n buildType,\n });\n }\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":";;;;;;;;;;;;EAKaA,cAAY;WAAZA;;EAIAC,uBAAqB;WAArBA;;;uBATqB;wBAED;qBACA;AAE1B,MAAMD,eAAe;AAC1B,QAAME,UAAGC,OAAOC,qBAAgB;AAClC;AAEO,MAAMH,wBAAwB,OACnCI,SACAC;AAKA,QAAM,EAAEC,UAAU,OAAOC,qBAAqBC,QAAQC,IAAG,EAAE,IAAKJ,mDAAW,CAAC;AAE5E,MAAIC,SAAS;AACX;EACF;AAEA,aAAWI,UAAUN,SAAS;AAC5B,QAAIG,uBAAuBG,OAAOC,QAAQ;AACxCC,oBAAOC,KAAKC,aAAMC,eAAeC,aAAKC,EAAEC,mBAAWC,MAAMC,aAAa;IACxE,OAAO;AACL,YAAMnB,UAAGC,OAAOQ,OAAOC,MAAM;IAC/B;EACF;AACF;","names":["clearDtsTemp","clearBuildConfigPaths","fs","remove","dtsTempDirectory","configs","options","noClear","projectAbsRootPath","process","cwd","config","outDir","logger","warn","chalk","bgYellowBright","i18n","t","localeKeys","warns","clearRootPath"],"sources":["../../src/builder/home/runner/work/modern.js/modern.js/packages/solutions/module-tools/src/builder/clear.ts"],"sourcesContent":["import { fs, logger, chalk } from '@modern-js/utils';\nimport type { BaseBuildConfig } from '../types';\nimport { i18n, localeKeys } from '../locale';\nimport { dtsTempDirectory } from '../constants/dts';\n\nexport const clearDtsTemp = async () => {\n await fs.remove(dtsTempDirectory);\n};\n\nexport const clearBuildConfigPaths = async (\n configs: BaseBuildConfig[],\n options?: {\n noClear?: boolean;\n projectAbsRootPath?: string;\n },\n) => {\n const { noClear = false, projectAbsRootPath = process.cwd() } = options ?? {};\n\n if (noClear) {\n return;\n }\n\n for (const config of configs) {\n if (projectAbsRootPath === config.outDir) {\n logger.warn(chalk.bgYellowBright(i18n.t(localeKeys.warns.clearRootPath)));\n } else {\n await fs.remove(config.outDir);\n }\n }\n};\n"]}
|
package/dist/builder/copy.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":";;;;;;;;;;;;EAeaA,aAAW;WAAXA;;EAwIAC,gBAAc;WAAdA;;EAsDAC,UAAQ;WAARA;;;;;iEA7MI;uBAQV;iEAGU;AAEjB,MAAMC,WAAW,oBAAIC;AAEd,MAAMJ,cAAc,OACzBK,SACAC;AAQA,QAAM,EA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AASG,GAAP;AACA,QAAIA,aAAaC,OAAO;AACtBV,oBAAO/C,MAAM,eAAewD,EAAEE,SAAS;IACzC;EACF;AACA,MAAI/E,QAAQiD,OAAO;AACjB,UAAMtD,eAAeK,SAASqD;EAChC;AACF;","names":["runPatterns","watchCopyFiles","copyTask","watchMap","Map","pattern","options","default","normalizePath","appDirectory","enableCopySync","from","globOptions","targetPattern","normalizedFrom","path","normalize","defaultAbsContext","defaultContext","context","isAbsolute","join","absoluteFrom","resolve","stats","fs","stat","error","fromType","isDirectory","isFile","glob","posix","fastGlob","escapePath","dot","dirname","globEntries","globby","followSymbolicLinks","cwd","objectMode","pMap","globEntry","dirent","to","toType","extname","slice","sep","relativeFrom","relative","filename","absoluteTo","outDir","watch","set","copySync","copy","copyConfig","debug","createDebugger","SectionTitleStatus","CopyLogPrefix","watchSectionTitle","watchList","Array","keys","changedFilePath","changeType","result","get","formatFilePath","remove","logger","log","Log","buildConfig","patterns","length","concurrency","copyOption","sourceDir","e","Error","message"],"sources":["../../src/builder/home/runner/work/modern.js/modern.js/packages/solutions/module-tools/src/builder/copy.ts"],"sourcesContent":["import path from 'path';\nimport {\n watch,\n fs,\n logger,\n createDebugger,\n globby,\n fastGlob,\n} from '@modern-js/utils';\nimport type { CopyOptions, CopyPattern } from '../types/config/copy';\nimport type { BaseBuildConfig } from '../types/config';\nimport pMap from '../../compiled/p-map';\n\nconst watchMap = new Map<string, string>();\n\nexport const runPatterns = async (\n pattern: CopyPattern,\n options: {\n appDirectory: string;\n enableCopySync?: boolean;\n outDir: string;\n defaultContext: string;\n watch?: boolean;\n },\n) => {\n const { default: normalizePath } = await import(\n '../../compiled/normalize-path'\n );\n const { appDirectory, enableCopySync = false } = options;\n const { from, globOptions = {} } = pattern;\n const targetPattern: CopyPattern = { ...pattern };\n const normalizedFrom = path.normalize(from);\n const defaultAbsContext = options.defaultContext;\n\n // when context is relative path\n if (typeof pattern.context === 'string') {\n targetPattern.context = path.isAbsolute(pattern.context)\n ? pattern.context\n : path.join(appDirectory, pattern.context);\n } else {\n targetPattern.context = defaultAbsContext;\n }\n\n let absoluteFrom;\n if (path.isAbsolute(normalizedFrom)) {\n absoluteFrom = normalizedFrom;\n } else {\n absoluteFrom = path.resolve(targetPattern.context, normalizedFrom);\n }\n\n let stats;\n try {\n stats = await fs.stat(absoluteFrom);\n } catch (error) {\n // Do Nothing\n }\n\n let fromType: 'file' | 'dir' | 'glob';\n if (stats) {\n if (stats.isDirectory()) {\n fromType = 'dir';\n } else if (stats.isFile()) {\n fromType = 'file';\n } else {\n fromType = 'glob';\n }\n } else {\n fromType = 'glob';\n }\n\n let glob;\n\n switch (fromType) {\n case 'dir':\n targetPattern.context = absoluteFrom;\n glob = path.posix.join(\n fastGlob.escapePath(normalizePath(path.resolve(absoluteFrom))),\n '**/*',\n );\n absoluteFrom = path.join(absoluteFrom, '**/*');\n\n if (typeof globOptions.dot === 'undefined') {\n globOptions.dot = true;\n }\n break;\n case 'file':\n targetPattern.context = path.dirname(absoluteFrom);\n glob = fastGlob.escapePath(normalizePath(path.resolve(absoluteFrom)));\n\n if (typeof globOptions.dot === 'undefined') {\n globOptions.dot = true;\n }\n break;\n case 'glob':\n default: {\n glob = path.isAbsolute(from)\n ? from\n : path.posix.join(\n fastGlob.escapePath(\n normalizePath(\n path.resolve(targetPattern.context ?? appDirectory),\n ),\n ),\n from,\n );\n }\n }\n\n const globEntries = await globby(glob, {\n ...{ followSymbolicLinks: true },\n ...(targetPattern.globOptions || {}),\n cwd: targetPattern.context,\n objectMode: true,\n });\n\n pMap(globEntries, async globEntry => {\n if (!globEntry.dirent.isFile()) {\n return;\n }\n\n const from = globEntry.path;\n const absoluteFrom = path.resolve(targetPattern.context!, from);\n const to = path.normalize(\n typeof targetPattern.to !== 'undefined' ? targetPattern.to : '',\n );\n const toType =\n path.extname(to) === '' || to.slice(-1) === path.sep ? 'dir' : 'file';\n\n const relativeFrom = path.relative(\n targetPattern.context ?? defaultAbsContext,\n absoluteFrom,\n );\n\n const filename = toType === 'dir' ? path.join(to, relativeFrom) : to;\n\n const absoluteTo = path.isAbsolute(filename)\n ? filename\n : path.join(options.outDir, filename);\n\n if (options.watch) {\n watchMap.set(absoluteFrom, absoluteTo);\n }\n\n if (enableCopySync) {\n fs.copySync(absoluteFrom, absoluteTo);\n } else {\n await fs.copy(absoluteFrom, absoluteTo);\n }\n });\n};\n\nexport const watchCopyFiles = async (\n options: {\n appDirectory: string;\n },\n copyConfig: CopyOptions,\n) => {\n const debug = createDebugger('module-tools:copy-watch');\n\n debug('watchMap', watchMap);\n\n const { SectionTitleStatus, CopyLogPrefix } = await import(\n '../constants/log'\n );\n const { watchSectionTitle } = await import('../utils/log');\n const watchList = Array.from(watchMap.keys());\n\n debug('watchList', watchList);\n\n watch(watchList, async ({ changedFilePath, changeType }) => {\n const result = watchMap.get(changedFilePath);\n if (!result) {\n return;\n }\n\n const formatFilePath = path.relative(options.appDirectory, changedFilePath);\n\n if (changeType === 'unlink') {\n fs.remove(result);\n logger.log(\n await watchSectionTitle(\n CopyLogPrefix,\n SectionTitleStatus.Log,\n `${formatFilePath} removed`,\n ),\n );\n return;\n }\n\n if (copyConfig?.options?.enableCopySync) {\n fs.copySync(changedFilePath, result);\n } else {\n await fs.copy(changedFilePath, result);\n }\n\n logger.log(\n await watchSectionTitle(\n CopyLogPrefix,\n SectionTitleStatus.Log,\n `${formatFilePath} changed`,\n ),\n );\n });\n};\n\nexport const copyTask = async (\n buildConfig: BaseBuildConfig,\n options: {\n appDirectory: string;\n watch?: boolean;\n },\n) => {\n const copyConfig = buildConfig.copy;\n\n if (!copyConfig.patterns || copyConfig.patterns.length === 0) {\n return;\n }\n\n const concurrency = copyConfig?.options?.concurrency || 100;\n try {\n await pMap(\n copyConfig.patterns,\n async copyOption => {\n await runPatterns(copyOption, {\n ...options,\n enableCopySync: copyConfig.options?.enableCopySync,\n outDir: buildConfig.outDir,\n defaultContext: buildConfig.sourceDir,\n });\n },\n { concurrency },\n );\n } catch (e) {\n if (e instanceof Error) {\n logger.error(`copy error: ${e.message}`);\n }\n }\n if (options.watch) {\n await watchCopyFiles(options, copyConfig);\n }\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":";;;;;;;;;;;;EAASA,WAAS;WAATA;;EACAC,QAAM;WAANA;;;wBADiB;qBACH;","names":["runRollup","runTsc"],"sources":["../../../src/builder/dts/home/runner/work/modern.js/modern.js/packages/solutions/module-tools/src/builder/dts/index.ts"],"sourcesContent":["export { runRollup } from './rollup';\nexport { runTsc } from './tsc';\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":";;;;+BAgCaA;;;WAAAA;;;;;iEAhCI;wBACM;uEACR;uEAaQ;4EACD;wBAC4B;AAe3C,MAAMA,YAAY,OACvBC,KACA,EACEC,SACAC,cACAC,WACAC,OACAC,OACAC,cACAC,iBACAC,aAAY,MACL;AAET,QAAMC,cAAsB;IAC1BC,MAAM;IACNC,KAAKC,IAAE;AACL,UAAI,CAAC,kCAAkCC,KAAKD,KAAK;AAC/C,eAAO;MACT;AACA,aAAO;IACT;EACF;AACA,QAAME,aAAaC,oBAAGC,eAAed,cAAca,oBAAGE,IAAIC,QAAQ;AAClE,QAAM,EAAEC,QAAO,IAAKJ,oBAAGK,2BACrBN,WAAWO,QACXN,oBAAGE,KACH;AAGF,QAAMK,UAAUC,cAAKC,WAAWL,QAAQG,WAAW,OAC/CH,QAAQG,UACRC,cAAKE,KAAKF,cAAKG,QAAQxB,eAAeiB,QAAQG,WAAW;AAC7D,QAAMK,uBAAuB;IAC3B;IACA;IACA;IACA;;AAEF,QAAMC,kBAAkB,CAACC,MAAcN,cAAKO,QAAQtB,cAAcqB;AAIlE,QAAME,WAAkBC,MAAMC,QAAQ7B,SAClCA,MAAM8B,IAAIN,oBACVO,qBAAS/B,OAAOwB;AAEpB,QAAMQ,cAA4B;IAChChC,OAAO2B;IACPM,UAAUlC;IACVmC,SAAS;OACPC,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qB;IACT,SAASG,GAAP;AACA,YAAM,EAAEC,sBAAqB,IAAK,MAAM,iFAAO;AAC/C,YAAMA,sBAAsBD,GAAG;QAAE7E;QAAcuE,WAAW;MAAS;AACnE,aAAO;IACT;EACF;AACF;","names":["runRollup","api","distDir","tsconfigPath","externals","input","watch","abortOnError","respectExternal","appDirectory","ignoreFiles","name","load","id","test","configFile","ts","readConfigFile","sys","readFile","options","parseJsonConfigFileContent","config","baseUrl","path","isAbsolute","join","dirname","ignoreCompileOptions","resolveRelative","p","resolve","dtsInput","Array","isArray","map","mapValue","inputConfig","external","plugins","jsonPlugin","dtsPlugin","compilerOptions","skipLibCheck","preserveSymlinks","composite","declarationMap","declaration","noEmit","emitDeclarationOnly","noEmitOnError","checkJs","target","ScriptTarget","ESNext","transformUndefineObject","tsconfig","filter","Boolean","outputConfig","dir","format","exports","watchSectionTitle","SectionTitleStatus","BundleDtsLogPrefix","runner","useHookRunners","watcher","output","on","event","code","logger","info","Log","Success","buildWatchDts","buildType","rollup","addRollupChunk","bundle","rollupOutput","write","e","printOrThrowDtsErrors"],"sources":["../../../src/builder/dts/home/runner/work/modern.js/modern.js/packages/solutions/module-tools/src/builder/dts/rollup.ts"],"sourcesContent":["import path from 'path';\nimport { logger } from '@modern-js/utils/logger';\nimport ts from 'typescript';\nimport type {\n InputOptions,\n OutputOptions,\n Plugin,\n RollupWatcher,\n} from '../../../compiled/rollup';\nimport type {\n BaseBuildConfig,\n Input,\n PluginAPI,\n ModuleTools,\n} from '../../types';\nimport jsonPlugin from '../../../compiled/@rollup/plugin-json';\nimport dtsPlugin from '../../../compiled/rollup-plugin-dts';\nimport { mapValue, transformUndefineObject } from '../../utils/common';\n\nexport type { RollupWatcher };\n\ntype Config = {\n distDir: string;\n tsconfigPath: string;\n externals: BaseBuildConfig['externals'];\n input: Input;\n watch: boolean;\n abortOnError: boolean;\n respectExternal: boolean;\n appDirectory: string;\n};\n\nexport const runRollup = async (\n api: PluginAPI<ModuleTools>,\n {\n distDir,\n tsconfigPath,\n externals,\n input,\n watch,\n abortOnError,\n respectExternal,\n appDirectory,\n }: Config,\n) => {\n const ignoreFiles: Plugin = {\n name: 'ignore-files',\n load(id) {\n if (!/\\.(js|jsx|ts|tsx|json|cts|mts)$/.test(id)) {\n return '';\n }\n return null;\n },\n };\n const configFile = ts.readConfigFile(tsconfigPath, ts.sys.readFile);\n const { options } = ts.parseJsonConfigFileContent(\n configFile.config,\n ts.sys,\n './',\n );\n\n const baseUrl = path.isAbsolute(options.baseUrl || '.')\n ? options.baseUrl\n : path.join(path.dirname(tsconfigPath), options.baseUrl || '.');\n const ignoreCompileOptions = [\n 'incremental',\n 'tsBuildInfoFile',\n 'sourceMap',\n 'inlineSources',\n ];\n const resolveRelative = (p: string) => path.resolve(appDirectory, p);\n\n // rollup don't have working directory option like esbuild,\n // so we need to resolve relative path.\n const dtsInput: Input = Array.isArray(input)\n ? input.map(resolveRelative)\n : mapValue(input, resolveRelative);\n\n const inputConfig: InputOptions = {\n input: dtsInput,\n external: externals,\n plugins: [\n jsonPlugin(),\n ignoreFiles,\n dtsPlugin({\n respectExternal,\n compilerOptions: {\n skipLibCheck: true,\n // https://github.com/Swatinem/rollup-plugin-dts/issues/143,\n // but it will cause error when bundle ts which import another ts file.\n preserveSymlinks: false,\n ...options,\n // https://github.com/Swatinem/rollup-plugin-dts/issues/127\n composite: false,\n // https://github.com/Swatinem/rollup-plugin-dts/issues/113\n declarationMap: false,\n // isAbsolute\n baseUrl,\n // Ensure \".d.ts\" modules are generated\n declaration: true,\n // Skip \".js\" generation\n noEmit: false,\n emitDeclarationOnly: true,\n // Skip code generation when error occurs\n noEmitOnError: true,\n // Avoid extra work\n checkJs: false,\n // Ensure we can parse the latest code\n target: ts.ScriptTarget.ESNext,\n ...transformUndefineObject(ignoreCompileOptions),\n },\n tsconfig: tsconfigPath,\n }),\n ].filter(Boolean),\n };\n const outputConfig: OutputOptions = {\n dir: distDir,\n format: 'esm',\n exports: 'named',\n };\n if (watch) {\n const { watch } = await import('../../../compiled/rollup');\n const { watchSectionTitle } = await import('../../utils/log');\n const { SectionTitleStatus, BundleDtsLogPrefix } = await import(\n '../../constants/log'\n );\n const runner = api.useHookRunners();\n const watcher = watch({\n ...inputConfig,\n plugins: inputConfig.plugins,\n output: outputConfig,\n }).on('event', async event => {\n if (event.code === 'START') {\n logger.info(\n await watchSectionTitle(BundleDtsLogPrefix, SectionTitleStatus.Log),\n );\n } else if (event.code === 'BUNDLE_END') {\n logger.info(\n await watchSectionTitle(\n BundleDtsLogPrefix,\n SectionTitleStatus.Success,\n ),\n );\n runner.buildWatchDts({ buildType: 'bundle' });\n } else if (event.code === 'ERROR') {\n // this is dts rollup plugin bug, error not complete message\n }\n });\n return watcher;\n } else {\n try {\n const { rollup } = await import('../../../compiled/rollup');\n const { addRollupChunk } = await import('../../utils/print');\n const bundle = await rollup(inputConfig);\n const rollupOutput = await bundle.write(outputConfig);\n addRollupChunk(rollupOutput, appDirectory, outputConfig.dir!);\n return bundle;\n } catch (e) {\n const { printOrThrowDtsErrors } = await import('../../utils/dts');\n await printOrThrowDtsErrors(e, { abortOnError, buildType: 'bundle' });\n return null;\n }\n }\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":";;;;+BAuGaA;;;WAAAA;;;uBAtGiB;uBACF;qBAWrB;qBAC2B;sBAI3B;sBACuB;AAE9B,MAAMC,aAAa,OACjBC,eACAC;MAYAD,uBAYAA,wBAGAA;AAtBA,QAAM,EAAEE,QAAQ,OAAOC,UAAU,YAAYC,OAAS,IAAKH;GAO3DD,sCAAcK,YAAM,QAApBL,kEAAsBM,GAAG,QAAQ,OAAMC;AACrC,QAAIL,OAAO;AACTM,oBAAOC,KACL,OAAMC,2BAAkBC,8BAAwBC,yBAAmBC,GAAG;AAExEL,oBAAOC,KAAKF,KAAKO,SAAQ;AACzB,UAAIP,KAAKO,SAAQ,EAAGC,SAASC,mBAAa,GAAG;AAC3C,cAAMb;MACR;IACF;EACF;GAEAH,uCAAcK,YAAM,QAApBL,oEAAsBM,GAAG,SAASW;AAChCT,kBAAOS,MAAMA,MAAMC,OAAO;EAC5B;GACAlB,sCAAcmB,YAAM,QAApBnB,kEAAsBM,GAAG,QAAQc;AAC/BZ,kBAAOS,MAAMG,MAAMN,SAAQ;EAC7B;AACF;AAEA,MAAMO,eAAe,OACnBC,KACAC;AAEA,QAAM,EAAEC,cAActB,QAAQ,OAAOuB,eAAe,KAAI,IAAKF;AAE7D,QAAM,EAAEG,cAAcC,mBAAmBC,OAAM,IAAK,OAAMC,2BACxDN;AAGF,QAAMO,aAAa,OAAMC,uBAAcP;AAEvC,QAAMQ,cAAc9B,QAAQ;IAAC;MAAQ;AACrC,QAAMF,iBAAgBiC,iBACpBH,YACA;IACE;IACAF,OAAOM;;IAEP;;IAEA;OACGF;KAEL;IACEG,OAAO;IACPC,KAAKZ;EACP;AAGF,QAAMa,SAASf,IAAIgB,eAAc;AACjCvC,aAAWC,eAAe;IACxBE;IACAC,SAAS;AACP,aAAMoC,sBAAahB,QAAQ;QAAE,GAAGK;QAAQF;MAAa;AACrDW,aAAOG,cAAc;QAAEC,WAAW;MAAa;IACjD;EACF;AAEA,MAAI;AACF,UAAMzC;EACR,SAAS0C,GAAP;AACA,WAAMC,+BAAsBD,GAAG;MAAEjB;MAAcgB,WAAW;IAAa;EACzE;AAEA,SAAO;IAAE,GAAGb;IAAQF;EAAa;AACnC;AAEO,MAAM5B,SAAS,OACpBwB,KACAC;AAEA,QAAMK,SAAS,MAAMP,aAAaC,KAAKC;AACvC,SAAMgB,sBAAahB,QAAQK;AAC3B,SAAMgB,uBAAYrB,OAAOsB,aAAatB,OAAOC,YAAY;AAC3D;","names":["runTsc","resolveLog","childProgress","options","watch","watchFn","undefined","stdout","on","data","logger","info","watchSectionTitle","BundlelessDtsLogPrefix","SectionTitleStatus","Log","toString","includes","watchDoneText","error","message","stderr","chunk","generatorDts","api","config","appDirectory","abortOnError","userTsconfig","generatedTsconfig","result","generatorTsConfig","tscBinFile","getTscBinPath","watchParams","execa","tempTsconfigPath","stdio","cwd","runner","useHookRunners","resolveAlias","buildWatchDts","buildType","e","printOrThrowDtsErrors","addDtsFiles","distAbsPath"],"sources":["../../../src/builder/dts/home/runner/work/modern.js/modern.js/packages/solutions/module-tools/src/builder/dts/tsc.ts"],"sourcesContent":["import type { ChildProcess } from 'child_process';\nimport { execa, logger } from '@modern-js/utils';\nimport { addDtsFiles } from '../../utils/print';\nimport type {\n BundlelessGeneratorDtsConfig,\n PluginAPI,\n ModuleTools,\n} from '../../types';\nimport {\n generatorTsConfig,\n getTscBinPath,\n printOrThrowDtsErrors,\n resolveAlias,\n} from '../../utils/dts';\nimport { watchSectionTitle } from '../../utils/log';\nimport {\n BundlelessDtsLogPrefix,\n SectionTitleStatus,\n} from '../../constants/log';\nimport { watchDoneText } from '../../constants/dts';\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\n /**\n * tsc 所有的log信息都是从stdout data 事件中获取\n * 正常模式下,如果有报错信息,交给 resolveLog 后面的逻辑来处理\n * watch 模式下,则使用这里的信息\n */\n childProgress.stdout?.on('data', async data => {\n if (watch) {\n logger.info(\n await watchSectionTitle(BundlelessDtsLogPrefix, SectionTitleStatus.Log),\n );\n logger.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 logger.error(error.message);\n });\n childProgress.stderr?.on('data', chunk => {\n logger.error(chunk.toString());\n });\n};\n\nconst generatorDts = async (\n api: PluginAPI<ModuleTools>,\n config: BundlelessGeneratorDtsConfig,\n) => {\n const { appDirectory, watch = false, abortOnError = true } = config;\n\n const { userTsconfig, generatedTsconfig: result } = await generatorTsConfig(\n config,\n );\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 await resolveAlias(config, { ...result, userTsconfig });\n runner.buildWatchDts({ buildType: 'bundleless' });\n },\n });\n\n try {\n await childProgress;\n } catch (e) {\n await printOrThrowDtsErrors(e, { abortOnError, buildType: 'bundleless' });\n }\n\n return { ...result, userTsconfig };\n};\n\nexport const runTsc = async (\n api: PluginAPI<ModuleTools>,\n config: BundlelessGeneratorDtsConfig,\n) => {\n const result = await generatorDts(api, config);\n await resolveAlias(config, result);\n await addDtsFiles(config.distAbsPath, config.appDirectory);\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":";;;;+BAaaA;;;WAAAA;;;;;+DAbE;uBAEe;iEAOb;uBACY;uBACuB;AAE7C,MAAMA,MAAM,OACjBC,SAKAC;AAEA,QAAM,EAAEC,qBAAqBC,SAASC,WAAU,IAAKJ;AACrD,QAAM,EAAEK,OAAOC,MAAK,IAAKF;AACzB,QAAMG,SAASN,IAAIO,eAAc;AAEjC,MAAIC,gBAAgB;AAEpB,MAAIP,oBAAoBQ,WAAW,GAAG;AACpCD,oBAAgBE,KAAKC,IAAG;AAExB,WAAMC,iCAAsBX,qBAAqB;MAC/CY,SAAS,CAACR;MACVS,oBAAoBZ,QAAQa;IAC9B;AACA,WAAMC,wBAAY;AAElB,QAAIZ,OAAO;AACTa,oBAAOC,KAAK;IACd;AAEA,QAAI;AACF,aAAMC,kBACJlB,qBACA,OAAMmB;AACJ,cAAMC,cAAc,MAAMf,OAAOgB,gBAAgBF;AAEjD,eAAMG,wBACJ;UACEF;UACAG,iBAAiBrB;UACjBD;QACF,GACAF;AAEF,cAAMM,OAAOmB,eAAe;UAAEC,QAAQ;UAAWN;QAAO;MAC1D,GACA;QAAEO,aAAaC,YAAGC,KAAI,EAAGpB;MAAO;IAEpC,SAASqB,GAAP;AACA,YAAM,EAAEC,iBAAiBC,iBAAgB,IAAK,MAAM,iFAAO;AAC3D,UAAID,gBAAgBD,IAAI;AACtB,cAAM,IAAIE,iBAAiBF;MAC7B,OAAO;AACL,cAAMA;MACR;IACF;AACAtB,oBAAgBE,KAAKC,IAAG,IAAKH;AAC7B,QAAI,CAACJ,OAAO;AACV,YAAM,EAAE6B,eAAeC,aAAY,IAAK,MAAM,iFAAO;AACrDA,mBAAa1B;AACbyB;IACF;EACF,OAAO;AACLhB,kBAAOkB,KACLC,aAAMC,OACJ,mFAAmF;EAGzF;AAEA,QAAM/B,OAAOgC,WAAW;IACtBZ,QAAQ;IACRN,QAAQnB;IACRsC,gBAAgBpC;IAChBK;EACF;AACF;","names":["run","options","api","resolvedBuildConfig","context","cmdOptions","watch","clear","runner","useHookRunners","totalDuration","length","Date","now","clearBuildConfigPaths","noClear","projectAbsRootPath","appDirectory","clearDtsTemp","logger","info","pMap","config","buildConfig","beforeBuildTask","runBuildTask","buildCmdOptions","afterBuildTask","status","concurrency","os","cpus","e","isInternalError","ModuleBuildError","printFileSize","printSucceed","warn","chalk","yellow","afterBuild","commandOptions"],"sources":["../../src/builder/home/runner/work/modern.js/modern.js/packages/solutions/module-tools/src/builder/index.ts"],"sourcesContent":["import os from 'os';\nimport type { PluginAPI } from '@modern-js/core';\nimport { chalk, logger } from '@modern-js/utils';\nimport type { ModuleContext } from '../types/context';\nimport type {\n BuildCommandOptions,\n BaseBuildConfig,\n ModuleTools,\n} from '../types';\nimport pMap from '../../compiled/p-map';\nimport { runBuildTask } from './build';\nimport { clearBuildConfigPaths, clearDtsTemp } from './clear';\n\nexport const run = async (\n options: {\n cmdOptions: BuildCommandOptions;\n resolvedBuildConfig: BaseBuildConfig[];\n context: ModuleContext;\n },\n api: PluginAPI<ModuleTools>,\n) => {\n const { resolvedBuildConfig, context, cmdOptions } = options;\n const { watch, clear } = cmdOptions;\n const runner = api.useHookRunners();\n\n let totalDuration = 0;\n\n if (resolvedBuildConfig.length !== 0) {\n totalDuration = Date.now();\n\n await clearBuildConfigPaths(resolvedBuildConfig, {\n noClear: !clear,\n projectAbsRootPath: context.appDirectory,\n });\n await clearDtsTemp();\n\n if (watch) {\n logger.info('Start build in watch mode...\\n');\n }\n\n try {\n await pMap(\n resolvedBuildConfig,\n 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 { concurrency: os.cpus().length },\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 (!watch) {\n const { printFileSize, printSucceed } = await import('../utils/print');\n printSucceed(totalDuration);\n printFileSize();\n }\n } else {\n logger.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"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":";;;;+BAMaA;;;WAAAA;;;uBALiB;uBAGH;AAEpB,MAAMA,gBAAgB,OAC3BC,SACAC,KACAC;AAEA,QAAMC,SAASF,IAAIG,eAAc;AACjC,QAAMC,mBAAmB,MAAMF,OAAOG,sBAAqB;AAC3D,MAAID,iBAAiBE,WAAW,GAAG;AACjC,QAAIP,QAAQQ,aAAa,MAAM;AAC7BC,oBAAOC,KAAK;IACd,WACEC,MAAMC,QAAQZ,QAAQQ,QAAQ,KAC9BR,QAAQQ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AYI,6BAA6B;AAGxE,YAAMxB,OAAOJ,cAAc;QAAES,UAAUmB;MAAe;AACtD,YAAMC,sBAAsBJ,MAAMG,gBAAgB;QAChDF,aAAavB,QAAQuB;MACvB;AAEAhB,oBAAOC,KAAKU,aAAME,IAAG,GAAII,WAAI,EAAE,aAAaC,sBAAsB;IACpE,WAAWhB,MAAMC,QAAQZ,QAAQQ,QAAQ,KAAKR,QAAQQ,SAASD,SAAS,GAAG;AACzE,iBAAWC,YAAYR,QAAQQ,UAAU;AACvC,cAAMwB,eAAe3B,iBAAiBwB,KAAKC;AACzC,cAAInB,MAAMC,QAAQkB,QAAQtB,QAAQ,GAAG;AACnC,mBAAOsB,QAAQtB,SAASuB,SAASvB;UACnC;AAEA,iBAAOsB,QAAQtB,aAAaA;QAC9B;AAEA,YAAI,CAACwB,cAAc;AACjBvB,wBAAOC,KAAK,QAAQF,2CAA2C;AAC/D;QACF;AAEAC,sBAAOC,KACLU,aAAMC,UAAUC,IAAG,GAAIC,WAAI,EAAE,YAAYf,uBAAuB;AAGlE,cAAML,OAAOJ,cAAc;UAAES;QAAS;AACtC,cAAMwB,aAAaR,MAAMhB,UAAU;UACjCiB,aAAavB,QAAQuB;QACvB;AAEAhB,sBAAOC,KAAKU,aAAME,IAAG,GAAII,WAAI,EAAE,aAAalB,gBAAgB;MAC9D;IACF;EACF,SAASyB,GAAP;AACA,QAAIA,aAAaC,OAAO;AACtBjB,iBAAWgB;IACb,OAAO;AACLhB,iBAAWkB,OAAOF;IACpB;EACF;AAEA,QAAM9B,OAAOiC,mBAAmB;IAC9BC,QAAQpB,aAAa,OAAO,YAAY;IACxCqB,SAASrB;EACX;AACF;","names":["buildPlatform","options","api","context","runner","useHookRunners","platformBuilders","registerBuildPlatform","length","platform","logger","info","Array","isArray","join","JSON","stringify","beforeBuildPlatform","errorMsg","platformBuilder","currentPlatform","chalk","underline","rgb","blue","build","isTsProject","gray","targetPlatform","selectPlatformBuilder","find","builder","includes","foundBuilder","e","Error","String","afterBuildPlatform","status","message"],"sources":["../../src/builder/home/runner/work/modern.js/modern.js/packages/solutions/module-tools/src/builder/platform.ts"],"sourcesContent":["import { PluginAPI } from '@modern-js/core';\nimport { chalk, logger } from '@modern-js/utils';\nimport { ModuleContext } from '../types/context';\nimport { BuildCommandOptions, ModuleTools } from '../types';\nimport { blue, gray } from '../constants/color';\n\nexport const buildPlatform = async (\n options: BuildCommandOptions,\n api: PluginAPI<ModuleTools>,\n context: ModuleContext,\n) => {\n const runner = api.useHookRunners();\n const platformBuilders = await runner.registerBuildPlatform();\n if (platformBuilders.length === 0) {\n if (options.platform === true) {\n logger.info('No executable platform build tasks');\n } else if (\n Array.isArray(options.platform) &&\n options.platform.length === 1\n ) {\n logger.info(\n `No build tasks with platform \"${options.platform[0]}\" found`,\n );\n } else if (Array.isArray(options.platform) && options.platform.length > 1) {\n logger.info(\n `No build tasks with platform ${options.platform.join(',')} found`,\n );\n } else {\n logger.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 logger.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 logger.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 logger.info(`The specified \"${targetPlatform}\" build does not exist`);\n return;\n }\n\n logger.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 logger.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 logger.info(`skip ${platform} build, because it does not exist`);\n continue;\n }\n\n logger.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 logger.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.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":";;;;+BAiBaA;;;WAAAA;;;uBAhBc;uBAEE;yBACF;yBAMpB;0BAC2B;wBACF;uBACG;8BACN;wBACN;AAEhB,MAAMA,cAAc,OAA+B;EACxDC,MAAM;EACNC;EACAC,aAAYC,wBAAWC,QAAQC,KAAKC,MAAM,GAAG,EAAE;EAC/CC;AACF;AAEA,MAAMA,QAAyC,OAAMC;AACnD,QAAMC,aAAaD,IAAIE,cAAa;AACpCF,MAAIG,cAAc;IAChB,GAAGF;IACHG,WAAW;EACb;AAEA,QAAMC,UAAU;AACd,WAAMC,gCAAiB;AAEvB,UAAML,cAAaD,IAAIE,cAAa;AACpCK,kBAAOC,OAAM;AAEb,UAAMC,UAAGC,SAAST,YAAWU,iBAAiB;AAE9C,UAAMC,cAAcZ,IAAIa,eAAc;AACtC,UAAMD,YAAYE,kBAAiB;AAEnC,WAAMC,4BAAgB;AACpB,YAAMH,YAAYI,SAAQ;IAC5B;EACF;AAEA,QAAMC,iBAAiB;AACrB,UAAMC,aAAalB,IAAImB,iBAAgB;AACvC,YAAOC,8BAAmBF,cACtBG,6BACAC;EACN;AAEA,SAAO;IACLjB;IACAY;IACA,MAAMM,SAAS,EAAEC,QAAO,GAAE;AACxB,aAAMC,0BAAaD,SAASxB;AAC5B,aAAM0B,wBAAWF,SAASxB;AAC1B,aAAM2B,wBAAWH;AACjB,aAAMI,4BAAeJ;IACvB;EACF;AACF;","names":["moduleTools","name","registerHook","usePlugins","getPlugins","process","argv","slice","setup","api","appContext","useAppContext","setAppContext","toolsType","prepare","initLocalLanguage","dotenv","config","fs","emptydir","internalDirectory","hookRunners","useHookRunners","addRuntimeExports","addExitListener","afterDev","validateSchema","userConfig","useConfigContext","isLegacyUserConfig","legacySchema","schema","commands","program","buildCommand","devCommand","newCommand","upgradeCommand"],"sources":["../src/home/runner/work/modern.js/modern.js/packages/solutions/module-tools/src/cli.ts"],"sourcesContent":["import type { CliPlugin } from '@modern-js/core';\nimport { dotenv, fs } from '@modern-js/utils';\nimport type { ModuleTools } from './types';\nimport { registerHook } from './hooks';\nimport { getPlugins } from './plugins';\nimport {\n buildCommand,\n devCommand,\n newCommand,\n upgradeCommand,\n} from './command';\nimport { initLocalLanguage } from './utils/language';\nimport { addExitListener } from './utils/onExit';\nimport { isLegacyUserConfig } from './config/merge';\nimport { legacySchema } from './config/legacySchema';\nimport { schema } from './config/schema';\n\nexport const moduleTools = (): 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 appContext = api.useAppContext();\n api.setAppContext({\n ...appContext,\n toolsType: 'module-tools',\n });\n\n const prepare = async () => {\n await initLocalLanguage();\n\n const appContext = api.useAppContext();\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 await addExitListener(async () => {\n await hookRunners.afterDev();\n });\n };\n\n const validateSchema = async () => {\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 await buildCommand(program, api);\n await devCommand(program, api);\n await newCommand(program);\n await upgradeCommand(program);\n },\n };\n};\n"]}
|
package/dist/command.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":";;;;;;;;;;;;EAOaA,cAAY;WAAZA;;EAwBAC,YAAU;WAAVA;;EAgDAC,YAAU;WAAVA;;EA8BAC,gBAAc;WAAdA;;;;wBAzGoB;yBACC;AAE3B,MAAMH,eAAe,OAC1BI,SACAC;AAEAD,UACGE,QAAQ,SACRC,MAAM,aACNC,YAAYC,aAAKC,EAAEC,mBAAWL,QAAQM,MAAMC,QAAQ,GACpDC,OAAO,eAAeL,aAAKC,EAAEC,mBAAWL,QAAQM,MAAMG,KAAK,GAC3DD,OAAO,yBAAyBL,aAAKC,EAAEC,mBAAWL,QAAQM,MAAMI,QAAQ,GACxEF,OACC,gCACAL,aAAKC,EAAEC,mBAAWL,QAAQM,MAAMK,QAAQ,GAEzCH,OAAO,YAAYL,aAAKC,EAAEC,mBAAWL,QAAQM,MAAMM,GAAG,GACtDJ,OAAO,cAAcL,aAAKC,EAAEC,mBAAWL,QAAQM,MAAMO,OAAO,GAC5DL,OAAO,wBAAwBL,aAAKC,EAAEC,mBAAWL,QAAQc,OAAOC,MAAM,GACtEC,OAAO,OAAOC;AACb,UAAMC,UAAU,OAAMC,+BAAkBpB;AACxC,UAAM,EAAEO,MAAK,IAAK,MAAM,iFAAO;AAC/B,UAAMA,MAAMP,KAAKkB,SAASC;EAC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AAIG,OAAO,GAChE3B,OAAO,cAAcL,aAAKC,EAAEC,mBAAWL,QAAQgC,IAAII,QAAQ,GAC3D5B,OACC,qBACAL,aAAKC,EAAEC,mBAAWL,QAAQc,OAAOuB,aAAa,GAE/CrB,OAAO,OAAMC;AACZ,UAAM,EAAEqB,gBAAe,IAAK,MAAM,iFAAO;AACzC,UAAM,EAAEC,kBAAiB,IAAK,MAAM,iFAClC;AAGF,UAAMC,SAASD;AAEf,UAAMD,gBAAgB;MAAE,GAAGrB;MAASuB,QAAQvB,QAAQgB,QAAQO;IAAO;EACrE;AACJ;AAEO,MAAM3C,iBAAiB,OAAOC;AACnC,QAAM,EAAE2C,cAAa,IAAK,MAAM,iFAAO;AACvCA,gBACE3C,QACGE,QAAQ,WACRQ,OAAO,wBAAwBL,aAAKC,EAAEC,mBAAWL,QAAQc,OAAOC,MAAM,GACtEP,OACC,qBACAL,aAAKC,EAAEC,mBAAWL,QAAQc,OAAOuB,aAAa;AAGtD;","names":["buildCommand","devCommand","newCommand","upgradeCommand","program","api","command","usage","description","i18n","t","localeKeys","build","describe","option","watch","tsconfig","platform","dts","noClear","shared","config","action","options","context","initModuleContext","runner","useHookRunners","devToolMetas","registerDev","beforeDev","devProgram","dev","meta","subCommands","subCmd","beforeDevTask","isTsProject","new","lang","debug","distTag","registry","noNeedInstall","ModuleNewAction","getLocaleLanguage","locale","defineCommand"],"sources":["../src/home/runner/work/modern.js/modern.js/packages/solutions/module-tools/src/command.ts"],"sourcesContent":["import type { Command } from '@modern-js/utils';\nimport type { PluginAPI } from '@modern-js/core';\nimport type { ModuleTools } from './types';\nimport type { DevCommandOptions, BuildCommandOptions } from './types/command';\nimport { i18n, localeKeys } from './locale';\nimport { initModuleContext } from './utils/context';\n\nexport const buildCommand = async (\n program: Command,\n api: PluginAPI<ModuleTools>,\n) => {\n program\n .command('build')\n .usage('[options]')\n .description(i18n.t(localeKeys.command.build.describe))\n .option('-w, --watch', i18n.t(localeKeys.command.build.watch))\n .option('--tsconfig [tsconfig]', i18n.t(localeKeys.command.build.tsconfig))\n .option(\n '-p, --platform [platform...]',\n i18n.t(localeKeys.command.build.platform),\n )\n .option('--no-dts', i18n.t(localeKeys.command.build.dts))\n .option('--no-clear', i18n.t(localeKeys.command.build.noClear))\n .option('-c --config <config>', i18n.t(localeKeys.command.shared.config))\n .action(async (options: BuildCommandOptions) => {\n const context = await initModuleContext(api);\n const { build } = await import('./build');\n await build(api, options, context);\n });\n};\n\nexport const devCommand = async (\n program: Command,\n api: PluginAPI<ModuleTools>,\n) => {\n const runner = api.useHookRunners();\n const devToolMetas = await runner.registerDev();\n\n await runner.beforeDev(devToolMetas);\n\n const devProgram = program\n .command('dev')\n .usage('[options]')\n .description(i18n.t(localeKeys.command.dev.describe))\n .option('--tsconfig [tsconfig]', i18n.t(localeKeys.command.dev.tsconfig))\n .action(async (options: DevCommandOptions) => {\n const context = await initModuleContext(api);\n const { dev } = await import('./dev');\n await dev(options, devToolMetas, api, context);\n });\n\n for (const meta of devToolMetas) {\n if (!meta.subCommands) {\n continue;\n }\n\n for (const subCmd of meta.subCommands) {\n devProgram.command(subCmd).action(async (options: DevCommandOptions) => {\n const context = await initModuleContext(api);\n\n // TODO: watch build\n // const { ensureFirstBuild, watchBuild } = await import('./dev');\n // await ensureFirstBuild(api, context, options, {\n // disableRunBuild: meta.disableRunBuild ?? false,\n // appDirectory: context.appDirectory,\n // });\n\n await runner.beforeDevTask(meta);\n await meta.action(options, { isTsProject: context.isTsProject });\n // TODO: watch build\n // await watchBuild(api, context, options, {\n // disableRunBuild: meta.disableRunBuild ?? false,\n // appDirectory: context.appDirectory,\n // });\n });\n }\n }\n};\n\nexport const newCommand = async (program: Command) => {\n program\n .command('new')\n .usage('[options]')\n .description(i18n.t(localeKeys.command.new.describe))\n .option(\n '--config-file <configFile>',\n i18n.t(localeKeys.command.shared.config),\n )\n .option('--lang <lang>', i18n.t(localeKeys.command.new.lang))\n .option('-c, --config <config>', i18n.t(localeKeys.command.new.config))\n .option('-d, --debug', i18n.t(localeKeys.command.new.debug), false)\n .option('--dist-tag <tag>', i18n.t(localeKeys.command.new.distTag))\n .option('--registry', i18n.t(localeKeys.command.new.registry))\n .option(\n '--no-need-install',\n i18n.t(localeKeys.command.shared.noNeedInstall),\n )\n .action(async options => {\n const { ModuleNewAction } = await import('@modern-js/new-action');\n const { getLocaleLanguage } = await import(\n '@modern-js/plugin-i18n/language-detector'\n );\n\n const locale = getLocaleLanguage();\n\n await ModuleNewAction({ ...options, locale: options.lang || locale });\n });\n};\n\nexport const upgradeCommand = async (program: Command) => {\n const { defineCommand } = await import('@modern-js/upgrade');\n defineCommand(\n program\n .command('upgrade')\n .option('-c --config <config>', i18n.t(localeKeys.command.shared.config))\n .option(\n '--no-need-install',\n i18n.t(localeKeys.command.shared.noNeedInstall),\n ),\n );\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"mappings":";;;;;;;;;;;;EAGaA,cAAY;WAAZA;;EAOAC,oBAAkB;WAAlBA;;;AAPN,MAAMD,eAAe,CAACE,WAC3BA;AAMK,MAAMD,qBAAqB,CAChCC,YAC4B;EAC5B,GAAGA;EACHC,QAAQ;EACRC,iBAAiB;AACnB;","names":["defineConfig","defineLegacyConfig","config","legacy","autoLoadPlugins"],"sources":["../../src/config/home/runner/work/modern.js/modern.js/packages/solutions/module-tools/src/config/defineConfig.ts"],"sourcesContent":["import type { UserConfigExport } from '@modern-js/core';\nimport type { ModuleConfigParams, ModuleLegacyUserConfig } from '../types';\n\nexport const defineConfig = (config: UserConfigExport<ModuleConfigParams>) =>\n config;\n\n/**\n * @deprecated\n * Using defineConfig first.\n */\nexport const defineLegacyConfig = (\n config: ModuleLegacyUserConfig,\n): ModuleLegacyUserConfig => ({\n ...config,\n legacy: true,\n autoLoadPlugins: true,\n});\n"]}
|