@modern-js/module-tools 2.10.1-beta.0 → 2.10.1-beta.1
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 +29 -9
- package/dist/build.js.map +1 -1
- package/dist/builder/build.js +86 -48
- package/dist/builder/build.js.map +1 -1
- package/dist/builder/clear.js +29 -9
- package/dist/builder/clear.js.map +1 -1
- package/dist/builder/copy.js +78 -39
- package/dist/builder/copy.js.map +1 -1
- package/dist/builder/dts/rollup.js +61 -26
- package/dist/builder/dts/rollup.js.map +1 -1
- package/dist/builder/dts/tsc.js +77 -37
- package/dist/builder/dts/tsc.js.map +1 -1
- package/dist/builder/index.js +36 -16
- package/dist/builder/index.js.map +1 -1
- package/dist/builder/platform.js +33 -13
- package/dist/builder/platform.js.map +1 -1
- package/dist/cli.js +45 -23
- package/dist/cli.js.map +1 -1
- package/dist/command.js +76 -39
- package/dist/command.js.map +1 -1
- package/dist/config/defineConfig.js +18 -2
- package/dist/config/defineConfig.js.map +1 -1
- package/dist/config/normalize.js +73 -45
- package/dist/config/normalize.js.map +1 -1
- package/dist/config/transformLegacyConfig.js +130 -90
- package/dist/config/transformLegacyConfig.js.map +1 -1
- package/dist/constants/buildPresets.js +23 -14
- package/dist/constants/buildPresets.js.map +1 -1
- package/dist/dev.js +43 -19
- package/dist/dev.js.map +1 -1
- package/dist/error.js +2 -7
- package/dist/error.js.map +1 -1
- package/dist/hooks/index.js +15 -6
- package/dist/hooks/index.js.map +1 -1
- package/dist/utils/builder.js +27 -7
- package/dist/utils/builder.js.map +1 -1
- package/dist/utils/common.js +19 -3
- package/dist/utils/common.js.map +1 -1
- package/dist/utils/config.js +83 -57
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/context.js +23 -3
- package/dist/utils/context.js.map +1 -1
- package/dist/utils/dts.js +64 -25
- package/dist/utils/dts.js.map +1 -1
- package/dist/utils/input.js +34 -14
- package/dist/utils/input.js.map +1 -1
- package/dist/utils/language.js +23 -3
- package/dist/utils/language.js.map +1 -1
- package/dist/utils/libuildPlugins.js +29 -9
- package/dist/utils/libuildPlugins.js.map +1 -1
- package/dist/utils/log.js +23 -3
- package/dist/utils/log.js.map +1 -1
- package/dist/utils/onExit.js +26 -6
- package/dist/utils/onExit.js.map +1 -1
- package/dist/utils/path.js +23 -3
- package/dist/utils/path.js.map +1 -1
- package/dist/utils/print.js +24 -4
- package/dist/utils/print.js.map +1 -1
- package/dist/utils/style.js +52 -29
- package/dist/utils/style.js.map +1 -1
- package/lib/types.d.ts +0 -98
- package/package.json +5 -5
package/dist/build.js
CHANGED
|
@@ -25,6 +25,26 @@ 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
|
+
};
|
|
28
48
|
var build_exports = {};
|
|
29
49
|
__export(build_exports, {
|
|
30
50
|
build: () => build
|
|
@@ -32,23 +52,23 @@ __export(build_exports, {
|
|
|
32
52
|
module.exports = __toCommonJS(build_exports);
|
|
33
53
|
var import_utils = require("@modern-js/utils");
|
|
34
54
|
const debug = (0, import_utils.createDebugger)("module-tools");
|
|
35
|
-
const build =
|
|
55
|
+
const build = (api, options, context) => __async(void 0, null, function* () {
|
|
36
56
|
if (options.platform) {
|
|
37
|
-
const { buildPlatform } =
|
|
38
|
-
|
|
57
|
+
const { buildPlatform } = yield Promise.resolve().then(() => __toESM(require("./builder/platform")));
|
|
58
|
+
yield buildPlatform(options, api, context);
|
|
39
59
|
return;
|
|
40
60
|
}
|
|
41
61
|
const runner = api.useHookRunners();
|
|
42
|
-
const { normalizeBuildConfig } =
|
|
43
|
-
const resolvedBuildConfig =
|
|
62
|
+
const { normalizeBuildConfig } = yield Promise.resolve().then(() => __toESM(require("./config/normalize")));
|
|
63
|
+
const resolvedBuildConfig = yield normalizeBuildConfig(api, context, options);
|
|
44
64
|
debug("resolvedBuildConfig", resolvedBuildConfig);
|
|
45
|
-
|
|
65
|
+
yield runner.beforeBuild({
|
|
46
66
|
config: resolvedBuildConfig,
|
|
47
67
|
cliOptions: options
|
|
48
68
|
});
|
|
49
|
-
const builder =
|
|
50
|
-
|
|
51
|
-
};
|
|
69
|
+
const builder = yield Promise.resolve().then(() => __toESM(require("./builder")));
|
|
70
|
+
yield builder.run({ cmdOptions: options, resolvedBuildConfig, context }, api);
|
|
71
|
+
});
|
|
52
72
|
// Annotate the CommonJS export names for ESM import in node:
|
|
53
73
|
0 && (module.exports = {
|
|
54
74
|
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,CACnB,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,9 +1,26 @@
|
|
|
1
1
|
var __create = Object.create;
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
8
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
9
|
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));
|
|
7
24
|
var __export = (target, all) => {
|
|
8
25
|
for (var name in all)
|
|
9
26
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -25,6 +42,26 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
25
42
|
mod
|
|
26
43
|
));
|
|
27
44
|
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
|
+
};
|
|
28
65
|
var build_exports = {};
|
|
29
66
|
__export(build_exports, {
|
|
30
67
|
buildInJsProject: () => buildInJsProject,
|
|
@@ -35,51 +72,53 @@ __export(build_exports, {
|
|
|
35
72
|
});
|
|
36
73
|
module.exports = __toCommonJS(build_exports);
|
|
37
74
|
var import_path = require("path");
|
|
38
|
-
const runBuildTask =
|
|
75
|
+
const runBuildTask = (options, api) => __async(void 0, null, function* () {
|
|
39
76
|
const { buildConfig, context, buildCmdOptions } = options;
|
|
40
77
|
const { appDirectory, isTsProject } = context;
|
|
41
|
-
const { copyTask } =
|
|
42
|
-
|
|
78
|
+
const { copyTask } = yield Promise.resolve().then(() => __toESM(require("./copy")));
|
|
79
|
+
yield copyTask(buildConfig, { appDirectory, watch: buildCmdOptions.watch });
|
|
43
80
|
if (isTsProject) {
|
|
44
|
-
|
|
81
|
+
yield buildInTsProject(options, api);
|
|
45
82
|
} else {
|
|
46
|
-
|
|
83
|
+
yield buildInJsProject(options, api);
|
|
47
84
|
}
|
|
48
|
-
};
|
|
49
|
-
const buildInTsProject =
|
|
85
|
+
});
|
|
86
|
+
const buildInTsProject = (options, api) => __async(void 0, null, function* () {
|
|
87
|
+
var _a;
|
|
50
88
|
const { buildConfig, buildCmdOptions } = options;
|
|
51
89
|
const dts = buildCmdOptions.dts ? buildConfig.dts : false;
|
|
52
90
|
const skipBuildLib = buildConfig.dts ? buildConfig.dts.only : false;
|
|
53
|
-
const watch = buildCmdOptions.watch
|
|
91
|
+
const watch = (_a = buildCmdOptions.watch) != null ? _a : false;
|
|
54
92
|
if (dts === false) {
|
|
55
|
-
!skipBuildLib &&
|
|
93
|
+
!skipBuildLib && (yield buildLib(buildConfig, api, { watch }));
|
|
56
94
|
} else {
|
|
57
95
|
const tasks = dts.only ? [generatorDts] : [buildLib, generatorDts];
|
|
58
|
-
const { default: pMap } =
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
});
|
|
96
|
+
const { default: pMap } = yield Promise.resolve().then(() => __toESM(require("../../compiled/p-map")));
|
|
97
|
+
yield pMap(tasks, (task) => __async(void 0, null, function* () {
|
|
98
|
+
yield task(buildConfig, api, { watch, dts });
|
|
99
|
+
}));
|
|
62
100
|
}
|
|
63
|
-
};
|
|
64
|
-
const buildInJsProject =
|
|
101
|
+
});
|
|
102
|
+
const buildInJsProject = (options, api) => __async(void 0, null, function* () {
|
|
103
|
+
var _a;
|
|
65
104
|
const { buildConfig, buildCmdOptions } = options;
|
|
66
105
|
const dts = buildCmdOptions.dts ? buildConfig.dts : false;
|
|
67
|
-
const watch = buildCmdOptions.watch
|
|
106
|
+
const watch = (_a = buildCmdOptions.watch) != null ? _a : false;
|
|
68
107
|
if (dts !== false && dts.only) {
|
|
69
108
|
return;
|
|
70
109
|
}
|
|
71
|
-
|
|
72
|
-
};
|
|
73
|
-
const generatorDts =
|
|
74
|
-
const { runRollup, runTsc } =
|
|
110
|
+
yield buildLib(buildConfig, api, { watch });
|
|
111
|
+
});
|
|
112
|
+
const generatorDts = (config, api, options) => __async(void 0, null, function* () {
|
|
113
|
+
const { runRollup, runTsc } = yield Promise.resolve().then(() => __toESM(require("./dts")));
|
|
75
114
|
const { watch, dts } = options;
|
|
76
115
|
const { buildType, input, sourceDir, alias } = config;
|
|
77
116
|
const { appDirectory } = api.useAppContext();
|
|
78
117
|
const { tsconfigPath, distPath } = dts;
|
|
79
118
|
if (buildType === "bundle") {
|
|
80
|
-
const { getFinalExternals } =
|
|
81
|
-
const finalExternals =
|
|
82
|
-
|
|
119
|
+
const { getFinalExternals } = yield Promise.resolve().then(() => __toESM(require("../utils/builder")));
|
|
120
|
+
const finalExternals = yield getFinalExternals(config, { appDirectory });
|
|
121
|
+
yield runRollup(api, {
|
|
83
122
|
distDir: distPath,
|
|
84
123
|
watch,
|
|
85
124
|
externals: finalExternals,
|
|
@@ -87,7 +126,7 @@ const generatorDts = async (config, api, options) => {
|
|
|
87
126
|
tsconfigPath
|
|
88
127
|
});
|
|
89
128
|
} else {
|
|
90
|
-
|
|
129
|
+
yield runTsc(api, {
|
|
91
130
|
appDirectory,
|
|
92
131
|
alias,
|
|
93
132
|
distAbsPath: distPath,
|
|
@@ -96,8 +135,9 @@ const generatorDts = async (config, api, options) => {
|
|
|
96
135
|
sourceDir
|
|
97
136
|
});
|
|
98
137
|
}
|
|
99
|
-
};
|
|
100
|
-
const buildLib =
|
|
138
|
+
});
|
|
139
|
+
const buildLib = (config, api, options) => __async(void 0, null, function* () {
|
|
140
|
+
var _a;
|
|
101
141
|
const { watch } = options;
|
|
102
142
|
const {
|
|
103
143
|
target,
|
|
@@ -124,20 +164,20 @@ const buildLib = async (config, api, options) => {
|
|
|
124
164
|
sideEffects
|
|
125
165
|
} = config;
|
|
126
166
|
const { appDirectory } = api.useAppContext();
|
|
127
|
-
const { slash } =
|
|
167
|
+
const { slash } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
128
168
|
const root = slash(appDirectory);
|
|
129
169
|
const outdir = slash(distPath);
|
|
130
170
|
const assetOutDir = asset.path ? slash(asset.path) : asset.path;
|
|
131
171
|
const { less, sass, postcss, inject, modules, autoModules } = style;
|
|
132
|
-
const { es5Plugin, umdPlugin, transformPlugin } =
|
|
172
|
+
const { es5Plugin, umdPlugin, transformPlugin } = yield Promise.resolve().then(() => __toESM(require("@modern-js/libuild-plugin-swc")));
|
|
133
173
|
const plugins = format === "umd" ? [umdPlugin(umdModuleName)] : [];
|
|
134
174
|
if (target === "es5") {
|
|
135
175
|
plugins.push(es5Plugin());
|
|
136
176
|
}
|
|
137
|
-
const { getProjectTsconfig } =
|
|
177
|
+
const { getProjectTsconfig } = yield Promise.resolve().then(() => __toESM(require("./dts/tsc")));
|
|
138
178
|
const tsconfigPath = dts ? dts.tsconfigPath : (0, import_path.join)(appDirectory, "./tsconfig.json");
|
|
139
|
-
const userTsconfig =
|
|
140
|
-
if (userTsconfig
|
|
179
|
+
const userTsconfig = yield getProjectTsconfig(tsconfigPath);
|
|
180
|
+
if ((_a = userTsconfig == null ? void 0 : userTsconfig.compilerOptions) == null ? void 0 : _a.emitDecoratorMetadata) {
|
|
141
181
|
plugins.push(
|
|
142
182
|
transformPlugin({
|
|
143
183
|
jsc: {
|
|
@@ -150,11 +190,11 @@ const buildLib = async (config, api, options) => {
|
|
|
150
190
|
);
|
|
151
191
|
}
|
|
152
192
|
if (asset.svgr) {
|
|
153
|
-
const { svgrPlugin } =
|
|
193
|
+
const { svgrPlugin } = yield Promise.resolve().then(() => __toESM(require("@modern-js/libuild-plugin-svgr")));
|
|
154
194
|
const options2 = typeof asset.svgr === "boolean" ? {} : asset.svgr;
|
|
155
195
|
plugins.push(svgrPlugin(options2));
|
|
156
196
|
}
|
|
157
|
-
const { watchPlugin, externalPlugin } =
|
|
197
|
+
const { watchPlugin, externalPlugin } = yield Promise.resolve().then(() => __toESM(require("../utils/libuildPlugins")));
|
|
158
198
|
plugins.push(watchPlugin(api, config));
|
|
159
199
|
plugins.push(externalPlugin(config, { appDirectory }));
|
|
160
200
|
const buildConfig = {
|
|
@@ -176,10 +216,9 @@ const buildLib = async (config, api, options) => {
|
|
|
176
216
|
resolve: {
|
|
177
217
|
alias
|
|
178
218
|
},
|
|
179
|
-
asset: {
|
|
180
|
-
...asset,
|
|
219
|
+
asset: __spreadProps(__spreadValues({}, asset), {
|
|
181
220
|
outdir: assetOutDir
|
|
182
|
-
},
|
|
221
|
+
}),
|
|
183
222
|
plugins,
|
|
184
223
|
jsx,
|
|
185
224
|
input,
|
|
@@ -195,40 +234,39 @@ const buildLib = async (config, api, options) => {
|
|
|
195
234
|
sideEffects,
|
|
196
235
|
// outbase for [dir]/[name]
|
|
197
236
|
outbase: sourceDir,
|
|
198
|
-
esbuildOptions: (options2) => ({
|
|
199
|
-
...options2,
|
|
237
|
+
esbuildOptions: (options2) => __spreadProps(__spreadValues({}, options2), {
|
|
200
238
|
supported: {
|
|
201
239
|
"dynamic-import": !(["cjs", "umd"].includes(format) && buildType === "bundleless")
|
|
202
240
|
}
|
|
203
241
|
})
|
|
204
242
|
};
|
|
205
243
|
try {
|
|
206
|
-
const { Libuilder } =
|
|
207
|
-
const { addOutputChunk } =
|
|
244
|
+
const { Libuilder } = yield Promise.resolve().then(() => __toESM(require("@modern-js/libuild")));
|
|
245
|
+
const { addOutputChunk } = yield Promise.resolve().then(() => __toESM(require("../utils/print")));
|
|
208
246
|
const runner = api.useHookRunners();
|
|
209
|
-
const modifiedBuildConfig =
|
|
247
|
+
const modifiedBuildConfig = yield runner.modifyLibuild(buildConfig, {
|
|
210
248
|
onLast: (c) => c
|
|
211
249
|
});
|
|
212
|
-
const builder =
|
|
213
|
-
|
|
250
|
+
const builder = yield Libuilder.create(modifiedBuildConfig);
|
|
251
|
+
yield builder.build();
|
|
214
252
|
addOutputChunk(builder.outputChunk, root, buildType === "bundle");
|
|
215
253
|
if (watch) {
|
|
216
|
-
const { watchSectionTitle } =
|
|
217
|
-
const { SectionTitleStatus } =
|
|
254
|
+
const { watchSectionTitle } = yield Promise.resolve().then(() => __toESM(require("../utils/log")));
|
|
255
|
+
const { SectionTitleStatus } = yield Promise.resolve().then(() => __toESM(require("../constants/log")));
|
|
218
256
|
const titleText = `[${buildType === "bundle" ? "Bundle" : "Bundleless"}: ${format}_${target}]`;
|
|
219
257
|
console.info(
|
|
220
|
-
|
|
258
|
+
yield watchSectionTitle(titleText, SectionTitleStatus.Success)
|
|
221
259
|
);
|
|
222
260
|
}
|
|
223
261
|
} catch (e) {
|
|
224
|
-
const { InternalBuildError } =
|
|
262
|
+
const { InternalBuildError } = yield Promise.resolve().then(() => __toESM(require("../error")));
|
|
225
263
|
throw new InternalBuildError(e, {
|
|
226
264
|
target,
|
|
227
265
|
format,
|
|
228
266
|
buildType
|
|
229
267
|
});
|
|
230
268
|
}
|
|
231
|
-
};
|
|
269
|
+
});
|
|
232
270
|
// Annotate the CommonJS export names for ESM import in node:
|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AI,mBAAmB,GAAG;AAAA,MAC9B;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH;AACF;;;;;;;;;","names":["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"]}
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAqB;AAWd,MAAM,eAAe,CAC1B,SAKA,QACG;AACH,QAAM,EAAE,aAAa,SAAS,gBAAgB,IAAI;AAClD,QAAM,EAAE,cAAc,YAAY,IAAI;AAEtC,QAAM,EAAE,SAAS,IAAI,MAAM,6CAAO,QAAQ;AAC1C,QAAM,SAAS,aAAa,EAAE,cAAc,OAAO,gBAAgB,MAAM,CAAC;AAE1E,MAAI,aAAa;AACf,UAAM,iBAAiB,SAAS,GAAG;AAAA,EACrC,OAAO;AACL,UAAM,iBAAiB,SAAS,GAAG;AAAA,EACrC;AACF;AAEO,MAAM,mBAAmB,CAC9B,SAKA,QACG;AAvCL;AAwCE,QAAM,EAAE,aAAa,gBAAgB,IAAI;AACzC,QAAM,MAAM,gBAAgB,MAAM,YAAY,MAAM;AACpD,QAAM,eAAe,YAAY,MAAM,YAAY,IAAI,OAAO;AAC9D,QAAM,SAAQ,qBAAgB,UAAhB,YAAyB;AAEvC,MAAI,QAAQ,OAAO;AAEjB,KAAC,iBAAiB,MAAM,SAAS,aAAa,KAAK,EAAE,MAAM,CAAC;AAAA,EAC9D,OAAO;AACL,UAAM,QAAQ,IAAI,OAAO,CAAC,YAAY,IAAI,CAAC,UAAU,YAAY;AACjE,UAAM,EAAE,SAAS,KAAK,IAAI,MAAM,6CAAO,sBAAsB;AAC7D,UAAM,KAAK,OAAO,CAAM,SAAQ;AAC9B,YAAM,KAAK,aAAa,KAAY,EAAE,OAAO,IAAI,CAAC;AAAA,IACpD,EAAC;AAAA,EACH;AACF;AAEO,MAAM,mBAAmB,CAC9B,SAKA,QACG;AAhEL;AAiEE,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AAA,IACF;AAAA,EACF,SAAS,GAAP;AACA,UAAM,EAAE,mBAAmB,IAAI,MAAM,6CAAO,UAAU;AACtD,UAAM,IAAI,mBAAmB,GAAG;AAAA,MAC9B;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH;AACF;;;;;;;;;","names":["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,23 +25,43 @@ 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
|
+
};
|
|
28
48
|
var clear_exports = {};
|
|
29
49
|
__export(clear_exports, {
|
|
30
50
|
clearBuildConfigPaths: () => clearBuildConfigPaths,
|
|
31
51
|
clearDtsTemp: () => clearDtsTemp
|
|
32
52
|
});
|
|
33
53
|
module.exports = __toCommonJS(clear_exports);
|
|
34
|
-
const clearDtsTemp =
|
|
35
|
-
const { fs } =
|
|
36
|
-
const { dtsTempDirectory } =
|
|
37
|
-
|
|
38
|
-
};
|
|
39
|
-
const clearBuildConfigPaths =
|
|
40
|
-
const { fs } =
|
|
54
|
+
const clearDtsTemp = () => __async(void 0, null, function* () {
|
|
55
|
+
const { fs } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
56
|
+
const { dtsTempDirectory } = yield Promise.resolve().then(() => __toESM(require("../constants/dts")));
|
|
57
|
+
yield fs.remove(dtsTempDirectory);
|
|
58
|
+
});
|
|
59
|
+
const clearBuildConfigPaths = (configs) => __async(void 0, null, function* () {
|
|
60
|
+
const { fs } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
41
61
|
for (const config of configs) {
|
|
42
|
-
|
|
62
|
+
yield fs.remove(config.outDir);
|
|
43
63
|
}
|
|
44
|
-
};
|
|
64
|
+
});
|
|
45
65
|
// Annotate the CommonJS export names for ESM import in node:
|
|
46
66
|
0 && (module.exports = {
|
|
47
67
|
clearBuildConfigPaths,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":"
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,MAAM,eAAe,MAAY;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,CAAO,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"]}
|