@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/build.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 build_exports = {};
|
|
49
29
|
__export(build_exports, {
|
|
50
30
|
build: () => build
|
|
@@ -52,23 +32,23 @@ __export(build_exports, {
|
|
|
52
32
|
module.exports = __toCommonJS(build_exports);
|
|
53
33
|
var import_utils = require("@modern-js/utils");
|
|
54
34
|
const debug = (0, import_utils.createDebugger)("module-tools");
|
|
55
|
-
const build = (api, options, context) =>
|
|
35
|
+
const build = async (api, options, context) => {
|
|
56
36
|
if (options.platform) {
|
|
57
|
-
const { buildPlatform } =
|
|
58
|
-
|
|
37
|
+
const { buildPlatform } = await Promise.resolve().then(() => __toESM(require("./builder/platform")));
|
|
38
|
+
await buildPlatform(options, api, context);
|
|
59
39
|
return;
|
|
60
40
|
}
|
|
61
41
|
const runner = api.useHookRunners();
|
|
62
|
-
const { normalizeBuildConfig } =
|
|
63
|
-
const resolvedBuildConfig =
|
|
42
|
+
const { normalizeBuildConfig } = await Promise.resolve().then(() => __toESM(require("./config/normalize")));
|
|
43
|
+
const resolvedBuildConfig = await normalizeBuildConfig(api, context, options);
|
|
64
44
|
debug("resolvedBuildConfig", resolvedBuildConfig);
|
|
65
|
-
|
|
45
|
+
await runner.beforeBuild({
|
|
66
46
|
config: resolvedBuildConfig,
|
|
67
47
|
cliOptions: options
|
|
68
48
|
});
|
|
69
|
-
const builder =
|
|
70
|
-
|
|
71
|
-
}
|
|
49
|
+
const builder = await Promise.resolve().then(() => __toESM(require("./builder")));
|
|
50
|
+
await builder.run({ cmdOptions: options, resolvedBuildConfig, context }, api);
|
|
51
|
+
};
|
|
72
52
|
// Annotate the CommonJS export names for ESM import in node:
|
|
73
53
|
0 && (module.exports = {
|
|
74
54
|
build
|
package/dist/build.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":"
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAA+B;AAG/B,MAAM,YAAQ,6BAAe,cAAc;AAEpC,MAAM,QAAQ,OACnB,KACA,SACA,YACG;AACH,MAAI,QAAQ,UAAU;AACpB,UAAM,EAAE,cAAc,IAAI,MAAM,6CAAO,oBAAoB;AAC3D,UAAM,cAAc,SAAS,KAAK,OAAO;AACzC;AAAA,EACF;AAEA,QAAM,SAAS,IAAI,eAAe;AAElC,QAAM,EAAE,qBAAqB,IAAI,MAAM,6CAAO,oBAAoB;AAClE,QAAM,sBAAsB,MAAM,qBAAqB,KAAK,SAAS,OAAO;AAE5E,QAAM,uBAAuB,mBAAmB;AAEhD,QAAM,OAAO,YAAY;AAAA,IACvB,QAAQ;AAAA,IACR,YAAY;AAAA,EACd,CAAC;AACD,QAAM,UAAU,MAAM,6CAAO,WAAW;AACxC,QAAM,QAAQ,IAAI,EAAE,YAAY,SAAS,qBAAqB,QAAQ,GAAG,GAAG;AAC9E;;;;;","names":[],"sources":["../src/build.ts"],"sourcesContent":["import type { PluginAPI } from '@modern-js/core';\nimport { createDebugger } from '@modern-js/utils';\nimport type { ModuleTools, ModuleContext, BuildCommandOptions } from './types';\n\nconst debug = createDebugger('module-tools');\n\nexport const build = async (\n api: PluginAPI<ModuleTools>,\n options: BuildCommandOptions,\n context: ModuleContext,\n) => {\n if (options.platform) {\n const { buildPlatform } = await import('./builder/platform');\n await buildPlatform(options, api, context);\n return;\n }\n\n const runner = api.useHookRunners();\n\n const { normalizeBuildConfig } = await import('./config/normalize');\n const resolvedBuildConfig = await normalizeBuildConfig(api, context, options);\n\n debug('resolvedBuildConfig', resolvedBuildConfig);\n\n await runner.beforeBuild({\n config: resolvedBuildConfig,\n cliOptions: options,\n });\n const builder = await import('./builder');\n await builder.run({ cmdOptions: options, resolvedBuildConfig, context }, api);\n};\n"]}
|
package/dist/builder/build.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 build_exports = {};
|
|
66
29
|
__export(build_exports, {
|
|
67
30
|
buildInJsProject: () => buildInJsProject,
|
|
@@ -72,53 +35,51 @@ __export(build_exports, {
|
|
|
72
35
|
});
|
|
73
36
|
module.exports = __toCommonJS(build_exports);
|
|
74
37
|
var import_path = require("path");
|
|
75
|
-
const runBuildTask = (options, api) =>
|
|
38
|
+
const runBuildTask = async (options, api) => {
|
|
76
39
|
const { buildConfig, context, buildCmdOptions } = options;
|
|
77
40
|
const { appDirectory, isTsProject } = context;
|
|
78
|
-
const { copyTask } =
|
|
79
|
-
|
|
41
|
+
const { copyTask } = await Promise.resolve().then(() => __toESM(require("./copy")));
|
|
42
|
+
await copyTask(buildConfig, { appDirectory, watch: buildCmdOptions.watch });
|
|
80
43
|
if (isTsProject) {
|
|
81
|
-
|
|
44
|
+
await buildInTsProject(options, api);
|
|
82
45
|
} else {
|
|
83
|
-
|
|
46
|
+
await buildInJsProject(options, api);
|
|
84
47
|
}
|
|
85
|
-
}
|
|
86
|
-
const buildInTsProject = (options, api) =>
|
|
87
|
-
var _a;
|
|
48
|
+
};
|
|
49
|
+
const buildInTsProject = async (options, api) => {
|
|
88
50
|
const { buildConfig, buildCmdOptions } = options;
|
|
89
51
|
const dts = buildCmdOptions.dts ? buildConfig.dts : false;
|
|
90
52
|
const skipBuildLib = buildConfig.dts ? buildConfig.dts.only : false;
|
|
91
|
-
const watch =
|
|
53
|
+
const watch = buildCmdOptions.watch ?? false;
|
|
92
54
|
if (dts === false) {
|
|
93
|
-
!skipBuildLib &&
|
|
55
|
+
!skipBuildLib && await buildLib(buildConfig, api, { watch });
|
|
94
56
|
} else {
|
|
95
57
|
const tasks = dts.only ? [generatorDts] : [buildLib, generatorDts];
|
|
96
|
-
const { default: pMap } =
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
})
|
|
58
|
+
const { default: pMap } = await Promise.resolve().then(() => __toESM(require("../../compiled/p-map")));
|
|
59
|
+
await pMap(tasks, async (task) => {
|
|
60
|
+
await task(buildConfig, api, { watch, dts });
|
|
61
|
+
});
|
|
100
62
|
}
|
|
101
|
-
}
|
|
102
|
-
const buildInJsProject = (options, api) =>
|
|
103
|
-
var _a;
|
|
63
|
+
};
|
|
64
|
+
const buildInJsProject = async (options, api) => {
|
|
104
65
|
const { buildConfig, buildCmdOptions } = options;
|
|
105
66
|
const dts = buildCmdOptions.dts ? buildConfig.dts : false;
|
|
106
|
-
const watch =
|
|
67
|
+
const watch = buildCmdOptions.watch ?? false;
|
|
107
68
|
if (dts !== false && dts.only) {
|
|
108
69
|
return;
|
|
109
70
|
}
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
const generatorDts = (config, api, options) =>
|
|
113
|
-
const { runRollup, runTsc } =
|
|
71
|
+
await buildLib(buildConfig, api, { watch });
|
|
72
|
+
};
|
|
73
|
+
const generatorDts = async (config, api, options) => {
|
|
74
|
+
const { runRollup, runTsc } = await Promise.resolve().then(() => __toESM(require("./dts")));
|
|
114
75
|
const { watch, dts } = options;
|
|
115
76
|
const { buildType, input, sourceDir, alias } = config;
|
|
116
77
|
const { appDirectory } = api.useAppContext();
|
|
117
78
|
const { tsconfigPath, distPath } = dts;
|
|
118
79
|
if (buildType === "bundle") {
|
|
119
|
-
const { getFinalExternals } =
|
|
120
|
-
const finalExternals =
|
|
121
|
-
|
|
80
|
+
const { getFinalExternals } = await Promise.resolve().then(() => __toESM(require("../utils/builder")));
|
|
81
|
+
const finalExternals = await getFinalExternals(config, { appDirectory });
|
|
82
|
+
await runRollup(api, {
|
|
122
83
|
distDir: distPath,
|
|
123
84
|
watch,
|
|
124
85
|
externals: finalExternals,
|
|
@@ -126,7 +87,7 @@ const generatorDts = (config, api, options) => __async(void 0, null, function* (
|
|
|
126
87
|
tsconfigPath
|
|
127
88
|
});
|
|
128
89
|
} else {
|
|
129
|
-
|
|
90
|
+
await runTsc(api, {
|
|
130
91
|
appDirectory,
|
|
131
92
|
alias,
|
|
132
93
|
distAbsPath: distPath,
|
|
@@ -135,9 +96,8 @@ const generatorDts = (config, api, options) => __async(void 0, null, function* (
|
|
|
135
96
|
sourceDir
|
|
136
97
|
});
|
|
137
98
|
}
|
|
138
|
-
}
|
|
139
|
-
const buildLib = (config, api, options) =>
|
|
140
|
-
var _a;
|
|
99
|
+
};
|
|
100
|
+
const buildLib = async (config, api, options) => {
|
|
141
101
|
const { watch } = options;
|
|
142
102
|
const {
|
|
143
103
|
target,
|
|
@@ -164,20 +124,20 @@ const buildLib = (config, api, options) => __async(void 0, null, function* () {
|
|
|
164
124
|
sideEffects
|
|
165
125
|
} = config;
|
|
166
126
|
const { appDirectory } = api.useAppContext();
|
|
167
|
-
const { slash } =
|
|
127
|
+
const { slash } = await Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
168
128
|
const root = slash(appDirectory);
|
|
169
129
|
const outdir = slash(distPath);
|
|
170
130
|
const assetOutDir = asset.path ? slash(asset.path) : asset.path;
|
|
171
131
|
const { less, sass, postcss, inject, modules, autoModules } = style;
|
|
172
|
-
const { es5Plugin, umdPlugin, transformPlugin } =
|
|
132
|
+
const { es5Plugin, umdPlugin, transformPlugin } = await Promise.resolve().then(() => __toESM(require("@modern-js/libuild-plugin-swc")));
|
|
173
133
|
const plugins = format === "umd" ? [umdPlugin(umdModuleName)] : [];
|
|
174
134
|
if (target === "es5") {
|
|
175
135
|
plugins.push(es5Plugin());
|
|
176
136
|
}
|
|
177
|
-
const { getProjectTsconfig } =
|
|
137
|
+
const { getProjectTsconfig } = await Promise.resolve().then(() => __toESM(require("./dts/tsc")));
|
|
178
138
|
const tsconfigPath = dts ? dts.tsconfigPath : (0, import_path.join)(appDirectory, "./tsconfig.json");
|
|
179
|
-
const userTsconfig =
|
|
180
|
-
if (
|
|
139
|
+
const userTsconfig = await getProjectTsconfig(tsconfigPath);
|
|
140
|
+
if (userTsconfig?.compilerOptions?.emitDecoratorMetadata) {
|
|
181
141
|
plugins.push(
|
|
182
142
|
transformPlugin({
|
|
183
143
|
jsc: {
|
|
@@ -190,11 +150,11 @@ const buildLib = (config, api, options) => __async(void 0, null, function* () {
|
|
|
190
150
|
);
|
|
191
151
|
}
|
|
192
152
|
if (asset.svgr) {
|
|
193
|
-
const { svgrPlugin } =
|
|
153
|
+
const { svgrPlugin } = await Promise.resolve().then(() => __toESM(require("@modern-js/libuild-plugin-svgr")));
|
|
194
154
|
const options2 = typeof asset.svgr === "boolean" ? {} : asset.svgr;
|
|
195
155
|
plugins.push(svgrPlugin(options2));
|
|
196
156
|
}
|
|
197
|
-
const { watchPlugin, externalPlugin } =
|
|
157
|
+
const { watchPlugin, externalPlugin } = await Promise.resolve().then(() => __toESM(require("../utils/libuildPlugins")));
|
|
198
158
|
plugins.push(watchPlugin(api, config));
|
|
199
159
|
plugins.push(externalPlugin(config, { appDirectory }));
|
|
200
160
|
const buildConfig = {
|
|
@@ -216,9 +176,10 @@ const buildLib = (config, api, options) => __async(void 0, null, function* () {
|
|
|
216
176
|
resolve: {
|
|
217
177
|
alias
|
|
218
178
|
},
|
|
219
|
-
asset:
|
|
179
|
+
asset: {
|
|
180
|
+
...asset,
|
|
220
181
|
outdir: assetOutDir
|
|
221
|
-
}
|
|
182
|
+
},
|
|
222
183
|
plugins,
|
|
223
184
|
jsx,
|
|
224
185
|
input,
|
|
@@ -234,39 +195,40 @@ const buildLib = (config, api, options) => __async(void 0, null, function* () {
|
|
|
234
195
|
sideEffects,
|
|
235
196
|
// outbase for [dir]/[name]
|
|
236
197
|
outbase: sourceDir,
|
|
237
|
-
esbuildOptions: (options2) =>
|
|
198
|
+
esbuildOptions: (options2) => ({
|
|
199
|
+
...options2,
|
|
238
200
|
supported: {
|
|
239
201
|
"dynamic-import": !(["cjs", "umd"].includes(format) && buildType === "bundleless")
|
|
240
202
|
}
|
|
241
203
|
})
|
|
242
204
|
};
|
|
243
205
|
try {
|
|
244
|
-
const { Libuilder } =
|
|
245
|
-
const { addOutputChunk } =
|
|
206
|
+
const { Libuilder } = await Promise.resolve().then(() => __toESM(require("@modern-js/libuild")));
|
|
207
|
+
const { addOutputChunk } = await Promise.resolve().then(() => __toESM(require("../utils/print")));
|
|
246
208
|
const runner = api.useHookRunners();
|
|
247
|
-
const modifiedBuildConfig =
|
|
209
|
+
const modifiedBuildConfig = await runner.modifyLibuild(buildConfig, {
|
|
248
210
|
onLast: (c) => c
|
|
249
211
|
});
|
|
250
|
-
const builder =
|
|
251
|
-
|
|
212
|
+
const builder = await Libuilder.create(modifiedBuildConfig);
|
|
213
|
+
await builder.build();
|
|
252
214
|
addOutputChunk(builder.outputChunk, root, buildType === "bundle");
|
|
253
215
|
if (watch) {
|
|
254
|
-
const { watchSectionTitle } =
|
|
255
|
-
const { SectionTitleStatus } =
|
|
216
|
+
const { watchSectionTitle } = await Promise.resolve().then(() => __toESM(require("../utils/log")));
|
|
217
|
+
const { SectionTitleStatus } = await Promise.resolve().then(() => __toESM(require("../constants/log")));
|
|
256
218
|
const titleText = `[${buildType === "bundle" ? "Bundle" : "Bundleless"}: ${format}_${target}]`;
|
|
257
219
|
console.info(
|
|
258
|
-
|
|
220
|
+
await watchSectionTitle(titleText, SectionTitleStatus.Success)
|
|
259
221
|
);
|
|
260
222
|
}
|
|
261
223
|
} catch (e) {
|
|
262
|
-
const { InternalBuildError } =
|
|
224
|
+
const { InternalBuildError } = await Promise.resolve().then(() => __toESM(require("../error")));
|
|
263
225
|
throw new InternalBuildError(e, {
|
|
264
226
|
target,
|
|
265
227
|
format,
|
|
266
228
|
buildType
|
|
267
229
|
});
|
|
268
230
|
}
|
|
269
|
-
}
|
|
231
|
+
};
|
|
270
232
|
// Annotate the CommonJS export names for ESM import in node:
|
|
271
233
|
0 && (module.exports = {
|
|
272
234
|
buildInJsProject,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;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"],"sources":["../../src/builder/build.ts"],"sourcesContent":["import { join } from 'path';\nimport type { CLIConfig } from '@modern-js/libuild';\nimport type {\n BuildCommandOptions,\n BaseBuildConfig,\n ModuleTools,\n PluginAPI,\n DTSOptions,\n ModuleContext,\n} from '../types';\n\nexport const runBuildTask = async (\n options: {\n buildConfig: BaseBuildConfig;\n buildCmdOptions: BuildCommandOptions;\n context: ModuleContext;\n },\n api: PluginAPI<ModuleTools>,\n) => {\n const { buildConfig, context, buildCmdOptions } = options;\n const { appDirectory, isTsProject } = context;\n\n const { copyTask } = await import('./copy');\n await copyTask(buildConfig, { appDirectory, watch: buildCmdOptions.watch });\n\n if (isTsProject) {\n await buildInTsProject(options, api);\n } else {\n await buildInJsProject(options, api);\n }\n};\n\nexport const buildInTsProject = async (\n options: {\n buildConfig: BaseBuildConfig;\n buildCmdOptions: BuildCommandOptions;\n context: ModuleContext;\n },\n api: PluginAPI<ModuleTools>,\n) => {\n const { buildConfig, buildCmdOptions } = options;\n const dts = buildCmdOptions.dts ? buildConfig.dts : false;\n const skipBuildLib = buildConfig.dts ? buildConfig.dts.only : false;\n const watch = buildCmdOptions.watch ?? false;\n\n if (dts === false) {\n // --no-dts and buildConfig is `{ dts: { only: true } }`, then skip.\n !skipBuildLib && (await buildLib(buildConfig, api, { watch }));\n } else {\n const tasks = dts.only ? [generatorDts] : [buildLib, generatorDts];\n const { default: pMap } = await import('../../compiled/p-map');\n await pMap(tasks, async task => {\n await task(buildConfig, api as any, { watch, dts });\n });\n }\n};\n\nexport const buildInJsProject = async (\n options: {\n buildConfig: BaseBuildConfig;\n buildCmdOptions: BuildCommandOptions;\n context: ModuleContext;\n },\n api: PluginAPI<ModuleTools>,\n) => {\n const { buildConfig, buildCmdOptions } = options;\n const dts = buildCmdOptions.dts ? buildConfig.dts : false;\n const watch = buildCmdOptions.watch ?? false;\n\n if (dts !== false && dts.only) {\n return;\n }\n\n await buildLib(buildConfig, api, { watch });\n};\n\nexport const generatorDts = async (\n config: BaseBuildConfig,\n api: PluginAPI<ModuleTools>,\n options: {\n watch: boolean;\n dts: DTSOptions;\n },\n) => {\n const { runRollup, runTsc } = await import('./dts');\n const { watch, dts } = options;\n const { buildType, input, sourceDir, alias } = config;\n const { appDirectory } = api.useAppContext();\n const { tsconfigPath, distPath } = dts;\n if (buildType === 'bundle') {\n const { getFinalExternals } = await import('../utils/builder');\n const finalExternals = await getFinalExternals(config, { appDirectory });\n\n await runRollup(api, {\n distDir: distPath,\n watch,\n externals: finalExternals,\n input,\n tsconfigPath,\n });\n } else {\n await runTsc(api, {\n appDirectory,\n alias,\n distAbsPath: distPath,\n watch,\n tsconfigPath,\n sourceDir,\n });\n }\n};\n\nexport const buildLib = async (\n config: BaseBuildConfig,\n api: PluginAPI<ModuleTools>,\n options: {\n watch: boolean;\n },\n) => {\n const { watch } = options;\n const {\n target,\n buildType,\n sourceMap,\n format,\n outDir: distPath,\n asset,\n jsx,\n input,\n platform,\n splitting,\n minify,\n sourceDir,\n umdGlobals,\n umdModuleName,\n define,\n alias,\n style,\n externals,\n autoExternal,\n dts,\n metafile,\n sideEffects,\n } = config;\n const { appDirectory } = api.useAppContext();\n const { slash } = await import('@modern-js/utils');\n const root = slash(appDirectory);\n const outdir = slash(distPath);\n const assetOutDir = asset.path ? slash(asset.path) : asset.path;\n const { less, sass, postcss, inject, modules, autoModules } = style;\n\n // support es5,umd and emitDecoratorMetadata by swc\n const { es5Plugin, umdPlugin, transformPlugin } = await import(\n '@modern-js/libuild-plugin-swc'\n );\n const plugins = format === 'umd' ? [umdPlugin(umdModuleName)] : [];\n if (target === 'es5') {\n plugins.push(es5Plugin());\n }\n const { getProjectTsconfig } = await import('./dts/tsc');\n const tsconfigPath = dts\n ? dts.tsconfigPath\n : join(appDirectory, './tsconfig.json');\n const userTsconfig = await getProjectTsconfig(tsconfigPath);\n if (userTsconfig?.compilerOptions?.emitDecoratorMetadata) {\n plugins.push(\n transformPlugin({\n jsc: {\n transform: {\n legacyDecorator: true,\n decoratorMetadata: true,\n },\n },\n }),\n );\n }\n\n // support svgr\n if (asset.svgr) {\n const { svgrPlugin } = await import('@modern-js/libuild-plugin-svgr');\n const options = typeof asset.svgr === 'boolean' ? {} : asset.svgr;\n plugins.push(svgrPlugin(options));\n }\n\n // adapt module tools\n const { watchPlugin, externalPlugin } = await import(\n '../utils/libuildPlugins'\n );\n plugins.push(watchPlugin(api, config));\n plugins.push(externalPlugin(config, { appDirectory }));\n\n const buildConfig: CLIConfig = {\n root,\n watch,\n target,\n sourceMap,\n format,\n outdir,\n define,\n style: {\n less,\n sass,\n postcss,\n inject,\n modules,\n autoModules,\n },\n resolve: {\n alias,\n },\n asset: {\n ...asset,\n outdir: assetOutDir,\n },\n plugins,\n jsx,\n input,\n platform,\n splitting,\n minify,\n sourceDir,\n metafile: metafile && buildType === 'bundle',\n globals: umdGlobals,\n external: externals,\n autoExternal,\n bundle: buildType === 'bundle',\n sideEffects,\n // outbase for [dir]/[name]\n outbase: sourceDir,\n esbuildOptions: (options: any) => ({\n ...options,\n supported: {\n 'dynamic-import': !(\n ['cjs', 'umd'].includes(format) && buildType === 'bundleless'\n ),\n },\n }),\n };\n\n try {\n const { Libuilder } = await import('@modern-js/libuild');\n const { addOutputChunk } = await import('../utils/print');\n const runner = api.useHookRunners();\n const modifiedBuildConfig = await runner.modifyLibuild(buildConfig, {\n onLast: c => c,\n });\n\n const builder = await Libuilder.create(modifiedBuildConfig);\n await builder.build();\n addOutputChunk(builder.outputChunk, root, buildType === 'bundle');\n\n if (watch) {\n const { watchSectionTitle } = await import('../utils/log');\n const { SectionTitleStatus } = await import('../constants/log');\n const titleText = `[${\n buildType === 'bundle' ? 'Bundle' : 'Bundleless'\n }: ${format}_${target}]`;\n\n console.info(\n await watchSectionTitle(titleText, SectionTitleStatus.Success),\n );\n }\n } catch (e: any) {\n const { InternalBuildError } = await import('../error');\n throw new InternalBuildError(e, {\n target,\n format,\n buildType,\n });\n }\n};\n"]}
|
|
1
|
+
{"version":3,"file":null,"mapp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":["options"],"sources":["../../src/builder/build.ts"],"sourcesContent":["import { join } from 'path';\nimport type { CLIConfig } from '@modern-js/libuild';\nimport type {\n BuildCommandOptions,\n BaseBuildConfig,\n ModuleTools,\n PluginAPI,\n DTSOptions,\n ModuleContext,\n} from '../types';\n\nexport const runBuildTask = async (\n options: {\n buildConfig: BaseBuildConfig;\n buildCmdOptions: BuildCommandOptions;\n context: ModuleContext;\n },\n api: PluginAPI<ModuleTools>,\n) => {\n const { buildConfig, context, buildCmdOptions } = options;\n const { appDirectory, isTsProject } = context;\n\n const { copyTask } = await import('./copy');\n await copyTask(buildConfig, { appDirectory, watch: buildCmdOptions.watch });\n\n if (isTsProject) {\n await buildInTsProject(options, api);\n } else {\n await buildInJsProject(options, api);\n }\n};\n\nexport const buildInTsProject = async (\n options: {\n buildConfig: BaseBuildConfig;\n buildCmdOptions: BuildCommandOptions;\n context: ModuleContext;\n },\n api: PluginAPI<ModuleTools>,\n) => {\n const { buildConfig, buildCmdOptions } = options;\n const dts = buildCmdOptions.dts ? buildConfig.dts : false;\n const skipBuildLib = buildConfig.dts ? buildConfig.dts.only : false;\n const watch = buildCmdOptions.watch ?? false;\n\n if (dts === false) {\n // --no-dts and buildConfig is `{ dts: { only: true } }`, then skip.\n !skipBuildLib && (await buildLib(buildConfig, api, { watch }));\n } else {\n const tasks = dts.only ? [generatorDts] : [buildLib, generatorDts];\n const { default: pMap } = await import('../../compiled/p-map');\n await pMap(tasks, async task => {\n await task(buildConfig, api as any, { watch, dts });\n });\n }\n};\n\nexport const buildInJsProject = async (\n options: {\n buildConfig: BaseBuildConfig;\n buildCmdOptions: BuildCommandOptions;\n context: ModuleContext;\n },\n api: PluginAPI<ModuleTools>,\n) => {\n const { buildConfig, buildCmdOptions } = options;\n const dts = buildCmdOptions.dts ? buildConfig.dts : false;\n const watch = buildCmdOptions.watch ?? false;\n\n if (dts !== false && dts.only) {\n return;\n }\n\n await buildLib(buildConfig, api, { watch });\n};\n\nexport const generatorDts = async (\n config: BaseBuildConfig,\n api: PluginAPI<ModuleTools>,\n options: {\n watch: boolean;\n dts: DTSOptions;\n },\n) => {\n const { runRollup, runTsc } = await import('./dts');\n const { watch, dts } = options;\n const { buildType, input, sourceDir, alias } = config;\n const { appDirectory } = api.useAppContext();\n const { tsconfigPath, distPath } = dts;\n if (buildType === 'bundle') {\n const { getFinalExternals } = await import('../utils/builder');\n const finalExternals = await getFinalExternals(config, { appDirectory });\n\n await runRollup(api, {\n distDir: distPath,\n watch,\n externals: finalExternals,\n input,\n tsconfigPath,\n });\n } else {\n await runTsc(api, {\n appDirectory,\n alias,\n distAbsPath: distPath,\n watch,\n tsconfigPath,\n sourceDir,\n });\n }\n};\n\nexport const buildLib = async (\n config: BaseBuildConfig,\n api: PluginAPI<ModuleTools>,\n options: {\n watch: boolean;\n },\n) => {\n const { watch } = options;\n const {\n target,\n buildType,\n sourceMap,\n format,\n outDir: distPath,\n asset,\n jsx,\n input,\n platform,\n splitting,\n minify,\n sourceDir,\n umdGlobals,\n umdModuleName,\n define,\n alias,\n style,\n externals,\n autoExternal,\n dts,\n metafile,\n sideEffects,\n } = config;\n const { appDirectory } = api.useAppContext();\n const { slash } = await import('@modern-js/utils');\n const root = slash(appDirectory);\n const outdir = slash(distPath);\n const assetOutDir = asset.path ? slash(asset.path) : asset.path;\n const { less, sass, postcss, inject, modules, autoModules } = style;\n\n // support es5,umd and emitDecoratorMetadata by swc\n const { es5Plugin, umdPlugin, transformPlugin } = await import(\n '@modern-js/libuild-plugin-swc'\n );\n const plugins = format === 'umd' ? [umdPlugin(umdModuleName)] : [];\n if (target === 'es5') {\n plugins.push(es5Plugin());\n }\n const { getProjectTsconfig } = await import('./dts/tsc');\n const tsconfigPath = dts\n ? dts.tsconfigPath\n : join(appDirectory, './tsconfig.json');\n const userTsconfig = await getProjectTsconfig(tsconfigPath);\n if (userTsconfig?.compilerOptions?.emitDecoratorMetadata) {\n plugins.push(\n transformPlugin({\n jsc: {\n transform: {\n legacyDecorator: true,\n decoratorMetadata: true,\n },\n },\n }),\n );\n }\n\n // support svgr\n if (asset.svgr) {\n const { svgrPlugin } = await import('@modern-js/libuild-plugin-svgr');\n const options = typeof asset.svgr === 'boolean' ? {} : asset.svgr;\n plugins.push(svgrPlugin(options));\n }\n\n // adapt module tools\n const { watchPlugin, externalPlugin } = await import(\n '../utils/libuildPlugins'\n );\n plugins.push(watchPlugin(api, config));\n plugins.push(externalPlugin(config, { appDirectory }));\n\n const buildConfig: CLIConfig = {\n root,\n watch,\n target,\n sourceMap,\n format,\n outdir,\n define,\n style: {\n less,\n sass,\n postcss,\n inject,\n modules,\n autoModules,\n },\n resolve: {\n alias,\n },\n asset: {\n ...asset,\n outdir: assetOutDir,\n },\n plugins,\n jsx,\n input,\n platform,\n splitting,\n minify,\n sourceDir,\n metafile: metafile && buildType === 'bundle',\n globals: umdGlobals,\n external: externals,\n autoExternal,\n bundle: buildType === 'bundle',\n sideEffects,\n // outbase for [dir]/[name]\n outbase: sourceDir,\n esbuildOptions: (options: any) => ({\n ...options,\n supported: {\n 'dynamic-import': !(\n ['cjs', 'umd'].includes(format) && buildType === 'bundleless'\n ),\n },\n }),\n };\n\n try {\n const { Libuilder } = await import('@modern-js/libuild');\n const { addOutputChunk } = await import('../utils/print');\n const runner = api.useHookRunners();\n const modifiedBuildConfig = await runner.modifyLibuild(buildConfig, {\n onLast: c => c,\n });\n\n const builder = await Libuilder.create(modifiedBuildConfig);\n await builder.build();\n addOutputChunk(builder.outputChunk, root, buildType === 'bundle');\n\n if (watch) {\n const { watchSectionTitle } = await import('../utils/log');\n const { SectionTitleStatus } = await import('../constants/log');\n const titleText = `[${\n buildType === 'bundle' ? 'Bundle' : 'Bundleless'\n }: ${format}_${target}]`;\n\n console.info(\n await watchSectionTitle(titleText, SectionTitleStatus.Success),\n );\n }\n } catch (e: any) {\n const { InternalBuildError } = await import('../error');\n throw new InternalBuildError(e, {\n target,\n format,\n buildType,\n });\n }\n};\n"]}
|
package/dist/builder/clear.js
CHANGED
|
@@ -25,43 +25,23 @@ 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 clear_exports = {};
|
|
49
29
|
__export(clear_exports, {
|
|
50
30
|
clearBuildConfigPaths: () => clearBuildConfigPaths,
|
|
51
31
|
clearDtsTemp: () => clearDtsTemp
|
|
52
32
|
});
|
|
53
33
|
module.exports = __toCommonJS(clear_exports);
|
|
54
|
-
const clearDtsTemp = () =>
|
|
55
|
-
const { fs } =
|
|
56
|
-
const { dtsTempDirectory } =
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
const clearBuildConfigPaths = (configs) =>
|
|
60
|
-
const { fs } =
|
|
34
|
+
const clearDtsTemp = async () => {
|
|
35
|
+
const { fs } = await Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
36
|
+
const { dtsTempDirectory } = await Promise.resolve().then(() => __toESM(require("../constants/dts")));
|
|
37
|
+
await fs.remove(dtsTempDirectory);
|
|
38
|
+
};
|
|
39
|
+
const clearBuildConfigPaths = async (configs) => {
|
|
40
|
+
const { fs } = await Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
61
41
|
for (const config of configs) {
|
|
62
|
-
|
|
42
|
+
await fs.remove(config.outDir);
|
|
63
43
|
}
|
|
64
|
-
}
|
|
44
|
+
};
|
|
65
45
|
// Annotate the CommonJS export names for ESM import in node:
|
|
66
46
|
0 && (module.exports = {
|
|
67
47
|
clearBuildConfigPaths,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":"
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,MAAM,eAAe,YAAY;AACtC,QAAM,EAAE,GAAG,IAAI,MAAM,6CAAO,kBAAkB;AAC9C,QAAM,EAAE,iBAAiB,IAAI,MAAM,6CAAO,kBAAkB;AAC5D,QAAM,GAAG,OAAO,gBAAgB;AAClC;AAEO,MAAM,wBAAwB,OAAO,YAA+B;AACzE,QAAM,EAAE,GAAG,IAAI,MAAM,6CAAO,kBAAkB;AAE9C,aAAW,UAAU,SAAS;AAC5B,UAAM,GAAG,OAAO,OAAO,MAAM;AAAA,EAC/B;AACF;;;;;;","names":[],"sources":["../../src/builder/clear.ts"],"sourcesContent":["import type { BaseBuildConfig } from '../types';\n\nexport const clearDtsTemp = async () => {\n const { fs } = await import('@modern-js/utils');\n const { dtsTempDirectory } = await import('../constants/dts');\n await fs.remove(dtsTempDirectory);\n};\n\nexport const clearBuildConfigPaths = async (configs: BaseBuildConfig[]) => {\n const { fs } = await import('@modern-js/utils');\n\n for (const config of configs) {\n await fs.remove(config.outDir);\n }\n};\n"]}
|