@modern-js/module-tools 2.15.0 → 2.16.0-beta.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/compiled/postcss-custom-properties/index.js +1 -1
- package/compiled/postcss-custom-properties/package.json +1 -1
- package/dist/build.js +23 -66
- package/dist/build.js.map +1 -1
- package/dist/builder/build.js +114 -170
- package/dist/builder/build.js.map +1 -1
- package/dist/builder/clear.js +23 -65
- package/dist/builder/clear.js.map +1 -1
- package/dist/builder/copy.js +83 -164
- package/dist/builder/copy.js.map +1 -1
- package/dist/builder/dts/index.js +15 -28
- package/dist/builder/dts/index.js.map +1 -1
- package/dist/builder/dts/rollup.js +46 -120
- package/dist/builder/dts/rollup.js.map +1 -1
- package/dist/builder/dts/tsc.js +82 -141
- package/dist/builder/dts/tsc.js.map +1 -1
- package/dist/builder/index.js +34 -85
- package/dist/builder/index.js.map +1 -1
- package/dist/builder/platform.js +40 -93
- package/dist/builder/platform.js.map +1 -1
- package/dist/cli.js +35 -84
- package/dist/cli.js.map +1 -1
- package/dist/command.js +56 -136
- package/dist/command.js.map +1 -1
- package/dist/config/defineConfig.js +13 -42
- package/dist/config/defineConfig.js.map +1 -1
- package/dist/config/legacySchema.js +96 -52
- package/dist/config/legacySchema.js.map +1 -1
- package/dist/config/normalize.js +73 -149
- package/dist/config/normalize.js.map +1 -1
- package/dist/config/schema.d.ts +36 -0
- package/dist/config/schema.js +118 -56
- package/dist/config/schema.js.map +1 -1
- package/dist/config/transformLegacyConfig.js +152 -203
- package/dist/config/transformLegacyConfig.js.map +1 -1
- package/dist/constants/build.js +15 -27
- package/dist/constants/build.js.map +1 -1
- package/dist/constants/buildPresets.js +71 -84
- package/dist/constants/buildPresets.js.map +1 -1
- package/dist/constants/colors.js +28 -30
- package/dist/constants/colors.js.map +1 -1
- package/dist/constants/dts.js +13 -28
- package/dist/constants/dts.js.map +1 -1
- package/dist/constants/file.js +27 -30
- package/dist/constants/file.js.map +1 -1
- package/dist/constants/legacyBuildPresets.js +33 -49
- package/dist/constants/legacyBuildPresets.js.map +1 -1
- package/dist/constants/log.js +15 -33
- package/dist/constants/log.js.map +1 -1
- package/dist/dev.js +45 -91
- package/dist/dev.js.map +1 -1
- package/dist/error.js +37 -54
- package/dist/error.js.map +1 -1
- package/dist/hooks/build.js +22 -35
- package/dist/hooks/build.js.map +1 -1
- package/dist/hooks/dev.js +15 -33
- package/dist/hooks/dev.js.map +1 -1
- package/dist/hooks/index.js +15 -42
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/misc.js +10 -28
- package/dist/hooks/misc.js.map +1 -1
- package/dist/index.js +21 -35
- package/dist/index.js.map +1 -1
- package/dist/locale/en.d.ts +7 -2
- package/dist/locale/en.js +25 -32
- package/dist/locale/en.js.map +1 -1
- package/dist/locale/index.d.ts +14 -4
- package/dist/locale/index.js +18 -31
- package/dist/locale/index.js.map +1 -1
- package/dist/locale/zh.d.ts +7 -2
- package/dist/locale/zh.js +25 -32
- package/dist/locale/zh.js.map +1 -1
- package/dist/plugins.js +16 -39
- package/dist/plugins.js.map +1 -1
- package/dist/types/color.js +4 -15
- package/dist/types/color.js.map +1 -1
- package/dist/types/command.js +4 -15
- package/dist/types/command.js.map +1 -1
- package/dist/types/config/index.d.ts +6 -0
- package/dist/types/config/index.js +6 -17
- package/dist/types/config/index.js.map +1 -1
- package/dist/types/config/style.js +4 -15
- package/dist/types/config/style.js.map +1 -1
- package/dist/types/context.js +4 -15
- package/dist/types/context.js.map +1 -1
- package/dist/types/copy.js +4 -15
- package/dist/types/copy.js.map +1 -1
- package/dist/types/dts.js +4 -15
- package/dist/types/dts.js.map +1 -1
- package/dist/types/hooks.js +4 -15
- package/dist/types/hooks.js.map +1 -1
- package/dist/types/index.js +11 -22
- package/dist/types/index.js.map +1 -1
- package/dist/types/legacyConfig/index.js +4 -15
- package/dist/types/legacyConfig/index.js.map +1 -1
- package/dist/types/legacyConfig/output.js +4 -15
- package/dist/types/legacyConfig/output.js.map +1 -1
- package/dist/types/legacyConfig/source.js +4 -15
- package/dist/types/legacyConfig/source.js.map +1 -1
- package/dist/types/legacyConfig/tools.js +4 -15
- package/dist/types/legacyConfig/tools.js.map +1 -1
- package/dist/types/utils.js +4 -17
- package/dist/utils/builder.d.ts +20 -2
- package/dist/utils/builder.js +81 -68
- package/dist/utils/builder.js.map +1 -1
- package/dist/utils/common.js +10 -44
- package/dist/utils/common.js.map +1 -1
- package/dist/utils/config.js +108 -144
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/context.js +16 -59
- package/dist/utils/context.js.map +1 -1
- package/dist/utils/dts.js +69 -146
- package/dist/utils/dts.js.map +1 -1
- package/dist/utils/input.js +44 -87
- package/dist/utils/input.js.map +1 -1
- package/dist/utils/language.js +15 -60
- package/dist/utils/language.js.map +1 -1
- package/dist/utils/libuildPlugins.js +27 -67
- package/dist/utils/libuildPlugins.js.map +1 -1
- package/dist/utils/log.js +14 -61
- package/dist/utils/log.js.map +1 -1
- package/dist/utils/onExit.js +14 -61
- package/dist/utils/onExit.js.map +1 -1
- package/dist/utils/path.js +13 -59
- package/dist/utils/path.js.map +1 -1
- package/dist/utils/print.js +57 -105
- package/dist/utils/print.js.map +1 -1
- package/dist/utils/style.js +54 -106
- package/dist/utils/style.js.map +1 -1
- package/dist/utils/tspathsTransform.js +44 -81
- package/dist/utils/tspathsTransform.js.map +1 -1
- package/package.json +11 -10
- package/scripts/debug-mode.js +23 -21
- package/dist/types/utils.js.map +0 -1
|
@@ -1,69 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
8
6
|
for (var name in all)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var __async = (__this, __arguments, generator) => {
|
|
29
|
-
return new Promise((resolve, reject) => {
|
|
30
|
-
var fulfilled = (value) => {
|
|
31
|
-
try {
|
|
32
|
-
step(generator.next(value));
|
|
33
|
-
} catch (e) {
|
|
34
|
-
reject(e);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
var rejected = (value) => {
|
|
38
|
-
try {
|
|
39
|
-
step(generator.throw(value));
|
|
40
|
-
} catch (e) {
|
|
41
|
-
reject(e);
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
45
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
46
|
-
});
|
|
47
|
-
};
|
|
48
|
-
var libuildPlugins_exports = {};
|
|
49
|
-
__export(libuildPlugins_exports, {
|
|
50
|
-
externalPlugin: () => externalPlugin,
|
|
51
|
-
watchPlugin: () => watchPlugin
|
|
7
|
+
Object.defineProperty(target, name, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: all[name]
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
_export(exports, {
|
|
13
|
+
watchPlugin: () => watchPlugin,
|
|
14
|
+
externalPlugin: () => externalPlugin
|
|
52
15
|
});
|
|
53
|
-
|
|
54
|
-
|
|
16
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
17
|
+
const _logger = require("@modern-js/utils/logger");
|
|
55
18
|
const watchPlugin = (api, config) => {
|
|
56
19
|
return {
|
|
57
20
|
name: "watch-plugin",
|
|
58
21
|
apply(compiler) {
|
|
59
|
-
compiler.hooks.watchChange.tap("watch-plugin", () =>
|
|
60
|
-
const { watchSectionTitle } =
|
|
61
|
-
const { SectionTitleStatus } =
|
|
22
|
+
compiler.hooks.watchChange.tap("watch-plugin", async () => {
|
|
23
|
+
const { watchSectionTitle } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("./log")));
|
|
24
|
+
const { SectionTitleStatus } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("../constants/log")));
|
|
62
25
|
const titleText = `[${config.buildType === "bundle" ? "Bundle" : "Bundleless"}:${config.format}_${config.target}]`;
|
|
63
|
-
|
|
26
|
+
_logger.logger.info(await watchSectionTitle(titleText, SectionTitleStatus.Log));
|
|
64
27
|
const runner = api.useHookRunners();
|
|
65
|
-
runner.buildWatchJs({
|
|
66
|
-
|
|
28
|
+
runner.buildWatchJs({
|
|
29
|
+
buildConfig: config
|
|
30
|
+
});
|
|
31
|
+
});
|
|
67
32
|
}
|
|
68
33
|
};
|
|
69
34
|
};
|
|
@@ -71,18 +36,13 @@ const externalPlugin = (config, options) => {
|
|
|
71
36
|
return {
|
|
72
37
|
name: "external-plugin",
|
|
73
38
|
apply(compiler) {
|
|
74
|
-
compiler.hooks.initialize.tapPromise("external-plugin", () =>
|
|
75
|
-
const { getFinalExternals } =
|
|
76
|
-
const finalExternals =
|
|
39
|
+
compiler.hooks.initialize.tapPromise("external-plugin", async () => {
|
|
40
|
+
const { getFinalExternals } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("./builder")));
|
|
41
|
+
const finalExternals = await getFinalExternals(config, options);
|
|
77
42
|
compiler.config.external = finalExternals;
|
|
78
|
-
})
|
|
43
|
+
});
|
|
79
44
|
}
|
|
80
45
|
};
|
|
81
46
|
};
|
|
82
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
83
|
-
0 && (module.exports = {
|
|
84
|
-
externalPlugin,
|
|
85
|
-
watchPlugin
|
|
86
|
-
});
|
|
87
47
|
|
|
88
48
|
//# sourceMappingURL=libuildPlugins.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":"
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;EAIaA,aAAW,MAAXA;EAuBAC,gBAAc,MAAdA;;;wBA3BU;AAIhB,MAAMD,cAAc,CACzBE,KACAC,WACkB;AAClB,SAAO;IACLC,MAAM;IACNC,MAAMC,UAAU;AACdA,eAASC,MAAMC,YAAYC,IAAI,gBAAgB,YAAY;AACzD,cAAM,EAAEC,kBAAiB,IAAK,MAAM,iFAAO;AAC3C,cAAM,EAAEC,mBAAkB,IAAK,MAAM,iFAAO;AAC5C,cAAMC,YAAY,IAChBT,OAAOU,cAAc,WAAW,WAAW,gBACzCV,OAAOW,UAAUX,OAAOY;AAE5BC,uBAAOC,KAAK,MAAMP,kBAAkBE,WAAWD,mBAAmBO,GAAG;AAErE,cAAMC,SAASjB,IAAIkB,eAAc;AACjCD,eAAOE,aAAa;UAAEC,aAAanB;QAAO;MAC5C;IACF;EACF;AACF;AAEO,MAAMF,iBAAiB,CAC5BE,QACAoB,YACkB;AAClB,SAAO;IACLnB,MAAM;IACNC,MAAMC,UAAU;AACdA,eAASC,MAAMiB,WAAWC,WAAW,mBAAmB,YAAY;AAClE,cAAM,EAAEC,kBAAiB,IAAK,MAAM,iFAAO;AAC3C,cAAMC,iBAAiB,MAAMD,kBAAkBvB,QAAQoB;AACvDjB,iBAASH,OAAOyB,WAAWD;MAC7B;IACF;EACF;AACF;","names":["watchPlugin","externalPlugin","api","config","name","apply","compiler","hooks","watchChange","tap","watchSectionTitle","SectionTitleStatus","titleText","buildType","format","target","logger","info","Log","runner","useHookRunners","buildWatchJs","buildConfig","options","initialize","tapPromise","getFinalExternals","finalExternals","external"],"sources":["../../src/utils/Users/bytedance/github/targeral/modern-js/packages/solutions/module-tools/src/utils/libuildPlugins.ts"],"sourcesContent":["import { logger } from '@modern-js/utils/logger';\nimport type { LibuildPlugin } from '@modern-js/libuild';\nimport type { BaseBuildConfig, PluginAPI, ModuleTools } from '../types';\n\nexport const watchPlugin = (\n api: PluginAPI<ModuleTools>,\n config: BaseBuildConfig,\n): LibuildPlugin => {\n return {\n name: 'watch-plugin',\n apply(compiler) {\n compiler.hooks.watchChange.tap('watch-plugin', async () => {\n const { watchSectionTitle } = await import('./log');\n const { SectionTitleStatus } = await import('../constants/log');\n const titleText = `[${\n config.buildType === 'bundle' ? 'Bundle' : 'Bundleless'\n }:${config.format}_${config.target}]`;\n\n logger.info(await watchSectionTitle(titleText, SectionTitleStatus.Log));\n\n const runner = api.useHookRunners();\n runner.buildWatchJs({ buildConfig: config });\n });\n },\n };\n};\n\nexport const externalPlugin = (\n config: BaseBuildConfig,\n options: { appDirectory: string },\n): LibuildPlugin => {\n return {\n name: 'external-plugin',\n apply(compiler) {\n compiler.hooks.initialize.tapPromise('external-plugin', async () => {\n const { getFinalExternals } = await import('./builder');\n const finalExternals = await getFinalExternals(config, options);\n compiler.config.external = finalExternals;\n });\n },\n };\n};\n"]}
|
package/dist/utils/log.js
CHANGED
|
@@ -1,68 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var __async = (__this, __arguments, generator) => {
|
|
29
|
-
return new Promise((resolve, reject) => {
|
|
30
|
-
var fulfilled = (value) => {
|
|
31
|
-
try {
|
|
32
|
-
step(generator.next(value));
|
|
33
|
-
} catch (e) {
|
|
34
|
-
reject(e);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
var rejected = (value) => {
|
|
38
|
-
try {
|
|
39
|
-
step(generator.throw(value));
|
|
40
|
-
} catch (e) {
|
|
41
|
-
reject(e);
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
45
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
46
|
-
});
|
|
47
|
-
};
|
|
48
|
-
var log_exports = {};
|
|
49
|
-
__export(log_exports, {
|
|
50
|
-
watchSectionTitle: () => watchSectionTitle
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
51
4
|
});
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
5
|
+
Object.defineProperty(exports, "watchSectionTitle", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: () => watchSectionTitle
|
|
8
|
+
});
|
|
9
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
10
|
+
const _log = require("../constants/log");
|
|
11
|
+
const watchSectionTitle = async (str, status, detailLog) => {
|
|
12
|
+
const { chalk } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/utils")));
|
|
13
|
+
if (status === _log.SectionTitleStatus.Success) {
|
|
57
14
|
return `${chalk.gray(str)} ${chalk.green("Successful")}`;
|
|
58
|
-
} else if (status ===
|
|
15
|
+
} else if (status === _log.SectionTitleStatus.Fail) {
|
|
59
16
|
return `${chalk.gray(str)} ${chalk.red("Build Failed")}`;
|
|
60
17
|
}
|
|
61
18
|
return `${chalk.gray(str)} ${detailLog ? detailLog : "Log:"}`;
|
|
62
|
-
}
|
|
63
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
64
|
-
0 && (module.exports = {
|
|
65
|
-
watchSectionTitle
|
|
66
|
-
});
|
|
19
|
+
};
|
|
67
20
|
|
|
68
21
|
//# sourceMappingURL=log.js.map
|
package/dist/utils/log.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":"
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;+BAEaA;;aAAAA;;;qBAFsB;AAE5B,MAAMA,oBAAoB,OAC/BC,KACAC,QACAC,cACG;AACH,QAAM,EAAEC,MAAK,IAAK,MAAM,iFAAO;AAC/B,MAAIF,WAAWG,wBAAmBC,SAAS;AACzC,WAAO,GAAGF,MAAMG,KAAKN,QAAQG,MAAMI,MAAM;EAC3C,WAAWN,WAAWG,wBAAmBI,MAAM;AAC7C,WAAO,GAAGL,MAAMG,KAAKN,QAAQG,MAAMM,IAAI;EACzC;AAEA,SAAO,GAAGN,MAAMG,KAAKN,QAAQE,YAAYA,YAAY;AACvD;","names":["watchSectionTitle","str","status","detailLog","chalk","SectionTitleStatus","Success","gray","green","Fail","red"],"sources":["../../src/utils/Users/bytedance/github/targeral/modern-js/packages/solutions/module-tools/src/utils/log.ts"],"sourcesContent":["import { SectionTitleStatus } from '../constants/log';\n\nexport const watchSectionTitle = async (\n str: string,\n status: SectionTitleStatus,\n detailLog?: string,\n) => {\n const { chalk } = await import('@modern-js/utils');\n if (status === SectionTitleStatus.Success) {\n return `${chalk.gray(str)} ${chalk.green('Successful')}`;\n } else if (status === SectionTitleStatus.Fail) {\n return `${chalk.gray(str)} ${chalk.red('Build Failed')}`;\n }\n\n return `${chalk.gray(str)} ${detailLog ? detailLog : 'Log:'}`;\n};\n"]}
|
package/dist/utils/onExit.js
CHANGED
|
@@ -1,67 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var __async = (__this, __arguments, generator) => {
|
|
29
|
-
return new Promise((resolve, reject) => {
|
|
30
|
-
var fulfilled = (value) => {
|
|
31
|
-
try {
|
|
32
|
-
step(generator.next(value));
|
|
33
|
-
} catch (e) {
|
|
34
|
-
reject(e);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
var rejected = (value) => {
|
|
38
|
-
try {
|
|
39
|
-
step(generator.throw(value));
|
|
40
|
-
} catch (e) {
|
|
41
|
-
reject(e);
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
45
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
46
|
-
});
|
|
47
|
-
};
|
|
48
|
-
var onExit_exports = {};
|
|
49
|
-
__export(onExit_exports, {
|
|
50
|
-
addExitListener: () => addExitListener
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "addExitListener", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: () => addExitListener
|
|
51
8
|
});
|
|
52
|
-
|
|
53
|
-
const addExitListener = (fn) =>
|
|
54
|
-
const { default: onExit } =
|
|
55
|
-
onExit((code) =>
|
|
9
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
10
|
+
const addExitListener = async (fn) => {
|
|
11
|
+
const { default: onExit } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("../../compiled/signal-exit")));
|
|
12
|
+
onExit(async (code) => {
|
|
56
13
|
if (code === 0) {
|
|
57
14
|
return;
|
|
58
15
|
}
|
|
59
|
-
|
|
60
|
-
})
|
|
61
|
-
}
|
|
62
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
63
|
-
0 && (module.exports = {
|
|
64
|
-
addExitListener
|
|
65
|
-
});
|
|
16
|
+
await fn();
|
|
17
|
+
});
|
|
18
|
+
};
|
|
66
19
|
|
|
67
20
|
//# sourceMappingURL=onExit.js.map
|
package/dist/utils/onExit.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":"
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;+BAAaA;;aAAAA;;;AAAN,MAAMA,kBAAkB,OAAOC,OAA4B;AAChE,QAAM,EAAEC,SAASC,OAAM,IAAK,MAAM,iFAAO;AAEzCA,SAAO,OAAMC,SAAQ;AACnB,QAAIA,SAAS,GAAG;AACd;IACF;AAEA,UAAMH;EACR;AACF;","names":["addExitListener","fn","default","onExit","code"],"sources":["../../src/utils/Users/bytedance/github/targeral/modern-js/packages/solutions/module-tools/src/utils/onExit.ts"],"sourcesContent":["export const addExitListener = async (fn: () => Promise<void>) => {\n const { default: onExit } = await import('../../compiled/signal-exit');\n\n onExit(async code => {\n if (code === 0) {\n return;\n }\n\n await fn();\n });\n};\n"]}
|
package/dist/utils/path.js
CHANGED
|
@@ -1,63 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var __async = (__this, __arguments, generator) => {
|
|
29
|
-
return new Promise((resolve, reject) => {
|
|
30
|
-
var fulfilled = (value) => {
|
|
31
|
-
try {
|
|
32
|
-
step(generator.next(value));
|
|
33
|
-
} catch (e) {
|
|
34
|
-
reject(e);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
var rejected = (value) => {
|
|
38
|
-
try {
|
|
39
|
-
step(generator.throw(value));
|
|
40
|
-
} catch (e) {
|
|
41
|
-
reject(e);
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
45
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
46
|
-
});
|
|
47
|
-
};
|
|
48
|
-
var path_exports = {};
|
|
49
|
-
__export(path_exports, {
|
|
50
|
-
getCompiledPath: () => getCompiledPath
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
51
4
|
});
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const { slash } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
56
|
-
return slash(import_path.default.join(__dirname, "../../compiled", packageName));
|
|
57
|
-
});
|
|
58
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
59
|
-
0 && (module.exports = {
|
|
60
|
-
getCompiledPath
|
|
5
|
+
Object.defineProperty(exports, "getCompiledPath", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: () => getCompiledPath
|
|
61
8
|
});
|
|
9
|
+
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
10
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
11
|
+
const _path = /* @__PURE__ */ _interop_require_default._(require("path"));
|
|
12
|
+
const getCompiledPath = async (packageName) => {
|
|
13
|
+
const { slash } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/utils")));
|
|
14
|
+
return slash(_path.default.join(__dirname, "../../compiled", packageName));
|
|
15
|
+
};
|
|
62
16
|
|
|
63
17
|
//# sourceMappingURL=path.js.map
|
package/dist/utils/path.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":"
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;+BAEaA;;aAAAA;;;;iEAFI;AAEV,MAAMA,kBAAkB,OAAOC,gBAAwB;AAC5D,QAAM,EAAEC,MAAK,IAAK,MAAM,iFAAO;AAC/B,SAAOA,MAAMC,cAAKC,KAAKC,WAAW,kBAAkBJ;AACtD;","names":["getCompiledPath","packageName","slash","path","join","__dirname"],"sources":["../../src/utils/Users/bytedance/github/targeral/modern-js/packages/solutions/module-tools/src/utils/path.ts"],"sourcesContent":["import path from 'path';\n\nexport const getCompiledPath = async (packageName: string) => {\n const { slash } = await import('@modern-js/utils');\n return slash(path.join(__dirname, '../../compiled', packageName));\n};\n"]}
|
package/dist/utils/print.js
CHANGED
|
@@ -1,71 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
8
6
|
for (var name in all)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var __async = (__this, __arguments, generator) => {
|
|
29
|
-
return new Promise((resolve2, reject) => {
|
|
30
|
-
var fulfilled = (value) => {
|
|
31
|
-
try {
|
|
32
|
-
step(generator.next(value));
|
|
33
|
-
} catch (e) {
|
|
34
|
-
reject(e);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
var rejected = (value) => {
|
|
38
|
-
try {
|
|
39
|
-
step(generator.throw(value));
|
|
40
|
-
} catch (e) {
|
|
41
|
-
reject(e);
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
var step = (x) => x.done ? resolve2(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
45
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
46
|
-
});
|
|
47
|
-
};
|
|
48
|
-
var print_exports = {};
|
|
49
|
-
__export(print_exports, {
|
|
50
|
-
addDtsFiles: () => addDtsFiles,
|
|
51
|
-
addOutputChunk: () => addOutputChunk,
|
|
52
|
-
addRollupChunk: () => addRollupChunk,
|
|
7
|
+
Object.defineProperty(target, name, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: all[name]
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
_export(exports, {
|
|
53
13
|
bundleFiles: () => bundleFiles,
|
|
54
14
|
bundlelessFiles: () => bundlelessFiles,
|
|
15
|
+
addOutputChunk: () => addOutputChunk,
|
|
16
|
+
addRollupChunk: () => addRollupChunk,
|
|
17
|
+
addDtsFiles: () => addDtsFiles,
|
|
55
18
|
printFileSize: () => printFileSize,
|
|
56
19
|
printSucceed: () => printSucceed
|
|
57
20
|
});
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
21
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
22
|
+
const _path = require("path");
|
|
23
|
+
const _utils = require("@modern-js/utils");
|
|
24
|
+
const _log = require("../constants/log");
|
|
62
25
|
const bundleFiles = [];
|
|
63
26
|
const bundlelessFiles = [];
|
|
64
27
|
const addOutputChunk = (outputChunk, appDirectory, isBundle) => {
|
|
65
28
|
const files = Array.from(outputChunk).map((val) => {
|
|
66
29
|
const [path, chunk] = val;
|
|
67
30
|
return {
|
|
68
|
-
name: (0,
|
|
31
|
+
name: (0, _path.relative)(appDirectory, path),
|
|
69
32
|
size: chunk.contents.length
|
|
70
33
|
};
|
|
71
34
|
});
|
|
@@ -77,43 +40,49 @@ const addOutputChunk = (outputChunk, appDirectory, isBundle) => {
|
|
|
77
40
|
};
|
|
78
41
|
const addRollupChunk = (rollupOutput, appDirectory, distDir) => {
|
|
79
42
|
const { output } = rollupOutput;
|
|
80
|
-
bundleFiles.push(
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
})
|
|
88
|
-
);
|
|
43
|
+
bundleFiles.push(...output.map((o) => {
|
|
44
|
+
return {
|
|
45
|
+
name: (0, _path.relative)(appDirectory, (0, _path.resolve)(distDir, o.fileName)),
|
|
46
|
+
// only d.ts, is outputChunk not outputAsset
|
|
47
|
+
size: o.code.length
|
|
48
|
+
};
|
|
49
|
+
}));
|
|
89
50
|
};
|
|
90
|
-
const addDtsFiles = (distDir, appDirectory) =>
|
|
91
|
-
const { fastGlob, slash } =
|
|
92
|
-
const files =
|
|
51
|
+
const addDtsFiles = async (distDir, appDirectory) => {
|
|
52
|
+
const { fastGlob, slash } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/utils")));
|
|
53
|
+
const files = await fastGlob(`${slash(distDir)}**/*.d.ts`, {
|
|
93
54
|
stats: true
|
|
94
55
|
});
|
|
95
|
-
bundlelessFiles.push(
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
);
|
|
103
|
-
});
|
|
56
|
+
bundlelessFiles.push(...files.map((file) => {
|
|
57
|
+
return {
|
|
58
|
+
name: (0, _path.relative)(appDirectory, file.path),
|
|
59
|
+
size: file.stats.size
|
|
60
|
+
};
|
|
61
|
+
}));
|
|
62
|
+
};
|
|
104
63
|
const printFileSize = () => {
|
|
105
64
|
printBundlelessInfo();
|
|
106
65
|
printBundleFiles();
|
|
107
66
|
};
|
|
108
67
|
const printSucceed = (totalDuration) => {
|
|
109
|
-
const time =
|
|
110
|
-
|
|
68
|
+
const time = _utils.chalk.cyan(`${totalDuration / 1e3}s`);
|
|
69
|
+
_utils.logger.info(`${_log.buildSuccessText} in ${time}`);
|
|
111
70
|
};
|
|
112
71
|
const prettyBytes = (bytes) => {
|
|
113
72
|
if (bytes === 0) {
|
|
114
73
|
return "0 B";
|
|
115
74
|
}
|
|
116
|
-
const unit = [
|
|
75
|
+
const unit = [
|
|
76
|
+
"B",
|
|
77
|
+
"KB",
|
|
78
|
+
"MB",
|
|
79
|
+
"GB",
|
|
80
|
+
"TB",
|
|
81
|
+
"PB",
|
|
82
|
+
"EB",
|
|
83
|
+
"ZB",
|
|
84
|
+
"YB"
|
|
85
|
+
];
|
|
117
86
|
const exp = Math.floor(Math.log(bytes) / Math.log(1024));
|
|
118
87
|
return `${(bytes / Math.pow(1024, exp)).toFixed(2)} ${unit[exp]}`;
|
|
119
88
|
};
|
|
@@ -121,19 +90,14 @@ const printBundleFiles = () => {
|
|
|
121
90
|
if (bundleFiles.length === 0) {
|
|
122
91
|
return;
|
|
123
92
|
}
|
|
124
|
-
const longestFileLength = bundleFiles.reduce(
|
|
125
|
-
|
|
126
|
-
import_log.reportFile1LineText.length
|
|
127
|
-
);
|
|
128
|
-
import_utils.logger.info(`Bundle generated ${bundleFiles.length} files
|
|
93
|
+
const longestFileLength = bundleFiles.reduce((max, str) => Math.max(max, str.name.length), _log.reportFile1LineText.length);
|
|
94
|
+
_utils.logger.info(`Bundle generated ${bundleFiles.length} files
|
|
129
95
|
`);
|
|
130
|
-
const headerRow =
|
|
131
|
-
|
|
96
|
+
const headerRow = _log.reportFile1LineText + " ".repeat(longestFileLength - 10) + _log.reportFile2LineText;
|
|
97
|
+
_utils.logger.log(_utils.chalk.bold(_utils.chalk.green(headerRow)));
|
|
132
98
|
bundleFiles.forEach(({ name, size }) => {
|
|
133
|
-
const infoRow = `${name}${" ".repeat(
|
|
134
|
-
|
|
135
|
-
)}${prettyBytes(size)}`;
|
|
136
|
-
import_utils.logger.log(infoRow);
|
|
99
|
+
const infoRow = `${name}${" ".repeat(longestFileLength - name.length + 2)}${prettyBytes(size)}`;
|
|
100
|
+
_utils.logger.log(infoRow);
|
|
137
101
|
});
|
|
138
102
|
};
|
|
139
103
|
const printBundlelessInfo = () => {
|
|
@@ -144,20 +108,8 @@ const printBundlelessInfo = () => {
|
|
|
144
108
|
const totalSize = bundlelessFiles.reduce((total, file) => {
|
|
145
109
|
return total + file.size;
|
|
146
110
|
}, 0);
|
|
147
|
-
const info = `Bundleless generated ${count} files, the total size is ${
|
|
148
|
-
|
|
149
|
-
)}`;
|
|
150
|
-
import_utils.logger.info(info);
|
|
111
|
+
const info = `Bundleless generated ${count} files, the total size is ${_utils.chalk.cyan(prettyBytes(totalSize))}`;
|
|
112
|
+
_utils.logger.info(info);
|
|
151
113
|
};
|
|
152
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
153
|
-
0 && (module.exports = {
|
|
154
|
-
addDtsFiles,
|
|
155
|
-
addOutputChunk,
|
|
156
|
-
addRollupChunk,
|
|
157
|
-
bundleFiles,
|
|
158
|
-
bundlelessFiles,
|
|
159
|
-
printFileSize,
|
|
160
|
-
printSucceed
|
|
161
|
-
});
|
|
162
114
|
|
|
163
115
|
//# sourceMappingURL=print.js.map
|