@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
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
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 });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var hash_exports = {};
|
|
20
|
+
__export(hash_exports, {
|
|
21
|
+
getHash: () => getHash
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(hash_exports);
|
|
24
|
+
var import_crypto = require("crypto");
|
|
25
|
+
function getHash(content, encoding, type = "md5") {
|
|
26
|
+
return (0, import_crypto.createHash)(type).update(content.toString(), encoding).digest("hex");
|
|
27
|
+
}
|
|
28
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
29
|
+
0 && (module.exports = {
|
|
30
|
+
getHash
|
|
31
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './assert';
|
|
2
|
+
export * from './builder';
|
|
3
|
+
export * from './common';
|
|
4
|
+
export * from './dts';
|
|
5
|
+
export * from './hash';
|
|
6
|
+
export * from './input';
|
|
7
|
+
export * from './log';
|
|
8
|
+
export * from './map';
|
|
9
|
+
export * from './print';
|
|
10
|
+
export * from './style';
|
|
11
|
+
export * from './tspath';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var utils_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(utils_exports);
|
|
18
|
+
__reExport(utils_exports, require("./assert"), module.exports);
|
|
19
|
+
__reExport(utils_exports, require("./builder"), module.exports);
|
|
20
|
+
__reExport(utils_exports, require("./common"), module.exports);
|
|
21
|
+
__reExport(utils_exports, require("./dts"), module.exports);
|
|
22
|
+
__reExport(utils_exports, require("./hash"), module.exports);
|
|
23
|
+
__reExport(utils_exports, require("./input"), module.exports);
|
|
24
|
+
__reExport(utils_exports, require("./log"), module.exports);
|
|
25
|
+
__reExport(utils_exports, require("./map"), module.exports);
|
|
26
|
+
__reExport(utils_exports, require("./print"), module.exports);
|
|
27
|
+
__reExport(utils_exports, require("./style"), module.exports);
|
|
28
|
+
__reExport(utils_exports, require("./tspath"), module.exports);
|
|
29
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
30
|
+
0 && (module.exports = {
|
|
31
|
+
...require("./assert"),
|
|
32
|
+
...require("./builder"),
|
|
33
|
+
...require("./common"),
|
|
34
|
+
...require("./dts"),
|
|
35
|
+
...require("./hash"),
|
|
36
|
+
...require("./input"),
|
|
37
|
+
...require("./log"),
|
|
38
|
+
...require("./map"),
|
|
39
|
+
...require("./print"),
|
|
40
|
+
...require("./style"),
|
|
41
|
+
...require("./tspath")
|
|
42
|
+
});
|
package/dist/utils/input.js
CHANGED
|
@@ -1,34 +1,48 @@
|
|
|
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 getDefaultIndexEntry;
|
|
15
|
-
},
|
|
16
|
-
normalizeInput: function() {
|
|
17
|
-
return normalizeInput;
|
|
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 });
|
|
18
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 input_exports = {};
|
|
30
|
+
__export(input_exports, {
|
|
31
|
+
getDefaultIndexEntry: () => getDefaultIndexEntry,
|
|
32
|
+
normalizeInput: () => normalizeInput
|
|
19
33
|
});
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
34
|
+
module.exports = __toCommonJS(input_exports);
|
|
35
|
+
var import_path = __toESM(require("path"));
|
|
36
|
+
var import_utils = require("@modern-js/utils");
|
|
23
37
|
const getDefaultIndexEntry = async ({ isTsProject, appDirectory }) => {
|
|
24
38
|
let entry = isTsProject ? "src/index.ts" : "src/index.js";
|
|
25
|
-
if (
|
|
39
|
+
if (import_utils.fs.existsSync(import_path.default.resolve(appDirectory, entry))) {
|
|
26
40
|
return [
|
|
27
41
|
entry
|
|
28
42
|
];
|
|
29
43
|
}
|
|
30
44
|
entry = isTsProject ? "src/index.tsx" : "src/index.jsx";
|
|
31
|
-
if (
|
|
45
|
+
if (import_utils.fs.existsSync(import_path.default.resolve(appDirectory, entry))) {
|
|
32
46
|
return [
|
|
33
47
|
entry
|
|
34
48
|
];
|
|
@@ -54,8 +68,11 @@ const normalizeInput = async (input, appDirectory, enableSvgr) => {
|
|
|
54
68
|
if (enableSvgr) {
|
|
55
69
|
extensions.push("svg");
|
|
56
70
|
}
|
|
57
|
-
if ((0,
|
|
58
|
-
|
|
71
|
+
if ((0, import_utils.isArray)(input)) {
|
|
72
|
+
if (input.length === 0) {
|
|
73
|
+
return input;
|
|
74
|
+
}
|
|
75
|
+
const normalizedInput = await (0, import_utils.globby)(input.map(import_utils.slash), {
|
|
59
76
|
expandDirectories: {
|
|
60
77
|
extensions
|
|
61
78
|
},
|
|
@@ -64,10 +81,16 @@ const normalizeInput = async (input, appDirectory, enableSvgr) => {
|
|
|
64
81
|
],
|
|
65
82
|
cwd: appDirectory
|
|
66
83
|
});
|
|
84
|
+
if (normalizedInput.length === 0) {
|
|
85
|
+
throw new Error(`Can not find ${input}`);
|
|
86
|
+
}
|
|
67
87
|
return normalizedInput;
|
|
68
88
|
} else {
|
|
69
89
|
return input;
|
|
70
90
|
}
|
|
71
91
|
};
|
|
72
|
-
|
|
73
|
-
|
|
92
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
93
|
+
0 && (module.exports = {
|
|
94
|
+
getDefaultIndexEntry,
|
|
95
|
+
normalizeInput
|
|
96
|
+
});
|
package/dist/utils/log.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const watchSectionTitle: (str: string, status: SectionTitleStatus, detailLog?: string) => Promise<string>;
|
|
1
|
+
export declare const withLogTitle: (titleText: string, message: string) => string;
|
package/dist/utils/log.js
CHANGED
|
@@ -1,23 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
} else if (status === _log.SectionTitleStatus.Fail) {
|
|
18
|
-
return `${chalk.gray(str)} ${chalk.red("Build Failed")}`;
|
|
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 });
|
|
19
17
|
}
|
|
20
|
-
return
|
|
18
|
+
return to;
|
|
21
19
|
};
|
|
22
|
-
|
|
23
|
-
|
|
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 log_exports = {};
|
|
30
|
+
__export(log_exports, {
|
|
31
|
+
withLogTitle: () => withLogTitle
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(log_exports);
|
|
34
|
+
var import_chalk = __toESM(require("@modern-js/utils/chalk"));
|
|
35
|
+
const withLogTitle = (titleText, message) => `${message} ${import_chalk.default.gray(`[${titleText}]`)}`;
|
|
36
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
37
|
+
0 && (module.exports = {
|
|
38
|
+
withLogTitle
|
|
39
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { RawSourceMap } from '@ampproject/remapping/dist/types/types';
|
|
2
|
+
import type { SourceMap } from '../types';
|
|
3
|
+
interface Options {
|
|
4
|
+
needSourceMap: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare function normalizeSourceMap(map: string | RawSourceMap | undefined, opts?: Options): SourceMap | undefined;
|
|
7
|
+
export type MergeMapResult = {
|
|
8
|
+
toString: () => string;
|
|
9
|
+
toMap: () => SourceMap;
|
|
10
|
+
toComment: () => string;
|
|
11
|
+
};
|
|
12
|
+
export declare function mergeMaps(mapList: SourceMap[]): MergeMapResult;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
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 map_exports = {};
|
|
30
|
+
__export(map_exports, {
|
|
31
|
+
mergeMaps: () => mergeMaps,
|
|
32
|
+
normalizeSourceMap: () => normalizeSourceMap
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(map_exports);
|
|
35
|
+
var import_convert_source_map = __toESM(require("convert-source-map"));
|
|
36
|
+
var import_remapping = __toESM(require("@ampproject/remapping"));
|
|
37
|
+
function normalizeSourceMap(map, opts) {
|
|
38
|
+
if ((opts === null || opts === void 0 ? void 0 : opts.needSourceMap) === false || !map) {
|
|
39
|
+
return void 0;
|
|
40
|
+
}
|
|
41
|
+
if (typeof map === "string") {
|
|
42
|
+
return JSON.parse(map);
|
|
43
|
+
}
|
|
44
|
+
return map;
|
|
45
|
+
}
|
|
46
|
+
function mergeMaps(mapList) {
|
|
47
|
+
const map = (0, import_remapping.default)(mapList, () => null);
|
|
48
|
+
return {
|
|
49
|
+
toMap: () => map,
|
|
50
|
+
toString: () => map.toString(),
|
|
51
|
+
toComment: () => import_convert_source_map.default.fromObject(map).toComment()
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
55
|
+
0 && (module.exports = {
|
|
56
|
+
mergeMaps,
|
|
57
|
+
normalizeSourceMap
|
|
58
|
+
});
|
package/dist/utils/onExit.js
CHANGED
|
@@ -1,16 +1,38 @@
|
|
|
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 onExit_exports = {};
|
|
30
|
+
__export(onExit_exports, {
|
|
31
|
+
addExitListener: () => addExitListener
|
|
10
32
|
});
|
|
11
|
-
|
|
33
|
+
module.exports = __toCommonJS(onExit_exports);
|
|
12
34
|
const addExitListener = async (fn) => {
|
|
13
|
-
const { default: onExit } = await Promise.resolve().then(() =>
|
|
35
|
+
const { default: onExit } = await Promise.resolve().then(() => __toESM(require("../../compiled/signal-exit")));
|
|
14
36
|
onExit(async (code) => {
|
|
15
37
|
if (code === 0) {
|
|
16
38
|
return;
|
|
@@ -18,5 +40,7 @@ const addExitListener = async (fn) => {
|
|
|
18
40
|
await fn();
|
|
19
41
|
});
|
|
20
42
|
};
|
|
21
|
-
|
|
22
|
-
|
|
43
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
44
|
+
0 && (module.exports = {
|
|
45
|
+
addExitListener
|
|
46
|
+
});
|
package/dist/utils/print.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type { ILibuilder } from '@modern-js/libuild';
|
|
2
1
|
import type { RollupOutput } from '../../compiled/rollup/types/rollup';
|
|
2
|
+
import { Chunk } from '../types';
|
|
3
3
|
type Files = {
|
|
4
4
|
name: string;
|
|
5
5
|
size: number;
|
|
6
6
|
};
|
|
7
7
|
export declare const bundleFiles: Files[];
|
|
8
8
|
export declare const bundlelessFiles: Files[];
|
|
9
|
-
export declare const addOutputChunk: (outputChunk:
|
|
9
|
+
export declare const addOutputChunk: (outputChunk: Map<string, Chunk>, appDirectory: string, isBundle: boolean) => void;
|
|
10
10
|
export declare const addRollupChunk: (rollupOutput: RollupOutput, appDirectory: string, distDir: string) => void;
|
|
11
11
|
export declare const addDtsFiles: (distDir: string, appDirectory: string) => Promise<void>;
|
|
12
12
|
export declare const printFileSize: () => void;
|
package/dist/utils/print.js
CHANGED
|
@@ -1,47 +1,42 @@
|
|
|
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 bundleFiles;
|
|
15
|
-
},
|
|
16
|
-
bundlelessFiles: function() {
|
|
17
|
-
return bundlelessFiles;
|
|
18
|
-
},
|
|
19
|
-
addOutputChunk: function() {
|
|
20
|
-
return addOutputChunk;
|
|
21
|
-
},
|
|
22
|
-
addRollupChunk: function() {
|
|
23
|
-
return addRollupChunk;
|
|
24
|
-
},
|
|
25
|
-
addDtsFiles: function() {
|
|
26
|
-
return addDtsFiles;
|
|
27
|
-
},
|
|
28
|
-
printFileSize: function() {
|
|
29
|
-
return printFileSize;
|
|
30
|
-
},
|
|
31
|
-
printSucceed: function() {
|
|
32
|
-
return printSucceed;
|
|
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 print_exports = {};
|
|
20
|
+
__export(print_exports, {
|
|
21
|
+
addDtsFiles: () => addDtsFiles,
|
|
22
|
+
addOutputChunk: () => addOutputChunk,
|
|
23
|
+
addRollupChunk: () => addRollupChunk,
|
|
24
|
+
bundleFiles: () => bundleFiles,
|
|
25
|
+
bundlelessFiles: () => bundlelessFiles,
|
|
26
|
+
printFileSize: () => printFileSize,
|
|
27
|
+
printSucceed: () => printSucceed
|
|
34
28
|
});
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
29
|
+
module.exports = __toCommonJS(print_exports);
|
|
30
|
+
var import_path = require("path");
|
|
31
|
+
var import_utils = require("@modern-js/utils");
|
|
32
|
+
var import_log = require("../constants/log");
|
|
38
33
|
const bundleFiles = [];
|
|
39
34
|
const bundlelessFiles = [];
|
|
40
35
|
const addOutputChunk = (outputChunk, appDirectory, isBundle) => {
|
|
41
36
|
const files = Array.from(outputChunk).map((val) => {
|
|
42
37
|
const [path, chunk] = val;
|
|
43
38
|
return {
|
|
44
|
-
name: (0,
|
|
39
|
+
name: (0, import_path.relative)(appDirectory, path),
|
|
45
40
|
size: chunk.contents.length
|
|
46
41
|
};
|
|
47
42
|
});
|
|
@@ -55,19 +50,19 @@ const addRollupChunk = (rollupOutput, appDirectory, distDir) => {
|
|
|
55
50
|
const { output } = rollupOutput;
|
|
56
51
|
bundleFiles.push(...output.map((o) => {
|
|
57
52
|
return {
|
|
58
|
-
name: (0,
|
|
53
|
+
name: (0, import_path.relative)(appDirectory, (0, import_path.resolve)(distDir, o.fileName)),
|
|
59
54
|
// only d.ts, is outputChunk not outputAsset
|
|
60
55
|
size: o.code.length
|
|
61
56
|
};
|
|
62
57
|
}));
|
|
63
58
|
};
|
|
64
59
|
const addDtsFiles = async (distDir, appDirectory) => {
|
|
65
|
-
const files = await (0,
|
|
60
|
+
const files = await (0, import_utils.fastGlob)(`${(0, import_utils.slash)(distDir)}/**/*.d.ts`, {
|
|
66
61
|
stats: true
|
|
67
62
|
});
|
|
68
63
|
bundlelessFiles.push(...files.map((file) => {
|
|
69
64
|
return {
|
|
70
|
-
name: (0,
|
|
65
|
+
name: (0, import_path.relative)(appDirectory, file.path),
|
|
71
66
|
size: file.stats.size
|
|
72
67
|
};
|
|
73
68
|
}));
|
|
@@ -77,8 +72,8 @@ const printFileSize = () => {
|
|
|
77
72
|
printBundleFiles();
|
|
78
73
|
};
|
|
79
74
|
const printSucceed = (totalDuration) => {
|
|
80
|
-
const time =
|
|
81
|
-
|
|
75
|
+
const time = import_utils.chalk.cyan(`${(totalDuration / 1e3).toFixed(1)}s`);
|
|
76
|
+
import_utils.logger.info(`${import_log.buildSuccessText} in ${time}`);
|
|
82
77
|
};
|
|
83
78
|
const prettyBytes = (bytes) => {
|
|
84
79
|
if (bytes === 0) {
|
|
@@ -96,20 +91,20 @@ const prettyBytes = (bytes) => {
|
|
|
96
91
|
"YB"
|
|
97
92
|
];
|
|
98
93
|
const exp = Math.floor(Math.log(bytes) / Math.log(1024));
|
|
99
|
-
return `${(bytes / Math.pow(1024, exp)).toFixed(
|
|
94
|
+
return `${(bytes / Math.pow(1024, exp)).toFixed(1)} ${unit[exp]}`;
|
|
100
95
|
};
|
|
101
96
|
const printBundleFiles = () => {
|
|
102
97
|
if (bundleFiles.length === 0) {
|
|
103
98
|
return;
|
|
104
99
|
}
|
|
105
|
-
const longestFileLength = bundleFiles.reduce((max, str) => Math.max(max, str.name.length),
|
|
106
|
-
|
|
100
|
+
const longestFileLength = bundleFiles.reduce((max, str) => Math.max(max, str.name.length), import_log.reportFile1LineText.length);
|
|
101
|
+
import_utils.logger.info(`Bundle generated ${bundleFiles.length} files
|
|
107
102
|
`);
|
|
108
|
-
const headerRow =
|
|
109
|
-
|
|
103
|
+
const headerRow = import_log.reportFile1LineText + " ".repeat(longestFileLength - 10) + import_log.reportFile2LineText;
|
|
104
|
+
import_utils.logger.log(import_utils.chalk.bold(import_utils.chalk.green(headerRow)));
|
|
110
105
|
bundleFiles.forEach(({ name, size }) => {
|
|
111
106
|
const infoRow = `${name}${" ".repeat(longestFileLength - name.length + 2)}${prettyBytes(size)}`;
|
|
112
|
-
|
|
107
|
+
import_utils.logger.log(infoRow);
|
|
113
108
|
});
|
|
114
109
|
};
|
|
115
110
|
const printBundlelessInfo = () => {
|
|
@@ -120,8 +115,16 @@ const printBundlelessInfo = () => {
|
|
|
120
115
|
const totalSize = bundlelessFiles.reduce((total, file) => {
|
|
121
116
|
return total + file.size;
|
|
122
117
|
}, 0);
|
|
123
|
-
const info = `Bundleless generated ${count} files, the total size is ${
|
|
124
|
-
|
|
118
|
+
const info = `Bundleless generated ${count} files, the total size is ${import_utils.chalk.cyan(prettyBytes(totalSize))}`;
|
|
119
|
+
import_utils.logger.info(info);
|
|
125
120
|
};
|
|
126
|
-
|
|
127
|
-
|
|
121
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
122
|
+
0 && (module.exports = {
|
|
123
|
+
addDtsFiles,
|
|
124
|
+
addOutputChunk,
|
|
125
|
+
addRollupChunk,
|
|
126
|
+
bundleFiles,
|
|
127
|
+
bundlelessFiles,
|
|
128
|
+
printFileSize,
|
|
129
|
+
printSucceed
|
|
130
|
+
});
|
package/dist/utils/style.d.ts
CHANGED
|
@@ -1,30 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export declare const getLessConfig: (config: PartialBaseBuildConfig) => Promise<{
|
|
5
|
-
additionalData?: (string | ((filePath: string) => string)) | undefined;
|
|
6
|
-
implementation?: string | object | undefined;
|
|
7
|
-
lessOptions?: Less.Options | undefined;
|
|
8
|
-
}>;
|
|
9
|
-
export declare const getSassConfig: (config: PartialBaseBuildConfig) => Promise<{
|
|
10
|
-
additionalData?: (string | ((filePath: string) => string)) | undefined;
|
|
11
|
-
implementation?: string | object | undefined;
|
|
12
|
-
sassOptions?: import("@modern-js/libuild").sassOptions | undefined;
|
|
13
|
-
}>;
|
|
1
|
+
import type { PartialBaseBuildConfig, PostcssOptions, LessOptions, SassOptions } from '../types';
|
|
2
|
+
export declare const getLessConfig: (config: PartialBaseBuildConfig) => Promise<LessOptions>;
|
|
3
|
+
export declare const getSassConfig: (config: PartialBaseBuildConfig) => Promise<SassOptions>;
|
|
14
4
|
export declare const getPostcssConfig: (config: PartialBaseBuildConfig) => Promise<PostcssOptions & {
|
|
15
5
|
$$tools?: string | undefined;
|
|
16
6
|
}>;
|
|
17
7
|
export declare const getStyleConfig: (config: PartialBaseBuildConfig) => Promise<{
|
|
18
|
-
less:
|
|
19
|
-
|
|
20
|
-
implementation?: string | object | undefined;
|
|
21
|
-
lessOptions?: Less.Options | undefined;
|
|
22
|
-
};
|
|
23
|
-
sass: {
|
|
24
|
-
additionalData?: (string | ((filePath: string) => string)) | undefined;
|
|
25
|
-
implementation?: string | object | undefined;
|
|
26
|
-
sassOptions?: import("@modern-js/libuild").sassOptions | undefined;
|
|
27
|
-
};
|
|
8
|
+
less: LessOptions;
|
|
9
|
+
sass: SassOptions;
|
|
28
10
|
postcss: PostcssOptions & {
|
|
29
11
|
$$tools?: string | undefined;
|
|
30
12
|
};
|