@modern-js/module-tools 2.10.1-beta.0 → 2.10.1-beta.2
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 +93 -52
- 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 +82 -42
- package/dist/builder/copy.js.map +1 -1
- package/dist/builder/dts/rollup.d.ts +4 -2
- package/dist/builder/dts/rollup.js +73 -34
- package/dist/builder/dts/rollup.js.map +1 -1
- package/dist/builder/dts/tsc.js +88 -47
- package/dist/builder/dts/tsc.js.map +1 -1
- package/dist/builder/index.js +39 -18
- package/dist/builder/index.js.map +1 -1
- package/dist/builder/platform.js +46 -25
- 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/schema.d.ts +12 -0
- package/dist/config/schema.js +2 -1
- package/dist/config/schema.js.map +1 -1
- package/dist/config/transformLegacyConfig.js +130 -90
- package/dist/config/transformLegacyConfig.js.map +1 -1
- package/dist/constants/build.d.ts +0 -3
- package/dist/constants/build.js +2 -11
- package/dist/constants/build.js.map +1 -1
- package/dist/constants/buildPresets.js +23 -14
- package/dist/constants/buildPresets.js.map +1 -1
- package/dist/dev.js +46 -21
- 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/locale/en.d.ts +3 -0
- package/dist/locale/en.js +5 -3
- package/dist/locale/en.js.map +1 -1
- package/dist/locale/index.d.ts +6 -0
- package/dist/locale/zh.d.ts +3 -0
- package/dist/locale/zh.js +5 -3
- package/dist/locale/zh.js.map +1 -1
- package/dist/types/config/index.d.ts +1 -0
- package/dist/types/config/index.js.map +1 -1
- package/dist/types/dts.d.ts +1 -0
- package/dist/types/dts.js.map +1 -1
- package/dist/utils/builder.js +29 -8
- 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.d.ts +6 -2
- package/dist/utils/dts.js +92 -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 +30 -11
- package/dist/utils/libuildPlugins.js.map +1 -1
- package/dist/utils/log.js +26 -10
- 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 +31 -13
- 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 +4 -4
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,69 +72,75 @@ __export(build_exports, {
|
|
|
35
72
|
});
|
|
36
73
|
module.exports = __toCommonJS(build_exports);
|
|
37
74
|
var import_path = require("path");
|
|
38
|
-
|
|
75
|
+
var import_logger = require("@modern-js/utils/logger");
|
|
76
|
+
const runBuildTask = (options, api) => __async(void 0, null, function* () {
|
|
39
77
|
const { buildConfig, context, buildCmdOptions } = options;
|
|
40
78
|
const { appDirectory, isTsProject } = context;
|
|
41
|
-
const { copyTask } =
|
|
42
|
-
|
|
79
|
+
const { copyTask } = yield Promise.resolve().then(() => __toESM(require("./copy")));
|
|
80
|
+
yield copyTask(buildConfig, { appDirectory, watch: buildCmdOptions.watch });
|
|
43
81
|
if (isTsProject) {
|
|
44
|
-
|
|
82
|
+
yield buildInTsProject(options, api);
|
|
45
83
|
} else {
|
|
46
|
-
|
|
84
|
+
yield buildInJsProject(options, api);
|
|
47
85
|
}
|
|
48
|
-
};
|
|
49
|
-
const buildInTsProject =
|
|
86
|
+
});
|
|
87
|
+
const buildInTsProject = (options, api) => __async(void 0, null, function* () {
|
|
88
|
+
var _a;
|
|
50
89
|
const { buildConfig, buildCmdOptions } = options;
|
|
51
90
|
const dts = buildCmdOptions.dts ? buildConfig.dts : false;
|
|
52
91
|
const skipBuildLib = buildConfig.dts ? buildConfig.dts.only : false;
|
|
53
|
-
const watch = buildCmdOptions.watch
|
|
92
|
+
const watch = (_a = buildCmdOptions.watch) != null ? _a : false;
|
|
54
93
|
if (dts === false) {
|
|
55
|
-
!skipBuildLib &&
|
|
94
|
+
!skipBuildLib && (yield buildLib(buildConfig, api, { watch }));
|
|
56
95
|
} else {
|
|
57
96
|
const tasks = dts.only ? [generatorDts] : [buildLib, generatorDts];
|
|
58
|
-
const { default: pMap } =
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
});
|
|
97
|
+
const { default: pMap } = yield Promise.resolve().then(() => __toESM(require("../../compiled/p-map")));
|
|
98
|
+
yield pMap(tasks, (task) => __async(void 0, null, function* () {
|
|
99
|
+
yield task(buildConfig, api, { watch, dts });
|
|
100
|
+
}));
|
|
62
101
|
}
|
|
63
|
-
};
|
|
64
|
-
const buildInJsProject =
|
|
102
|
+
});
|
|
103
|
+
const buildInJsProject = (options, api) => __async(void 0, null, function* () {
|
|
104
|
+
var _a;
|
|
65
105
|
const { buildConfig, buildCmdOptions } = options;
|
|
66
106
|
const dts = buildCmdOptions.dts ? buildConfig.dts : false;
|
|
67
|
-
const watch = buildCmdOptions.watch
|
|
107
|
+
const watch = (_a = buildCmdOptions.watch) != null ? _a : false;
|
|
68
108
|
if (dts !== false && dts.only) {
|
|
69
109
|
return;
|
|
70
110
|
}
|
|
71
|
-
|
|
72
|
-
};
|
|
73
|
-
const generatorDts =
|
|
74
|
-
const { runRollup, runTsc } =
|
|
111
|
+
yield buildLib(buildConfig, api, { watch });
|
|
112
|
+
});
|
|
113
|
+
const generatorDts = (config, api, options) => __async(void 0, null, function* () {
|
|
114
|
+
const { runRollup, runTsc } = yield Promise.resolve().then(() => __toESM(require("./dts")));
|
|
75
115
|
const { watch, dts } = options;
|
|
76
116
|
const { buildType, input, sourceDir, alias } = config;
|
|
77
117
|
const { appDirectory } = api.useAppContext();
|
|
78
|
-
const { tsconfigPath, distPath } = dts;
|
|
118
|
+
const { tsconfigPath, distPath, abortOnError } = dts;
|
|
79
119
|
if (buildType === "bundle") {
|
|
80
|
-
const { getFinalExternals } =
|
|
81
|
-
const finalExternals =
|
|
82
|
-
|
|
120
|
+
const { getFinalExternals } = yield Promise.resolve().then(() => __toESM(require("../utils/builder")));
|
|
121
|
+
const finalExternals = yield getFinalExternals(config, { appDirectory });
|
|
122
|
+
yield runRollup(api, {
|
|
83
123
|
distDir: distPath,
|
|
84
124
|
watch,
|
|
85
125
|
externals: finalExternals,
|
|
86
126
|
input,
|
|
87
|
-
tsconfigPath
|
|
127
|
+
tsconfigPath,
|
|
128
|
+
abortOnError
|
|
88
129
|
});
|
|
89
130
|
} else {
|
|
90
|
-
|
|
131
|
+
yield runTsc(api, {
|
|
91
132
|
appDirectory,
|
|
92
133
|
alias,
|
|
93
134
|
distAbsPath: distPath,
|
|
94
135
|
watch,
|
|
95
136
|
tsconfigPath,
|
|
96
|
-
sourceDir
|
|
137
|
+
sourceDir,
|
|
138
|
+
abortOnError
|
|
97
139
|
});
|
|
98
140
|
}
|
|
99
|
-
};
|
|
100
|
-
const buildLib =
|
|
141
|
+
});
|
|
142
|
+
const buildLib = (config, api, options) => __async(void 0, null, function* () {
|
|
143
|
+
var _a;
|
|
101
144
|
const { watch } = options;
|
|
102
145
|
const {
|
|
103
146
|
target,
|
|
@@ -124,20 +167,20 @@ const buildLib = async (config, api, options) => {
|
|
|
124
167
|
sideEffects
|
|
125
168
|
} = config;
|
|
126
169
|
const { appDirectory } = api.useAppContext();
|
|
127
|
-
const { slash } =
|
|
170
|
+
const { slash } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
128
171
|
const root = slash(appDirectory);
|
|
129
172
|
const outdir = slash(distPath);
|
|
130
173
|
const assetOutDir = asset.path ? slash(asset.path) : asset.path;
|
|
131
174
|
const { less, sass, postcss, inject, modules, autoModules } = style;
|
|
132
|
-
const { es5Plugin, umdPlugin, transformPlugin } =
|
|
175
|
+
const { es5Plugin, umdPlugin, transformPlugin } = yield Promise.resolve().then(() => __toESM(require("@modern-js/libuild-plugin-swc")));
|
|
133
176
|
const plugins = format === "umd" ? [umdPlugin(umdModuleName)] : [];
|
|
134
177
|
if (target === "es5") {
|
|
135
178
|
plugins.push(es5Plugin());
|
|
136
179
|
}
|
|
137
|
-
const { getProjectTsconfig } =
|
|
180
|
+
const { getProjectTsconfig } = yield Promise.resolve().then(() => __toESM(require("./dts/tsc")));
|
|
138
181
|
const tsconfigPath = dts ? dts.tsconfigPath : (0, import_path.join)(appDirectory, "./tsconfig.json");
|
|
139
|
-
const userTsconfig =
|
|
140
|
-
if (userTsconfig
|
|
182
|
+
const userTsconfig = yield getProjectTsconfig(tsconfigPath);
|
|
183
|
+
if ((_a = userTsconfig == null ? void 0 : userTsconfig.compilerOptions) == null ? void 0 : _a.emitDecoratorMetadata) {
|
|
141
184
|
plugins.push(
|
|
142
185
|
transformPlugin({
|
|
143
186
|
jsc: {
|
|
@@ -150,11 +193,11 @@ const buildLib = async (config, api, options) => {
|
|
|
150
193
|
);
|
|
151
194
|
}
|
|
152
195
|
if (asset.svgr) {
|
|
153
|
-
const { svgrPlugin } =
|
|
196
|
+
const { svgrPlugin } = yield Promise.resolve().then(() => __toESM(require("@modern-js/libuild-plugin-svgr")));
|
|
154
197
|
const options2 = typeof asset.svgr === "boolean" ? {} : asset.svgr;
|
|
155
198
|
plugins.push(svgrPlugin(options2));
|
|
156
199
|
}
|
|
157
|
-
const { watchPlugin, externalPlugin } =
|
|
200
|
+
const { watchPlugin, externalPlugin } = yield Promise.resolve().then(() => __toESM(require("../utils/libuildPlugins")));
|
|
158
201
|
plugins.push(watchPlugin(api, config));
|
|
159
202
|
plugins.push(externalPlugin(config, { appDirectory }));
|
|
160
203
|
const buildConfig = {
|
|
@@ -176,10 +219,9 @@ const buildLib = async (config, api, options) => {
|
|
|
176
219
|
resolve: {
|
|
177
220
|
alias
|
|
178
221
|
},
|
|
179
|
-
asset: {
|
|
180
|
-
...asset,
|
|
222
|
+
asset: __spreadProps(__spreadValues({}, asset), {
|
|
181
223
|
outdir: assetOutDir
|
|
182
|
-
},
|
|
224
|
+
}),
|
|
183
225
|
plugins,
|
|
184
226
|
jsx,
|
|
185
227
|
input,
|
|
@@ -195,40 +237,39 @@ const buildLib = async (config, api, options) => {
|
|
|
195
237
|
sideEffects,
|
|
196
238
|
// outbase for [dir]/[name]
|
|
197
239
|
outbase: sourceDir,
|
|
198
|
-
esbuildOptions: (options2) => ({
|
|
199
|
-
...options2,
|
|
240
|
+
esbuildOptions: (options2) => __spreadProps(__spreadValues({}, options2), {
|
|
200
241
|
supported: {
|
|
201
242
|
"dynamic-import": !(["cjs", "umd"].includes(format) && buildType === "bundleless")
|
|
202
243
|
}
|
|
203
244
|
})
|
|
204
245
|
};
|
|
205
246
|
try {
|
|
206
|
-
const { Libuilder } =
|
|
207
|
-
const { addOutputChunk } =
|
|
247
|
+
const { Libuilder } = yield Promise.resolve().then(() => __toESM(require("@modern-js/libuild")));
|
|
248
|
+
const { addOutputChunk } = yield Promise.resolve().then(() => __toESM(require("../utils/print")));
|
|
208
249
|
const runner = api.useHookRunners();
|
|
209
|
-
const modifiedBuildConfig =
|
|
250
|
+
const modifiedBuildConfig = yield runner.modifyLibuild(buildConfig, {
|
|
210
251
|
onLast: (c) => c
|
|
211
252
|
});
|
|
212
|
-
const builder =
|
|
213
|
-
|
|
253
|
+
const builder = yield Libuilder.create(modifiedBuildConfig);
|
|
254
|
+
yield builder.build();
|
|
214
255
|
addOutputChunk(builder.outputChunk, root, buildType === "bundle");
|
|
215
256
|
if (watch) {
|
|
216
|
-
const { watchSectionTitle } =
|
|
217
|
-
const { SectionTitleStatus } =
|
|
257
|
+
const { watchSectionTitle } = yield Promise.resolve().then(() => __toESM(require("../utils/log")));
|
|
258
|
+
const { SectionTitleStatus } = yield Promise.resolve().then(() => __toESM(require("../constants/log")));
|
|
218
259
|
const titleText = `[${buildType === "bundle" ? "Bundle" : "Bundleless"}: ${format}_${target}]`;
|
|
219
|
-
|
|
220
|
-
|
|
260
|
+
import_logger.logger.info(
|
|
261
|
+
yield watchSectionTitle(titleText, SectionTitleStatus.Success)
|
|
221
262
|
);
|
|
222
263
|
}
|
|
223
264
|
} catch (e) {
|
|
224
|
-
const { InternalBuildError } =
|
|
265
|
+
const { InternalBuildError } = yield Promise.resolve().then(() => __toESM(require("../error")));
|
|
225
266
|
throw new InternalBuildError(e, {
|
|
226
267
|
target,
|
|
227
268
|
format,
|
|
228
269
|
buildType
|
|
229
270
|
});
|
|
230
271
|
}
|
|
231
|
-
};
|
|
272
|
+
});
|
|
232
273
|
// Annotate the CommonJS export names for ESM import in node:
|
|
233
274
|
0 && (module.exports = {
|
|
234
275
|
buildInJsProject,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAqB;AAWd,MAAM,eAAe,OAC1B,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,OAC9B,SAKA,QACG;AACH,QAAM,EAAE,aAAa,gBAAgB,IAAI;AACzC,Q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,6CAAO,gBAAgB;AACxD,UAAM,SAAS,IAAI,eAAe;AAClC,UAAM,sBAAsB,MAAM,OAAO,cAAc,aAAa;AAAA,MAClE,QAAQ,OAAK;AAAA,IACf,CAAC;AAED,UAAM,UAAU,MAAM,UAAU,OAAO,mBAAmB;AAC1D,UAAM,QAAQ,MAAM;AACpB,mBAAe,QAAQ,aAAa,MAAM,cAAc,QAAQ;AAEhE,QAAI,OAAO;AACT,YAAM,EAAE,kBAAkB,IAAI,MAAM,6CAAO,cAAc;AACzD,YAAM,EAAE,mBAAmB,IAAI,MAAM,6CAAO,kBAAkB;AAC9D,YAAM,YAAY,IAChB,cAAc,WAAW,WAAW,iBACjC,UAAU;AAEf,cAAQ;AAAA,QACN,MAAM,kBAAkB,WAAW,mBAAmB,OAAO;AAAA,MAC/D;AAAA,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"]}
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAqB;AACrB,oBAAuB;AAWhB,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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AK,cAAc;AAAA,MAErD;AAAA,IACF;AAAA,EACF;AAEA,MAAI;AACF,UAAM,EAAE,UAAU,IAAI,MAAM,6CAAO,oBAAoB;AACvD,UAAM,EAAE,eAAe,IAAI,MAAM,6CAAO,gBAAgB;AACxD,UAAM,SAAS,IAAI,eAAe;AAClC,UAAM,sBAAsB,MAAM,OAAO,cAAc,aAAa;AAAA,MAClE,QAAQ,OAAK;AAAA,IACf,CAAC;AAED,UAAM,UAAU,MAAM,UAAU,OAAO,mBAAmB;AAC1D,UAAM,QAAQ,MAAM;AACpB,mBAAe,QAAQ,aAAa,MAAM,cAAc,QAAQ;AAEhE,QAAI,OAAO;AACT,YAAM,EAAE,kBAAkB,IAAI,MAAM,6CAAO,cAAc;AACzD,YAAM,EAAE,mBAAmB,IAAI,MAAM,6CAAO,kBAAkB;AAC9D,YAAM,YAAY,IAChB,cAAc,WAAW,WAAW,iBACjC,UAAU;AAEf,2BAAO;AAAA,QACL,MAAM,kBAAkB,WAAW,mBAAmB,OAAO;AAAA,MAC/D;AAAA,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 { logger } from '@modern-js/utils/logger';\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, abortOnError } = 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 abortOnError,\n });\n } else {\n await runTsc(api, {\n appDirectory,\n alias,\n distAbsPath: distPath,\n watch,\n tsconfigPath,\n sourceDir,\n abortOnError,\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 logger.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"]}
|