@modern-js/module-tools 2.10.0 → 2.10.1-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/dist/build.js +9 -29
- package/dist/build.js.map +1 -1
- package/dist/builder/build.js +48 -86
- package/dist/builder/build.js.map +1 -1
- package/dist/builder/clear.js +9 -29
- package/dist/builder/clear.js.map +1 -1
- package/dist/builder/copy.js +39 -78
- package/dist/builder/copy.js.map +1 -1
- package/dist/builder/dts/rollup.js +26 -61
- package/dist/builder/dts/rollup.js.map +1 -1
- package/dist/builder/dts/tsc.js +37 -77
- package/dist/builder/dts/tsc.js.map +1 -1
- package/dist/builder/index.js +16 -36
- package/dist/builder/index.js.map +1 -1
- package/dist/builder/platform.js +13 -33
- package/dist/builder/platform.js.map +1 -1
- package/dist/cli.js +23 -45
- package/dist/cli.js.map +1 -1
- package/dist/command.js +39 -76
- package/dist/command.js.map +1 -1
- package/dist/config/defineConfig.js +2 -18
- package/dist/config/defineConfig.js.map +1 -1
- package/dist/config/normalize.js +45 -73
- package/dist/config/normalize.js.map +1 -1
- package/dist/config/transformLegacyConfig.js +90 -130
- package/dist/config/transformLegacyConfig.js.map +1 -1
- package/dist/constants/buildPresets.js +14 -23
- package/dist/constants/buildPresets.js.map +1 -1
- package/dist/dev.js +19 -43
- package/dist/dev.js.map +1 -1
- package/dist/error.js +7 -2
- package/dist/error.js.map +1 -1
- package/dist/hooks/index.js +6 -15
- package/dist/hooks/index.js.map +1 -1
- package/dist/utils/builder.js +7 -27
- package/dist/utils/builder.js.map +1 -1
- package/dist/utils/common.js +3 -19
- package/dist/utils/common.js.map +1 -1
- package/dist/utils/config.js +57 -83
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/context.js +3 -23
- package/dist/utils/context.js.map +1 -1
- package/dist/utils/dts.js +25 -64
- package/dist/utils/dts.js.map +1 -1
- package/dist/utils/input.js +14 -34
- package/dist/utils/input.js.map +1 -1
- package/dist/utils/language.js +3 -23
- package/dist/utils/language.js.map +1 -1
- package/dist/utils/libuildPlugins.js +9 -29
- package/dist/utils/libuildPlugins.js.map +1 -1
- package/dist/utils/log.js +3 -23
- package/dist/utils/log.js.map +1 -1
- package/dist/utils/onExit.js +6 -26
- package/dist/utils/onExit.js.map +1 -1
- package/dist/utils/path.js +3 -23
- package/dist/utils/path.js.map +1 -1
- package/dist/utils/print.js +4 -24
- package/dist/utils/print.js.map +1 -1
- package/dist/utils/style.js +29 -52
- package/dist/utils/style.js.map +1 -1
- package/package.json +7 -7
package/dist/utils/context.js
CHANGED
|
@@ -25,37 +25,17 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
25
25
|
mod
|
|
26
26
|
));
|
|
27
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var __async = (__this, __arguments, generator) => {
|
|
29
|
-
return new Promise((resolve, reject) => {
|
|
30
|
-
var fulfilled = (value) => {
|
|
31
|
-
try {
|
|
32
|
-
step(generator.next(value));
|
|
33
|
-
} catch (e) {
|
|
34
|
-
reject(e);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
var rejected = (value) => {
|
|
38
|
-
try {
|
|
39
|
-
step(generator.throw(value));
|
|
40
|
-
} catch (e) {
|
|
41
|
-
reject(e);
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
45
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
46
|
-
});
|
|
47
|
-
};
|
|
48
28
|
var context_exports = {};
|
|
49
29
|
__export(context_exports, {
|
|
50
30
|
initModuleContext: () => initModuleContext
|
|
51
31
|
});
|
|
52
32
|
module.exports = __toCommonJS(context_exports);
|
|
53
|
-
const initModuleContext = (api) =>
|
|
54
|
-
const { isTypescript } =
|
|
33
|
+
const initModuleContext = async (api) => {
|
|
34
|
+
const { isTypescript } = await Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
55
35
|
const { appDirectory, srcDirectory } = api.useAppContext();
|
|
56
36
|
const isTsProject = isTypescript(appDirectory);
|
|
57
37
|
return { isTsProject, appDirectory, srcDirectory };
|
|
58
|
-
}
|
|
38
|
+
};
|
|
59
39
|
// Annotate the CommonJS export names for ESM import in node:
|
|
60
40
|
0 && (module.exports = {
|
|
61
41
|
initModuleContext
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":"
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,MAAM,oBAAoB,OAAO,QAAgC;AACtE,QAAM,EAAE,aAAa,IAAI,MAAM,6CAAO,kBAAkB;AACxD,QAAM,EAAE,cAAc,aAAa,IAAI,IAAI,cAAc;AACzD,QAAM,cAAc,aAAa,YAAY;AAE7C,SAAO,EAAE,aAAa,cAAc,aAAa;AACnD;;;;;","names":[],"sources":["../../src/utils/context.ts"],"sourcesContent":["import type { PluginAPI } from '@modern-js/core';\nimport type { ModuleTools } from '../types';\n\nexport const initModuleContext = async (api: PluginAPI<ModuleTools>) => {\n const { isTypescript } = await import('@modern-js/utils');\n const { appDirectory, srcDirectory } = api.useAppContext();\n const isTsProject = isTypescript(appDirectory);\n\n return { isTsProject, appDirectory, srcDirectory };\n};\n"]}
|
package/dist/utils/dts.js
CHANGED
|
@@ -1,26 +1,9 @@
|
|
|
1
1
|
var __create = Object.create;
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
-
var __defProps = Object.defineProperties;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
9
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
-
var __spreadValues = (a, b) => {
|
|
13
|
-
for (var prop in b || (b = {}))
|
|
14
|
-
if (__hasOwnProp.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
if (__getOwnPropSymbols)
|
|
17
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
-
if (__propIsEnum.call(b, prop))
|
|
19
|
-
__defNormalProp(a, prop, b[prop]);
|
|
20
|
-
}
|
|
21
|
-
return a;
|
|
22
|
-
};
|
|
23
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
7
|
var __export = (target, all) => {
|
|
25
8
|
for (var name in all)
|
|
26
9
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -42,26 +25,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
42
25
|
mod
|
|
43
26
|
));
|
|
44
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
45
|
-
var __async = (__this, __arguments, generator) => {
|
|
46
|
-
return new Promise((resolve, reject) => {
|
|
47
|
-
var fulfilled = (value) => {
|
|
48
|
-
try {
|
|
49
|
-
step(generator.next(value));
|
|
50
|
-
} catch (e) {
|
|
51
|
-
reject(e);
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
var rejected = (value) => {
|
|
55
|
-
try {
|
|
56
|
-
step(generator.throw(value));
|
|
57
|
-
} catch (e) {
|
|
58
|
-
reject(e);
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
62
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
63
|
-
});
|
|
64
|
-
};
|
|
65
28
|
var dts_exports = {};
|
|
66
29
|
__export(dts_exports, {
|
|
67
30
|
assignTsConfigPath: () => assignTsConfigPath,
|
|
@@ -71,9 +34,9 @@ __export(dts_exports, {
|
|
|
71
34
|
});
|
|
72
35
|
module.exports = __toCommonJS(dts_exports);
|
|
73
36
|
var import_path = __toESM(require("path"));
|
|
74
|
-
const generatorTsConfig = (config) =>
|
|
75
|
-
const { fs, nanoid } =
|
|
76
|
-
const { dtsTempDirectory } =
|
|
37
|
+
const generatorTsConfig = async (config) => {
|
|
38
|
+
const { fs, nanoid } = await Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
39
|
+
const { dtsTempDirectory } = await Promise.resolve().then(() => __toESM(require("../constants/dts")));
|
|
77
40
|
const { appDirectory, sourceDir: absSourceDir, tsconfigPath } = config;
|
|
78
41
|
const tempDistAbsRootPath = import_path.default.join(
|
|
79
42
|
appDirectory,
|
|
@@ -104,19 +67,19 @@ const generatorTsConfig = (config) => __async(void 0, null, function* () {
|
|
|
104
67
|
tempDistAbsRootPath,
|
|
105
68
|
tempDistAbsSrcPath: tempDistAbsOurDir
|
|
106
69
|
};
|
|
107
|
-
}
|
|
108
|
-
const getTscBinPath = (appDirectory) =>
|
|
109
|
-
const { fs } =
|
|
110
|
-
const { default: findUp, exists: pathExists } =
|
|
111
|
-
const tscBinFile =
|
|
112
|
-
(directory) =>
|
|
70
|
+
};
|
|
71
|
+
const getTscBinPath = async (appDirectory) => {
|
|
72
|
+
const { fs } = await Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
73
|
+
const { default: findUp, exists: pathExists } = await Promise.resolve().then(() => __toESM(require("../../compiled/find-up")));
|
|
74
|
+
const tscBinFile = await findUp(
|
|
75
|
+
async (directory) => {
|
|
113
76
|
const targetFilePath = import_path.default.join(directory, "./node_modules/.bin/tsc");
|
|
114
|
-
const hasTscBinFile =
|
|
77
|
+
const hasTscBinFile = await pathExists(targetFilePath);
|
|
115
78
|
if (hasTscBinFile) {
|
|
116
79
|
return targetFilePath;
|
|
117
80
|
}
|
|
118
81
|
return void 0;
|
|
119
|
-
}
|
|
82
|
+
},
|
|
120
83
|
{ cwd: appDirectory }
|
|
121
84
|
);
|
|
122
85
|
if (!tscBinFile || !fs.existsSync(tscBinFile)) {
|
|
@@ -125,38 +88,36 @@ const getTscBinPath = (appDirectory) => __async(void 0, null, function* () {
|
|
|
125
88
|
);
|
|
126
89
|
}
|
|
127
90
|
return tscBinFile;
|
|
128
|
-
}
|
|
129
|
-
const resolveAlias =
|
|
130
|
-
var _a, _b;
|
|
91
|
+
};
|
|
92
|
+
const resolveAlias = async (config, options, watchFilenames = []) => {
|
|
131
93
|
const { userTsconfig, tempDistAbsSrcPath, tempDistAbsRootPath } = options;
|
|
132
|
-
const { globby, fs } =
|
|
133
|
-
const { transformDtsAlias } =
|
|
94
|
+
const { globby, fs } = await Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
95
|
+
const { transformDtsAlias } = await Promise.resolve().then(() => __toESM(require("./tspathsTransform")));
|
|
134
96
|
const { distAbsPath } = config;
|
|
135
97
|
const dtsDistPath = `${tempDistAbsSrcPath}/**/*.d.ts`;
|
|
136
98
|
const dtsFilenames = watchFilenames.length > 0 ? watchFilenames : globby.sync(dtsDistPath, { absolute: true });
|
|
137
99
|
const result = transformDtsAlias({
|
|
138
100
|
filenames: dtsFilenames,
|
|
139
101
|
baseUrl: tempDistAbsRootPath,
|
|
140
|
-
paths:
|
|
102
|
+
paths: userTsconfig.compilerOptions?.paths ?? {}
|
|
141
103
|
});
|
|
142
104
|
for (const r of result) {
|
|
143
105
|
fs.writeFileSync(r.path, r.content);
|
|
144
106
|
}
|
|
145
|
-
|
|
146
|
-
}
|
|
147
|
-
const assignTsConfigPath = (config, options) =>
|
|
148
|
-
|
|
149
|
-
const { defaultTsConfigPath } = yield Promise.resolve().then(() => __toESM(require("../constants/dts")));
|
|
107
|
+
await fs.copy(tempDistAbsSrcPath, distAbsPath);
|
|
108
|
+
};
|
|
109
|
+
const assignTsConfigPath = async (config, options) => {
|
|
110
|
+
const { defaultTsConfigPath } = await Promise.resolve().then(() => __toESM(require("../constants/dts")));
|
|
150
111
|
if (typeof options.tsconfig === "string" && options.tsconfig !== defaultTsConfigPath) {
|
|
151
|
-
config.dts =
|
|
112
|
+
config.dts = {
|
|
152
113
|
only: false,
|
|
153
|
-
distPath: "./"
|
|
154
|
-
|
|
114
|
+
distPath: "./",
|
|
115
|
+
...config.dts ?? {},
|
|
155
116
|
tsconfigPath: options.tsconfig
|
|
156
|
-
}
|
|
117
|
+
};
|
|
157
118
|
}
|
|
158
119
|
return config;
|
|
159
|
-
}
|
|
120
|
+
};
|
|
160
121
|
// Annotate the CommonJS export names for ESM import in node:
|
|
161
122
|
0 && (module.exports = {
|
|
162
123
|
assignTsConfigPath,
|
package/dist/utils/dts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":"
|
|
1
|
+
{"version":3,"file":null,"mappings":"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","names":[],"sources":["../../src/utils/dts.ts"],"sourcesContent":["import path from 'path';\n// import type { NodePath } from '../../compiled/@babel/traverse';\n// import type * as tt from '../../compiled/@babel/types';\n// import t from '../../compiled/@babel/types';\nimport type {\n ITsconfig,\n BundlelessGeneratorDtsConfig,\n BuildCommandOptions,\n BaseBuildConfig,\n // AliasOption,\n} from '../types';\n\nexport const generatorTsConfig = async (\n config: BundlelessGeneratorDtsConfig,\n) => {\n const { fs, nanoid } = await import('@modern-js/utils');\n const { dtsTempDirectory } = await import('../constants/dts');\n\n const { appDirectory, sourceDir: absSourceDir, tsconfigPath } = config;\n const tempDistAbsRootPath = path.join(\n appDirectory,\n `${dtsTempDirectory}/${nanoid()}`,\n );\n const tempDistAbsOurDir = path.join(\n tempDistAbsRootPath,\n path.relative(appDirectory, absSourceDir),\n );\n\n const tempTsconfigPath = path.join(tempDistAbsRootPath, `tsconfig.json`);\n fs.ensureFileSync(tempTsconfigPath);\n\n const extendsPath = path.join(\n path.relative(path.dirname(tempTsconfigPath), path.dirname(tsconfigPath)),\n path.basename(tempTsconfigPath),\n );\n\n const resetConfig: ITsconfig = {\n extends: extendsPath,\n compilerOptions: {\n // Ensure that .d.ts files are created by tsc, but not .js files\n declaration: true,\n emitDeclarationOnly: true,\n outDir: tempDistAbsOurDir,\n },\n };\n\n fs.writeJSONSync(tempTsconfigPath, resetConfig);\n\n return {\n tempTsconfigPath,\n tempDistAbsRootPath,\n tempDistAbsSrcPath: tempDistAbsOurDir,\n };\n};\n\nexport const getTscBinPath = async (appDirectory: string) => {\n const { fs } = await import('@modern-js/utils');\n const { default: findUp, exists: pathExists } = await import(\n '../../compiled/find-up'\n );\n const tscBinFile = await findUp(\n async (directory: string) => {\n const targetFilePath = path.join(directory, './node_modules/.bin/tsc');\n const hasTscBinFile = await pathExists(targetFilePath);\n if (hasTscBinFile) {\n return targetFilePath;\n }\n return undefined;\n },\n { cwd: appDirectory },\n );\n\n if (!tscBinFile || !fs.existsSync(tscBinFile)) {\n throw new Error(\n 'Failed to excute the `tsc` command, please check if `typescript` is installed correctly in the current directory.',\n );\n }\n\n return tscBinFile;\n};\n\nexport const resolveAlias = async (\n config: BundlelessGeneratorDtsConfig,\n options: {\n userTsconfig: ITsconfig;\n tempTsconfigPath: string;\n tempDistAbsRootPath: string;\n tempDistAbsSrcPath: string;\n },\n watchFilenames: string[] = [],\n) => {\n const { userTsconfig, tempDistAbsSrcPath, tempDistAbsRootPath } = options;\n const { globby, fs } = await import('@modern-js/utils');\n const { transformDtsAlias } = await import('./tspathsTransform');\n const { distAbsPath } = config;\n const dtsDistPath = `${tempDistAbsSrcPath}/**/*.d.ts`;\n const dtsFilenames =\n watchFilenames.length > 0\n ? watchFilenames\n : globby.sync(dtsDistPath, { absolute: true });\n const result = transformDtsAlias({\n filenames: dtsFilenames,\n baseUrl: tempDistAbsRootPath,\n paths: userTsconfig.compilerOptions?.paths ?? {},\n });\n for (const r of result) {\n fs.writeFileSync(r.path, r.content);\n }\n\n await fs.copy(tempDistAbsSrcPath, distAbsPath);\n};\n\n// export const matchesPattern = (calleePath: NodePath, pattern: string) => {\n// const { node } = calleePath;\n\n// if (t.isMemberExpression(node)) {\n// return calleePath.matchesPattern(pattern);\n// }\n\n// if (!t.isIdentifier(node) || pattern.includes('.')) {\n// return false;\n// }\n\n// const name = pattern.split('.')[0];\n\n// return node.name === name;\n// };\n\n// export const isImportCall = (calleePath: NodePath<tt.CallExpression>) => {\n// return t.isImport(calleePath.node.callee);\n// };\n\n// export const verifyTsConfigPaths = async (\n// tsconfigAbsPath: string,\n// userAliases?: AliasOption,\n// ) => {\n// const { readTsConfigByFile, chalk } = await import('@modern-js/utils');\n// if (!userAliases) {\n// return;\n// }\n\n// const paths = Object.keys(\n// readTsConfigByFile(tsconfigAbsPath).compilerOptions?.paths || {},\n// ).map(key => key.replace(/\\/\\*$/, ''));\n\n// Object.keys(userAliases).forEach(name => {\n// if (paths.includes(name)) {\n// throw new Error(\n// chalk.red(\n// `It looks like you have configured the alias ${chalk.bold(\n// name,\n// )} in both the modern.config file and tsconfig.json.\\n Please remove the configuration in modern.config file and just keep the configuration in tsconfig.json.`,\n// ),\n// );\n// }\n// });\n// };\n\nexport const assignTsConfigPath = async (\n config: BaseBuildConfig,\n options: BuildCommandOptions,\n) => {\n const { defaultTsConfigPath } = await import('../constants/dts');\n\n // user run `build --tsconfig './tsconfig.build.json'`\n if (\n typeof options.tsconfig === 'string' &&\n options.tsconfig !== defaultTsConfigPath\n ) {\n config.dts = {\n only: false,\n distPath: './',\n ...(config.dts ?? {}),\n tsconfigPath: options.tsconfig,\n };\n }\n\n return config;\n};\n"]}
|
package/dist/utils/input.js
CHANGED
|
@@ -25,26 +25,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
25
25
|
mod
|
|
26
26
|
));
|
|
27
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var __async = (__this, __arguments, generator) => {
|
|
29
|
-
return new Promise((resolve, reject) => {
|
|
30
|
-
var fulfilled = (value) => {
|
|
31
|
-
try {
|
|
32
|
-
step(generator.next(value));
|
|
33
|
-
} catch (e) {
|
|
34
|
-
reject(e);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
var rejected = (value) => {
|
|
38
|
-
try {
|
|
39
|
-
step(generator.throw(value));
|
|
40
|
-
} catch (e) {
|
|
41
|
-
reject(e);
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
45
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
46
|
-
});
|
|
47
|
-
};
|
|
48
28
|
var input_exports = {};
|
|
49
29
|
__export(input_exports, {
|
|
50
30
|
addInputToPreset: () => addInputToPreset,
|
|
@@ -54,8 +34,8 @@ __export(input_exports, {
|
|
|
54
34
|
});
|
|
55
35
|
module.exports = __toCommonJS(input_exports);
|
|
56
36
|
var import_path = __toESM(require("path"));
|
|
57
|
-
const getAbsInput = (entry, options) =>
|
|
58
|
-
const { slash } =
|
|
37
|
+
const getAbsInput = async (entry, options) => {
|
|
38
|
+
const { slash } = await Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
59
39
|
const { appDirectory } = options;
|
|
60
40
|
if (Array.isArray(entry)) {
|
|
61
41
|
return entry.map(
|
|
@@ -67,28 +47,28 @@ const getAbsInput = (entry, options) => __async(void 0, null, function* () {
|
|
|
67
47
|
newEntry[key] = import_path.default.isAbsolute(entry[key]) ? slash(entry[key]) : slash(import_path.default.join(appDirectory, entry[key]));
|
|
68
48
|
}
|
|
69
49
|
return newEntry;
|
|
70
|
-
}
|
|
71
|
-
const addInputToPreset = (config, context) =>
|
|
50
|
+
};
|
|
51
|
+
const addInputToPreset = async (config, context) => {
|
|
72
52
|
if (Array.isArray(config)) {
|
|
73
53
|
for (const c of config) {
|
|
74
54
|
if (c.buildType === "bundle") {
|
|
75
|
-
c.input =
|
|
55
|
+
c.input = await getDefaultIndexEntry(context);
|
|
76
56
|
} else if (c.buildType === "bundleless") {
|
|
77
57
|
c.sourceDir = "./src";
|
|
78
58
|
}
|
|
79
59
|
}
|
|
80
60
|
} else if (config.buildType === "bundle") {
|
|
81
|
-
config.input =
|
|
61
|
+
config.input = await getDefaultIndexEntry(context);
|
|
82
62
|
} else if (config.buildType === "bundleless") {
|
|
83
63
|
config.sourceDir = "./src";
|
|
84
64
|
}
|
|
85
65
|
return config;
|
|
86
|
-
}
|
|
87
|
-
const getDefaultIndexEntry =
|
|
66
|
+
};
|
|
67
|
+
const getDefaultIndexEntry = async ({
|
|
88
68
|
isTsProject,
|
|
89
69
|
appDirectory
|
|
90
|
-
}) {
|
|
91
|
-
const { fs } =
|
|
70
|
+
}) => {
|
|
71
|
+
const { fs } = await Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
92
72
|
let entry = isTsProject ? import_path.default.join(appDirectory, "./src/index.ts") : import_path.default.join(appDirectory, "./src/index.js");
|
|
93
73
|
if (fs.existsSync(entry)) {
|
|
94
74
|
return [`./${import_path.default.relative(appDirectory, entry)}`];
|
|
@@ -98,14 +78,14 @@ const getDefaultIndexEntry = (_0) => __async(void 0, [_0], function* ({
|
|
|
98
78
|
return [`./${import_path.default.relative(appDirectory, entry)}`];
|
|
99
79
|
}
|
|
100
80
|
return [];
|
|
101
|
-
}
|
|
102
|
-
const normalizeInput = (baseConfig, options) =>
|
|
81
|
+
};
|
|
82
|
+
const normalizeInput = async (baseConfig, options) => {
|
|
103
83
|
if (baseConfig.buildType === "bundleless" && !baseConfig.input) {
|
|
104
|
-
const { slash } =
|
|
84
|
+
const { slash } = await Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
105
85
|
return [slash(baseConfig.sourceDir)];
|
|
106
86
|
}
|
|
107
87
|
return getAbsInput(baseConfig.input, options);
|
|
108
|
-
}
|
|
88
|
+
};
|
|
109
89
|
// Annotate the CommonJS export names for ESM import in node:
|
|
110
90
|
0 && (module.exports = {
|
|
111
91
|
addInputToPreset,
|
package/dist/utils/input.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":"
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAYV,MAAM,cAAc,OAAO,OAAc,YAA0B;AACxE,QAAM,EAAE,MAAM,IAAI,MAAM,6CAAO,kBAAkB;AACjD,QAAM,EAAE,aAAa,IAAI;AAEzB,MAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,WAAO,MAAM;AAAA,MAAI,OACf,oBAAK,WAAW,CAAC,IAAI,MAAM,CAAC,IAAI,MAAM,oBAAK,KAAK,cAAc,CAAC,CAAC;AAAA,IAClE;AAAA,EACF;AAEA,QAAM,WAAmC,CAAC;AAC1C,aAAW,OAAO,OAAO,KAAK,KAAK,GAAG;AACpC,aAAS,GAAG,IAAI,oBAAK,WAAW,MAAM,GAAG,CAAC,IACtC,MAAM,MAAM,GAAG,CAAC,IAChB,MAAM,oBAAK,KAAK,cAAc,MAAM,GAAG,CAAC,CAAC;AAAA,EAC/C;AACA,SAAO;AACT;AAEO,MAAM,mBAAmB,OAC9B,QACA,YACG;AACH,MAAI,MAAM,QAAQ,MAAM,GAAG;AACzB,eAAW,KAAK,QAAQ;AACtB,UAAI,EAAE,cAAc,UAAU;AAC5B,UAAE,QAAQ,MAAM,qBAAqB,OAAO;AAAA,MAC9C,WAAW,EAAE,cAAc,cAAc;AACvC,UAAE,YAAY;AAAA,MAChB;AAAA,IACF;AAAA,EACF,WAAW,OAAO,cAAc,UAAU;AACxC,WAAO,QAAQ,MAAM,qBAAqB,OAAO;AAAA,EACnD,WAAW,OAAO,cAAc,cAAc;AAC5C,WAAO,YAAY;AAAA,EACrB;AAEA,SAAO;AACT;AAEO,MAAM,uBAAuB,OAAO;AAAA,EACzC;AAAA,EACA;AACF,MAGM;AACJ,QAAM,EAAE,GAAG,IAAI,MAAM,6CAAO,kBAAkB;AAC9C,MAAI,QAAQ,cACR,oBAAK,KAAK,cAAc,gBAAgB,IACxC,oBAAK,KAAK,cAAc,gBAAgB;AAC5C,MAAI,GAAG,WAAW,KAAK,GAAG;AACxB,WAAO,CAAC,KAAK,oBAAK,SAAS,cAAc,KAAK,GAAG;AAAA,EACnD;AAEA,UAAQ,cACJ,oBAAK,KAAK,cAAc,iBAAiB,IACzC,oBAAK,KAAK,cAAc,iBAAiB;AAC7C,MAAI,GAAG,WAAW,KAAK,GAAG;AACxB,WAAO,CAAC,KAAK,oBAAK,SAAS,cAAc,KAAK,GAAG;AAAA,EACnD;AAEA,SAAO,CAAC;AACV;AAEO,MAAM,iBAAiB,OAC5B,YACA,YACG;AACH,MAAI,WAAW,cAAc,gBAAgB,CAAC,WAAW,OAAO;AAC9D,UAAM,EAAE,MAAM,IAAI,MAAM,6CAAO,kBAAkB;AACjD,WAAO,CAAC,MAAM,WAAW,SAAS,CAAC;AAAA,EACrC;AACA,SAAO,YAAY,WAAW,OAAO,OAAO;AAC9C;;;;;;;;","names":[],"sources":["../../src/utils/input.ts"],"sourcesContent":["import path from 'path';\nimport { ModuleContext } from '../types';\nimport type {\n Input,\n BaseBuildConfig,\n PartialBuildConfig,\n} from '../types/config';\n\ninterface EntryOptions {\n appDirectory: string;\n}\n\nexport const getAbsInput = async (entry: Input, options: EntryOptions) => {\n const { slash } = await import('@modern-js/utils');\n const { appDirectory } = options;\n\n if (Array.isArray(entry)) {\n return entry.map(p =>\n path.isAbsolute(p) ? slash(p) : slash(path.join(appDirectory, p)),\n );\n }\n\n const newEntry: Record<string, string> = {};\n for (const key of Object.keys(entry)) {\n newEntry[key] = path.isAbsolute(entry[key])\n ? slash(entry[key])\n : slash(path.join(appDirectory, entry[key]));\n }\n return newEntry;\n};\n\nexport const addInputToPreset = async (\n config: PartialBuildConfig,\n context: ModuleContext,\n) => {\n if (Array.isArray(config)) {\n for (const c of config) {\n if (c.buildType === 'bundle') {\n c.input = await getDefaultIndexEntry(context);\n } else if (c.buildType === 'bundleless') {\n c.sourceDir = './src';\n }\n }\n } else if (config.buildType === 'bundle') {\n config.input = await getDefaultIndexEntry(context);\n } else if (config.buildType === 'bundleless') {\n config.sourceDir = './src';\n }\n\n return config;\n};\n\nexport const getDefaultIndexEntry = async ({\n isTsProject,\n appDirectory,\n}: {\n isTsProject: boolean;\n appDirectory: string;\n}) => {\n const { fs } = await import('@modern-js/utils');\n let entry = isTsProject\n ? path.join(appDirectory, './src/index.ts')\n : path.join(appDirectory, './src/index.js');\n if (fs.existsSync(entry)) {\n return [`./${path.relative(appDirectory, entry)}`];\n }\n\n entry = isTsProject\n ? path.join(appDirectory, './src/index.tsx')\n : path.join(appDirectory, './src/index.jsx');\n if (fs.existsSync(entry)) {\n return [`./${path.relative(appDirectory, entry)}`];\n }\n\n return [];\n};\n\nexport const normalizeInput = async (\n baseConfig: BaseBuildConfig,\n options: EntryOptions,\n) => {\n if (baseConfig.buildType === 'bundleless' && !baseConfig.input) {\n const { slash } = await import('@modern-js/utils');\n return [slash(baseConfig.sourceDir)];\n }\n return getAbsInput(baseConfig.input, options);\n};\n"]}
|
package/dist/utils/language.js
CHANGED
|
@@ -25,26 +25,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
25
25
|
mod
|
|
26
26
|
));
|
|
27
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var __async = (__this, __arguments, generator) => {
|
|
29
|
-
return new Promise((resolve, reject) => {
|
|
30
|
-
var fulfilled = (value) => {
|
|
31
|
-
try {
|
|
32
|
-
step(generator.next(value));
|
|
33
|
-
} catch (e) {
|
|
34
|
-
reject(e);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
var rejected = (value) => {
|
|
38
|
-
try {
|
|
39
|
-
step(generator.throw(value));
|
|
40
|
-
} catch (e) {
|
|
41
|
-
reject(e);
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
45
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
46
|
-
});
|
|
47
|
-
};
|
|
48
28
|
var language_exports = {};
|
|
49
29
|
__export(language_exports, {
|
|
50
30
|
getLocaleLanguage: () => getLocaleLanguage,
|
|
@@ -57,12 +37,12 @@ function getLocaleLanguage() {
|
|
|
57
37
|
const detector = new i18n.I18CLILanguageDetector();
|
|
58
38
|
return detector.detect();
|
|
59
39
|
}
|
|
60
|
-
const initLocalLanguage = () =>
|
|
61
|
-
const local =
|
|
40
|
+
const initLocalLanguage = async () => {
|
|
41
|
+
const local = await Promise.resolve().then(() => __toESM(require("../locale")));
|
|
62
42
|
const locale = getLocaleLanguage();
|
|
63
43
|
local.i18n.changeLanguage({ locale });
|
|
64
44
|
return local;
|
|
65
|
-
}
|
|
45
|
+
};
|
|
66
46
|
// Annotate the CommonJS export names for ESM import in node:
|
|
67
47
|
0 && (module.exports = {
|
|
68
48
|
getLocaleLanguage,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":"
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAuB;AAEvB,MAAM,OACJ,oBAAO,KAAK,4CAA4C,OAAO;AAE1D,SAAS,oBAAoB;AAClC,QAAM,WAAW,IAAI,KAAK,uBAAuB;AACjD,SAAO,SAAS,OAAO;AACzB;AAEO,MAAM,oBAAoB,YAAY;AAC3C,QAAM,QAAQ,MAAM,6CAAO,WAAW;AACtC,QAAM,SAAS,kBAAkB;AACjC,QAAM,KAAK,eAAe,EAAE,OAAO,CAAC;AACpC,SAAO;AACT;;;;;;","names":[],"sources":["../../src/utils/language.ts"],"sourcesContent":["import { Import } from '@modern-js/utils';\n\nconst i18n: typeof import('@modern-js/plugin-i18n/language-detector') =\n Import.lazy('@modern-js/plugin-i18n/language-detector', require);\n\nexport function getLocaleLanguage() {\n const detector = new i18n.I18CLILanguageDetector();\n return detector.detect();\n}\n\nexport const initLocalLanguage = async () => {\n const local = await import('../locale');\n const locale = getLocaleLanguage();\n local.i18n.changeLanguage({ locale });\n return local;\n};\n"]}
|
|
@@ -25,26 +25,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
25
25
|
mod
|
|
26
26
|
));
|
|
27
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var __async = (__this, __arguments, generator) => {
|
|
29
|
-
return new Promise((resolve, reject) => {
|
|
30
|
-
var fulfilled = (value) => {
|
|
31
|
-
try {
|
|
32
|
-
step(generator.next(value));
|
|
33
|
-
} catch (e) {
|
|
34
|
-
reject(e);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
var rejected = (value) => {
|
|
38
|
-
try {
|
|
39
|
-
step(generator.throw(value));
|
|
40
|
-
} catch (e) {
|
|
41
|
-
reject(e);
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
45
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
46
|
-
});
|
|
47
|
-
};
|
|
48
28
|
var libuildPlugins_exports = {};
|
|
49
29
|
__export(libuildPlugins_exports, {
|
|
50
30
|
externalPlugin: () => externalPlugin,
|
|
@@ -55,16 +35,16 @@ const watchPlugin = (api, config) => {
|
|
|
55
35
|
return {
|
|
56
36
|
name: "watch-plugin",
|
|
57
37
|
apply(compiler) {
|
|
58
|
-
compiler.hooks.watchChange.tap("watch-plugin", () =>
|
|
59
|
-
const { watchSectionTitle } =
|
|
60
|
-
const { SectionTitleStatus } =
|
|
38
|
+
compiler.hooks.watchChange.tap("watch-plugin", async () => {
|
|
39
|
+
const { watchSectionTitle } = await Promise.resolve().then(() => __toESM(require("./log")));
|
|
40
|
+
const { SectionTitleStatus } = await Promise.resolve().then(() => __toESM(require("../constants/log")));
|
|
61
41
|
const titleText = `[${config.buildType === "bundle" ? "Bundle" : "Bundleless"}:${config.format}_${config.target}]`;
|
|
62
42
|
console.info(
|
|
63
|
-
|
|
43
|
+
await watchSectionTitle(titleText, SectionTitleStatus.Log)
|
|
64
44
|
);
|
|
65
45
|
const runner = api.useHookRunners();
|
|
66
46
|
runner.buildWatchJs({ buildConfig: config });
|
|
67
|
-
})
|
|
47
|
+
});
|
|
68
48
|
}
|
|
69
49
|
};
|
|
70
50
|
};
|
|
@@ -72,11 +52,11 @@ const externalPlugin = (config, options) => {
|
|
|
72
52
|
return {
|
|
73
53
|
name: "external-plugin",
|
|
74
54
|
apply(compiler) {
|
|
75
|
-
compiler.hooks.initialize.tapPromise("external-plugin", () =>
|
|
76
|
-
const { getFinalExternals } =
|
|
77
|
-
const finalExternals =
|
|
55
|
+
compiler.hooks.initialize.tapPromise("external-plugin", async () => {
|
|
56
|
+
const { getFinalExternals } = await Promise.resolve().then(() => __toESM(require("./builder")));
|
|
57
|
+
const finalExternals = await getFinalExternals(config, options);
|
|
78
58
|
compiler.config.external = finalExternals;
|
|
79
|
-
})
|
|
59
|
+
});
|
|
80
60
|
}
|
|
81
61
|
};
|
|
82
62
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":"
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,MAAM,cAAc,CACzB,KACA,WACkB;AAClB,SAAO;AAAA,IACL,MAAM;AAAA,IACN,MAAM,UAAU;AACd,eAAS,MAAM,YAAY,IAAI,gBAAgB,YAAY;AACzD,cAAM,EAAE,kBAAkB,IAAI,MAAM,6CAAO,OAAO;AAClD,cAAM,EAAE,mBAAmB,IAAI,MAAM,6CAAO,kBAAkB;AAC9D,cAAM,YAAY,IAChB,OAAO,cAAc,WAAW,WAAW,gBACzC,OAAO,UAAU,OAAO;AAC5B,gBAAQ;AAAA,UACN,MAAM,kBAAkB,WAAW,mBAAmB,GAAG;AAAA,QAC3D;AACA,cAAM,SAAS,IAAI,eAAe;AAClC,eAAO,aAAa,EAAE,aAAa,OAAO,CAAC;AAAA,MAC7C,CAAC;AAAA,IACH;AAAA,EACF;AACF;AAEO,MAAM,iBAAiB,CAC5B,QACA,YACkB;AAClB,SAAO;AAAA,IACL,MAAM;AAAA,IACN,MAAM,UAAU;AACd,eAAS,MAAM,WAAW,WAAW,mBAAmB,YAAY;AAClE,cAAM,EAAE,kBAAkB,IAAI,MAAM,6CAAO,WAAW;AACtD,cAAM,iBAAiB,MAAM,kBAAkB,QAAQ,OAAO;AAC9D,iBAAS,OAAO,WAAW;AAAA,MAC7B,CAAC;AAAA,IACH;AAAA,EACF;AACF;;;;;;","names":[],"sources":["../../src/utils/libuildPlugins.ts"],"sourcesContent":["import 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 console.info(\n 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
|
@@ -25,34 +25,14 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
25
25
|
mod
|
|
26
26
|
));
|
|
27
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var __async = (__this, __arguments, generator) => {
|
|
29
|
-
return new Promise((resolve, reject) => {
|
|
30
|
-
var fulfilled = (value) => {
|
|
31
|
-
try {
|
|
32
|
-
step(generator.next(value));
|
|
33
|
-
} catch (e) {
|
|
34
|
-
reject(e);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
var rejected = (value) => {
|
|
38
|
-
try {
|
|
39
|
-
step(generator.throw(value));
|
|
40
|
-
} catch (e) {
|
|
41
|
-
reject(e);
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
45
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
46
|
-
});
|
|
47
|
-
};
|
|
48
28
|
var log_exports = {};
|
|
49
29
|
__export(log_exports, {
|
|
50
30
|
watchSectionTitle: () => watchSectionTitle
|
|
51
31
|
});
|
|
52
32
|
module.exports = __toCommonJS(log_exports);
|
|
53
33
|
var import_log = require("../constants/log");
|
|
54
|
-
const watchSectionTitle = (str, status, detailLog) =>
|
|
55
|
-
const { chalk } =
|
|
34
|
+
const watchSectionTitle = async (str, status, detailLog) => {
|
|
35
|
+
const { chalk } = await Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
56
36
|
if (status === import_log.SectionTitleStatus.Success) {
|
|
57
37
|
return `${chalk.bgWhite.gray.underline(str)} ${chalk.green.underline(
|
|
58
38
|
"Successful"
|
|
@@ -63,7 +43,7 @@ const watchSectionTitle = (str, status, detailLog) => __async(void 0, null, func
|
|
|
63
43
|
)}`;
|
|
64
44
|
}
|
|
65
45
|
return `${chalk.bgWhite.gray.underline(str)} ${detailLog ? detailLog : chalk.blue.underline("Log")}`;
|
|
66
|
-
}
|
|
46
|
+
};
|
|
67
47
|
// Annotate the CommonJS export names for ESM import in node:
|
|
68
48
|
0 && (module.exports = {
|
|
69
49
|
watchSectionTitle
|
package/dist/utils/log.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":"
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAmC;AAE5B,MAAM,oBAAoB,OAC/B,KACA,QACA,cACG;AACH,QAAM,EAAE,MAAM,IAAI,MAAM,6CAAO,kBAAkB;AACjD,MAAI,WAAW,8BAAmB,SAAS;AACzC,WAAO,GAAG,MAAM,QAAQ,KAAK,UAAU,GAAG,KAAK,MAAM,MAAM;AAAA,MACzD;AAAA,IACF;AAAA,EACF,WAAW,WAAW,8BAAmB,MAAM;AAC7C,WAAO,GAAG,MAAM,QAAQ,KAAK,UAAU,GAAG,KAAK,MAAM,IAAI;AAAA,MACvD;AAAA,IACF;AAAA,EACF;AAEA,SAAO,GAAG,MAAM,QAAQ,KAAK,UAAU,GAAG,KACxC,YAAY,YAAY,MAAM,KAAK,UAAU,KAAK;AAEtD;;;;;","names":[],"sources":["../../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.bgWhite.gray.underline(str)} ${chalk.green.underline(\n 'Successful',\n )}`;\n } else if (status === SectionTitleStatus.Fail) {\n return `${chalk.bgWhite.gray.underline(str)} ${chalk.red.underline(\n 'Build Failed',\n )}`;\n }\n\n return `${chalk.bgWhite.gray.underline(str)} ${\n detailLog ? detailLog : chalk.blue.underline('Log')\n }`;\n};\n"]}
|
package/dist/utils/onExit.js
CHANGED
|
@@ -25,40 +25,20 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
25
25
|
mod
|
|
26
26
|
));
|
|
27
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var __async = (__this, __arguments, generator) => {
|
|
29
|
-
return new Promise((resolve, reject) => {
|
|
30
|
-
var fulfilled = (value) => {
|
|
31
|
-
try {
|
|
32
|
-
step(generator.next(value));
|
|
33
|
-
} catch (e) {
|
|
34
|
-
reject(e);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
var rejected = (value) => {
|
|
38
|
-
try {
|
|
39
|
-
step(generator.throw(value));
|
|
40
|
-
} catch (e) {
|
|
41
|
-
reject(e);
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
45
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
46
|
-
});
|
|
47
|
-
};
|
|
48
28
|
var onExit_exports = {};
|
|
49
29
|
__export(onExit_exports, {
|
|
50
30
|
addExitListener: () => addExitListener
|
|
51
31
|
});
|
|
52
32
|
module.exports = __toCommonJS(onExit_exports);
|
|
53
|
-
const addExitListener = (fn) =>
|
|
54
|
-
const { default: onExit } =
|
|
55
|
-
onExit((code) =>
|
|
33
|
+
const addExitListener = async (fn) => {
|
|
34
|
+
const { default: onExit } = await Promise.resolve().then(() => __toESM(require("../../compiled/signal-exit")));
|
|
35
|
+
onExit(async (code) => {
|
|
56
36
|
if (code === 0) {
|
|
57
37
|
return;
|
|
58
38
|
}
|
|
59
|
-
|
|
60
|
-
})
|
|
61
|
-
}
|
|
39
|
+
await fn();
|
|
40
|
+
});
|
|
41
|
+
};
|
|
62
42
|
// Annotate the CommonJS export names for ESM import in node:
|
|
63
43
|
0 && (module.exports = {
|
|
64
44
|
addExitListener
|
package/dist/utils/onExit.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":"
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,kBAAkB,OAAO,OAA4B;AAChE,QAAM,EAAE,SAAS,OAAO,IAAI,MAAM,6CAAO,4BAA4B;AAErE,SAAO,OAAM,SAAQ;AACnB,QAAI,SAAS,GAAG;AACd;AAAA,IACF;AAEA,UAAM,GAAG;AAAA,EACX,CAAC;AACH;;;;;","names":[],"sources":["../../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
|
@@ -25,36 +25,16 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
25
25
|
mod
|
|
26
26
|
));
|
|
27
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var __async = (__this, __arguments, generator) => {
|
|
29
|
-
return new Promise((resolve, reject) => {
|
|
30
|
-
var fulfilled = (value) => {
|
|
31
|
-
try {
|
|
32
|
-
step(generator.next(value));
|
|
33
|
-
} catch (e) {
|
|
34
|
-
reject(e);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
var rejected = (value) => {
|
|
38
|
-
try {
|
|
39
|
-
step(generator.throw(value));
|
|
40
|
-
} catch (e) {
|
|
41
|
-
reject(e);
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
45
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
46
|
-
});
|
|
47
|
-
};
|
|
48
28
|
var path_exports = {};
|
|
49
29
|
__export(path_exports, {
|
|
50
30
|
getCompiledPath: () => getCompiledPath
|
|
51
31
|
});
|
|
52
32
|
module.exports = __toCommonJS(path_exports);
|
|
53
33
|
var import_path = __toESM(require("path"));
|
|
54
|
-
const getCompiledPath = (packageName) =>
|
|
55
|
-
const { slash } =
|
|
34
|
+
const getCompiledPath = async (packageName) => {
|
|
35
|
+
const { slash } = await Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
56
36
|
return slash(import_path.default.join(__dirname, "../../compiled", packageName));
|
|
57
|
-
}
|
|
37
|
+
};
|
|
58
38
|
// Annotate the CommonJS export names for ESM import in node:
|
|
59
39
|
0 && (module.exports = {
|
|
60
40
|
getCompiledPath
|
package/dist/utils/path.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":"
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEV,MAAM,kBAAkB,OAAO,gBAAwB;AAC5D,QAAM,EAAE,MAAM,IAAI,MAAM,6CAAO,kBAAkB;AACjD,SAAO,MAAM,oBAAK,KAAK,WAAW,kBAAkB,WAAW,CAAC;AAClE;;;;;","names":[],"sources":["../../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"]}
|