@modern-js/module-tools 2.15.0 → 2.16.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/CHANGELOG.md +38 -0
- package/compiled/postcss-custom-properties/index.js +1 -1
- package/compiled/postcss-custom-properties/package.json +1 -1
- package/dist/build.js +23 -66
- package/dist/build.js.map +1 -1
- package/dist/builder/build.js +114 -170
- package/dist/builder/build.js.map +1 -1
- package/dist/builder/clear.js +23 -65
- package/dist/builder/clear.js.map +1 -1
- package/dist/builder/copy.js +83 -164
- package/dist/builder/copy.js.map +1 -1
- package/dist/builder/dts/index.js +15 -28
- package/dist/builder/dts/index.js.map +1 -1
- package/dist/builder/dts/rollup.js +46 -120
- package/dist/builder/dts/rollup.js.map +1 -1
- package/dist/builder/dts/tsc.js +82 -141
- package/dist/builder/dts/tsc.js.map +1 -1
- package/dist/builder/index.js +34 -85
- package/dist/builder/index.js.map +1 -1
- package/dist/builder/platform.js +40 -93
- package/dist/builder/platform.js.map +1 -1
- package/dist/cli.js +35 -84
- package/dist/cli.js.map +1 -1
- package/dist/command.js +56 -136
- package/dist/command.js.map +1 -1
- package/dist/config/defineConfig.js +13 -42
- package/dist/config/defineConfig.js.map +1 -1
- package/dist/config/legacySchema.js +96 -52
- package/dist/config/legacySchema.js.map +1 -1
- package/dist/config/normalize.js +73 -149
- package/dist/config/normalize.js.map +1 -1
- package/dist/config/schema.d.ts +36 -0
- package/dist/config/schema.js +118 -56
- package/dist/config/schema.js.map +1 -1
- package/dist/config/transformLegacyConfig.js +152 -203
- package/dist/config/transformLegacyConfig.js.map +1 -1
- package/dist/constants/build.js +15 -27
- package/dist/constants/build.js.map +1 -1
- package/dist/constants/buildPresets.js +71 -84
- package/dist/constants/buildPresets.js.map +1 -1
- package/dist/constants/colors.js +28 -30
- package/dist/constants/colors.js.map +1 -1
- package/dist/constants/dts.js +13 -28
- package/dist/constants/dts.js.map +1 -1
- package/dist/constants/file.js +27 -30
- package/dist/constants/file.js.map +1 -1
- package/dist/constants/legacyBuildPresets.js +33 -49
- package/dist/constants/legacyBuildPresets.js.map +1 -1
- package/dist/constants/log.js +15 -33
- package/dist/constants/log.js.map +1 -1
- package/dist/dev.js +45 -91
- package/dist/dev.js.map +1 -1
- package/dist/error.js +37 -54
- package/dist/error.js.map +1 -1
- package/dist/hooks/build.js +22 -35
- package/dist/hooks/build.js.map +1 -1
- package/dist/hooks/dev.js +15 -33
- package/dist/hooks/dev.js.map +1 -1
- package/dist/hooks/index.js +15 -42
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/misc.js +10 -28
- package/dist/hooks/misc.js.map +1 -1
- package/dist/index.js +21 -35
- package/dist/index.js.map +1 -1
- package/dist/locale/en.d.ts +7 -2
- package/dist/locale/en.js +25 -32
- package/dist/locale/en.js.map +1 -1
- package/dist/locale/index.d.ts +14 -4
- package/dist/locale/index.js +18 -31
- package/dist/locale/index.js.map +1 -1
- package/dist/locale/zh.d.ts +7 -2
- package/dist/locale/zh.js +25 -32
- package/dist/locale/zh.js.map +1 -1
- package/dist/plugins.js +16 -39
- package/dist/plugins.js.map +1 -1
- package/dist/types/color.js +4 -15
- package/dist/types/color.js.map +1 -1
- package/dist/types/command.js +4 -15
- package/dist/types/command.js.map +1 -1
- package/dist/types/config/index.d.ts +6 -0
- package/dist/types/config/index.js +6 -17
- package/dist/types/config/index.js.map +1 -1
- package/dist/types/config/style.js +4 -15
- package/dist/types/config/style.js.map +1 -1
- package/dist/types/context.js +4 -15
- package/dist/types/context.js.map +1 -1
- package/dist/types/copy.js +4 -15
- package/dist/types/copy.js.map +1 -1
- package/dist/types/dts.js +4 -15
- package/dist/types/dts.js.map +1 -1
- package/dist/types/hooks.js +4 -15
- package/dist/types/hooks.js.map +1 -1
- package/dist/types/index.js +11 -22
- package/dist/types/index.js.map +1 -1
- package/dist/types/legacyConfig/index.js +4 -15
- package/dist/types/legacyConfig/index.js.map +1 -1
- package/dist/types/legacyConfig/output.js +4 -15
- package/dist/types/legacyConfig/output.js.map +1 -1
- package/dist/types/legacyConfig/source.js +4 -15
- package/dist/types/legacyConfig/source.js.map +1 -1
- package/dist/types/legacyConfig/tools.js +4 -15
- package/dist/types/legacyConfig/tools.js.map +1 -1
- package/dist/types/utils.js +4 -17
- package/dist/utils/builder.d.ts +20 -2
- package/dist/utils/builder.js +81 -68
- package/dist/utils/builder.js.map +1 -1
- package/dist/utils/common.js +10 -44
- package/dist/utils/common.js.map +1 -1
- package/dist/utils/config.js +108 -144
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/context.js +16 -59
- package/dist/utils/context.js.map +1 -1
- package/dist/utils/dts.js +69 -146
- package/dist/utils/dts.js.map +1 -1
- package/dist/utils/input.js +44 -87
- package/dist/utils/input.js.map +1 -1
- package/dist/utils/language.js +15 -60
- package/dist/utils/language.js.map +1 -1
- package/dist/utils/libuildPlugins.js +27 -67
- package/dist/utils/libuildPlugins.js.map +1 -1
- package/dist/utils/log.js +14 -61
- package/dist/utils/log.js.map +1 -1
- package/dist/utils/onExit.js +14 -61
- package/dist/utils/onExit.js.map +1 -1
- package/dist/utils/path.js +13 -59
- package/dist/utils/path.js.map +1 -1
- package/dist/utils/print.js +57 -105
- package/dist/utils/print.js.map +1 -1
- package/dist/utils/style.js +54 -106
- package/dist/utils/style.js.map +1 -1
- package/dist/utils/tspathsTransform.js +44 -81
- package/dist/utils/tspathsTransform.js.map +1 -1
- package/package.json +25 -20
- package/scripts/debug-mode.js +23 -21
- package/dist/types/utils.js.map +0 -1
package/dist/builder/build.js
CHANGED
|
@@ -1,125 +1,88 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
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));
|
|
24
|
-
var __export = (target, all) => {
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
25
6
|
for (var name in all)
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
return to;
|
|
35
|
-
};
|
|
36
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
37
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
38
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
39
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
40
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
41
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
42
|
-
mod
|
|
43
|
-
));
|
|
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
|
-
};
|
|
65
|
-
var build_exports = {};
|
|
66
|
-
__export(build_exports, {
|
|
67
|
-
buildInJsProject: () => buildInJsProject,
|
|
7
|
+
Object.defineProperty(target, name, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: all[name]
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
_export(exports, {
|
|
13
|
+
runBuildTask: () => runBuildTask,
|
|
68
14
|
buildInTsProject: () => buildInTsProject,
|
|
69
|
-
|
|
15
|
+
buildInJsProject: () => buildInJsProject,
|
|
70
16
|
generatorDts: () => generatorDts,
|
|
71
|
-
|
|
17
|
+
buildLib: () => buildLib
|
|
72
18
|
});
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const runBuildTask = (options, api) =>
|
|
19
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
20
|
+
const _path = require("path");
|
|
21
|
+
const _logger = require("@modern-js/utils/logger");
|
|
22
|
+
const runBuildTask = async (options, api) => {
|
|
77
23
|
const { buildConfig, context, buildCmdOptions } = options;
|
|
78
24
|
const { appDirectory, isTsProject } = context;
|
|
79
|
-
const { copyTask } =
|
|
80
|
-
|
|
25
|
+
const { copyTask } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("./copy")));
|
|
26
|
+
await copyTask(buildConfig, {
|
|
27
|
+
appDirectory,
|
|
28
|
+
watch: buildCmdOptions.watch
|
|
29
|
+
});
|
|
81
30
|
if (isTsProject) {
|
|
82
|
-
|
|
31
|
+
await buildInTsProject(options, api);
|
|
83
32
|
} else {
|
|
84
|
-
|
|
33
|
+
await buildInJsProject(options, api);
|
|
85
34
|
}
|
|
86
|
-
}
|
|
87
|
-
const buildInTsProject = (options, api) =>
|
|
88
|
-
var _a;
|
|
35
|
+
};
|
|
36
|
+
const buildInTsProject = async (options, api) => {
|
|
89
37
|
const { buildConfig, buildCmdOptions } = options;
|
|
90
38
|
const dts = buildCmdOptions.dts ? buildConfig.dts : false;
|
|
91
39
|
const skipBuildLib = buildConfig.dts ? buildConfig.dts.only : false;
|
|
92
|
-
|
|
40
|
+
var _buildCmdOptions_watch;
|
|
41
|
+
const watch = (_buildCmdOptions_watch = buildCmdOptions.watch) !== null && _buildCmdOptions_watch !== void 0 ? _buildCmdOptions_watch : false;
|
|
93
42
|
if (dts === false) {
|
|
94
|
-
!skipBuildLib &&
|
|
43
|
+
!skipBuildLib && await buildLib(buildConfig, api, {
|
|
44
|
+
watch
|
|
45
|
+
});
|
|
95
46
|
} else {
|
|
96
|
-
const tasks = dts.only ? [
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
47
|
+
const tasks = dts.only ? [
|
|
48
|
+
generatorDts
|
|
49
|
+
] : [
|
|
50
|
+
buildLib,
|
|
51
|
+
generatorDts
|
|
52
|
+
];
|
|
53
|
+
const { default: pMap } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("../../compiled/p-map")));
|
|
54
|
+
await pMap(tasks, async (task) => {
|
|
55
|
+
await task(buildConfig, api, {
|
|
56
|
+
watch,
|
|
57
|
+
dts
|
|
58
|
+
});
|
|
59
|
+
});
|
|
101
60
|
}
|
|
102
|
-
}
|
|
103
|
-
const buildInJsProject = (options, api) =>
|
|
104
|
-
var _a;
|
|
61
|
+
};
|
|
62
|
+
const buildInJsProject = async (options, api) => {
|
|
105
63
|
const { buildConfig, buildCmdOptions } = options;
|
|
106
64
|
const dts = buildCmdOptions.dts ? buildConfig.dts : false;
|
|
107
|
-
|
|
65
|
+
var _buildCmdOptions_watch;
|
|
66
|
+
const watch = (_buildCmdOptions_watch = buildCmdOptions.watch) !== null && _buildCmdOptions_watch !== void 0 ? _buildCmdOptions_watch : false;
|
|
108
67
|
if (dts !== false && dts.only) {
|
|
109
68
|
return;
|
|
110
69
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
70
|
+
await buildLib(buildConfig, api, {
|
|
71
|
+
watch
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
const generatorDts = async (config, api, options) => {
|
|
75
|
+
const { runRollup, runTsc } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("./dts")));
|
|
115
76
|
const { watch, dts } = options;
|
|
116
77
|
const { buildType, input, sourceDir, alias } = config;
|
|
117
78
|
const { appDirectory } = api.useAppContext();
|
|
118
79
|
const { tsconfigPath, distPath, abortOnError } = dts;
|
|
119
80
|
if (buildType === "bundle") {
|
|
120
|
-
const { getFinalExternals } =
|
|
121
|
-
const finalExternals =
|
|
122
|
-
|
|
81
|
+
const { getFinalExternals } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("../utils/builder")));
|
|
82
|
+
const finalExternals = await getFinalExternals(config, {
|
|
83
|
+
appDirectory
|
|
84
|
+
});
|
|
85
|
+
await runRollup(api, {
|
|
123
86
|
distDir: distPath,
|
|
124
87
|
watch,
|
|
125
88
|
externals: finalExternals,
|
|
@@ -128,7 +91,7 @@ const generatorDts = (config, api, options) => __async(void 0, null, function* (
|
|
|
128
91
|
abortOnError
|
|
129
92
|
});
|
|
130
93
|
} else {
|
|
131
|
-
|
|
94
|
+
await runTsc(api, {
|
|
132
95
|
appDirectory,
|
|
133
96
|
alias,
|
|
134
97
|
distAbsPath: distPath,
|
|
@@ -138,70 +101,60 @@ const generatorDts = (config, api, options) => __async(void 0, null, function* (
|
|
|
138
101
|
abortOnError
|
|
139
102
|
});
|
|
140
103
|
}
|
|
141
|
-
}
|
|
142
|
-
const buildLib = (config, api, options) =>
|
|
143
|
-
var _a;
|
|
104
|
+
};
|
|
105
|
+
const buildLib = async (config, api, options) => {
|
|
144
106
|
const { watch } = options;
|
|
145
|
-
const {
|
|
146
|
-
target,
|
|
147
|
-
buildType,
|
|
148
|
-
sourceMap,
|
|
149
|
-
format,
|
|
150
|
-
outDir: distPath,
|
|
151
|
-
asset,
|
|
152
|
-
jsx,
|
|
153
|
-
input,
|
|
154
|
-
platform,
|
|
155
|
-
splitting,
|
|
156
|
-
minify,
|
|
157
|
-
sourceDir,
|
|
158
|
-
umdGlobals,
|
|
159
|
-
umdModuleName,
|
|
160
|
-
define,
|
|
161
|
-
alias,
|
|
162
|
-
style,
|
|
163
|
-
externals,
|
|
164
|
-
autoExternal,
|
|
165
|
-
dts,
|
|
166
|
-
metafile,
|
|
167
|
-
sideEffects,
|
|
168
|
-
redirect,
|
|
169
|
-
esbuildOptions
|
|
170
|
-
} = config;
|
|
107
|
+
const { target, buildType, sourceMap, format, outDir: distPath, asset, jsx, input, platform, splitting, minify, sourceDir, umdGlobals, umdModuleName, define, alias, style, externals, autoExternal, dts, metafile, sideEffects, redirect, esbuildOptions, externalHelpers, transformImport, sourceType, disableSwcTransform } = config;
|
|
171
108
|
const { appDirectory } = api.useAppContext();
|
|
172
|
-
const { slash } =
|
|
109
|
+
const { slash } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/utils")));
|
|
173
110
|
const root = slash(appDirectory);
|
|
174
111
|
const outdir = slash(distPath);
|
|
175
112
|
const assetOutDir = asset.path ? slash(asset.path) : asset.path;
|
|
176
113
|
const { less, sass, postcss, inject, modules, autoModules } = style;
|
|
177
|
-
const {
|
|
178
|
-
const
|
|
179
|
-
|
|
114
|
+
const { umdPlugin, swcTransformPlugin, es5Plugin } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/libuild-plugin-swc")));
|
|
115
|
+
const { checkSwcHelpers, matchEs5PluginCondition, matchSwcTransformCondition } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("../utils/builder")));
|
|
116
|
+
const { getProjectTsconfig } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("./dts/tsc")));
|
|
117
|
+
const tsconfigPath = dts ? dts.tsconfigPath : (0, _path.join)(appDirectory, "./tsconfig.json");
|
|
118
|
+
const userTsconfig = await getProjectTsconfig(tsconfigPath);
|
|
119
|
+
const plugins = [];
|
|
120
|
+
if (matchSwcTransformCondition({
|
|
121
|
+
sourceType,
|
|
122
|
+
buildType,
|
|
123
|
+
format,
|
|
124
|
+
disableSwcTransform
|
|
125
|
+
})) {
|
|
126
|
+
var _userTsconfig_compilerOptions;
|
|
127
|
+
plugins.push(swcTransformPlugin({
|
|
128
|
+
pluginImport: transformImport,
|
|
129
|
+
externalHelpers: Boolean(externalHelpers),
|
|
130
|
+
emitDecoratorMetadata: userTsconfig === null || userTsconfig === void 0 ? void 0 : (_userTsconfig_compilerOptions = userTsconfig.compilerOptions) === null || _userTsconfig_compilerOptions === void 0 ? void 0 : _userTsconfig_compilerOptions.emitDecoratorMetadata
|
|
131
|
+
}));
|
|
132
|
+
} else if (matchEs5PluginCondition({
|
|
133
|
+
sourceType,
|
|
134
|
+
buildType,
|
|
135
|
+
format,
|
|
136
|
+
target,
|
|
137
|
+
disableSwcTransform
|
|
138
|
+
})) {
|
|
180
139
|
plugins.push(es5Plugin());
|
|
181
140
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
const userTsconfig = yield getProjectTsconfig(tsconfigPath);
|
|
185
|
-
if ((_a = userTsconfig == null ? void 0 : userTsconfig.compilerOptions) == null ? void 0 : _a.emitDecoratorMetadata) {
|
|
186
|
-
plugins.push(
|
|
187
|
-
transformPlugin({
|
|
188
|
-
jsc: {
|
|
189
|
-
transform: {
|
|
190
|
-
legacyDecorator: true,
|
|
191
|
-
decoratorMetadata: true
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
})
|
|
195
|
-
);
|
|
141
|
+
if (format === "umd") {
|
|
142
|
+
plugins.push(umdPlugin(umdModuleName));
|
|
196
143
|
}
|
|
144
|
+
await checkSwcHelpers({
|
|
145
|
+
appDirectory,
|
|
146
|
+
externalHelpers
|
|
147
|
+
});
|
|
197
148
|
if (asset.svgr) {
|
|
198
|
-
const { svgrPlugin } =
|
|
149
|
+
const { svgrPlugin } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/libuild-plugin-svgr")));
|
|
199
150
|
const options2 = typeof asset.svgr === "boolean" ? {} : asset.svgr;
|
|
200
151
|
plugins.push(svgrPlugin(options2));
|
|
201
152
|
}
|
|
202
|
-
const { watchPlugin, externalPlugin } =
|
|
153
|
+
const { watchPlugin, externalPlugin } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("../utils/libuildPlugins")));
|
|
203
154
|
plugins.push(watchPlugin(api, config));
|
|
204
|
-
plugins.push(externalPlugin(config, {
|
|
155
|
+
plugins.push(externalPlugin(config, {
|
|
156
|
+
appDirectory
|
|
157
|
+
}));
|
|
205
158
|
const buildConfig = {
|
|
206
159
|
root,
|
|
207
160
|
watch,
|
|
@@ -221,9 +174,10 @@ const buildLib = (config, api, options) => __async(void 0, null, function* () {
|
|
|
221
174
|
resolve: {
|
|
222
175
|
alias
|
|
223
176
|
},
|
|
224
|
-
asset:
|
|
177
|
+
asset: {
|
|
178
|
+
...asset,
|
|
225
179
|
outdir: assetOutDir
|
|
226
|
-
}
|
|
180
|
+
},
|
|
227
181
|
plugins,
|
|
228
182
|
jsx,
|
|
229
183
|
input,
|
|
@@ -243,39 +197,29 @@ const buildLib = (config, api, options) => __async(void 0, null, function* () {
|
|
|
243
197
|
esbuildOptions
|
|
244
198
|
};
|
|
245
199
|
try {
|
|
246
|
-
const { Libuilder } =
|
|
247
|
-
const { addOutputChunk } =
|
|
200
|
+
const { Libuilder } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/libuild")));
|
|
201
|
+
const { addOutputChunk } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("../utils/print")));
|
|
248
202
|
const runner = api.useHookRunners();
|
|
249
|
-
const modifiedBuildConfig =
|
|
203
|
+
const modifiedBuildConfig = await runner.modifyLibuild(buildConfig, {
|
|
250
204
|
onLast: (c) => c
|
|
251
205
|
});
|
|
252
|
-
const builder =
|
|
253
|
-
|
|
206
|
+
const builder = await Libuilder.create(modifiedBuildConfig);
|
|
207
|
+
await builder.build();
|
|
254
208
|
addOutputChunk(builder.outputChunk, root, buildType === "bundle");
|
|
255
209
|
if (watch) {
|
|
256
|
-
const { watchSectionTitle } =
|
|
257
|
-
const { SectionTitleStatus } =
|
|
210
|
+
const { watchSectionTitle } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("../utils/log")));
|
|
211
|
+
const { SectionTitleStatus } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("../constants/log")));
|
|
258
212
|
const titleText = `[${buildType === "bundle" ? "Bundle" : "Bundleless"}: ${format}_${target}]`;
|
|
259
|
-
|
|
260
|
-
yield watchSectionTitle(titleText, SectionTitleStatus.Success)
|
|
261
|
-
);
|
|
213
|
+
_logger.logger.info(await watchSectionTitle(titleText, SectionTitleStatus.Success));
|
|
262
214
|
}
|
|
263
215
|
} catch (e) {
|
|
264
|
-
const { InternalBuildError } =
|
|
216
|
+
const { InternalBuildError } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("../error")));
|
|
265
217
|
throw new InternalBuildError(e, {
|
|
266
218
|
target,
|
|
267
219
|
format,
|
|
268
220
|
buildType
|
|
269
221
|
});
|
|
270
222
|
}
|
|
271
|
-
}
|
|
272
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
273
|
-
0 && (module.exports = {
|
|
274
|
-
buildInJsProject,
|
|
275
|
-
buildInTsProject,
|
|
276
|
-
buildLib,
|
|
277
|
-
generatorDts,
|
|
278
|
-
runBuildTask
|
|
279
|
-
});
|
|
223
|
+
};
|
|
280
224
|
|
|
281
225
|
//# sourceMappingURL=build.js.map
|
|
@@ -1 +1 @@
|
|
|
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,CAC9B,SAKA,QACG;AAxCL;AAyCE,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,KA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,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 redirect,\n esbuildOptions,\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 redirect,\n bundle: buildType === 'bundle',\n sideEffects,\n // outbase for [dir]/[name]\n outbase: sourceDir,\n esbuildOptions,\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"]}
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;EAYaA,cAAY,MAAZA;EAqBAC,kBAAgB,MAAhBA;EAyBAC,kBAAgB,MAAhBA;EAmBAC,cAAY,MAAZA;EAsCAC,UAAQ,MAARA;;;sBAnHQ;wBACE;AAWhB,MAAMJ,eAAe,OAC1BK,SAKAC,QACG;AACH,QAAM,EAAEC,aAAaC,SAASC,gBAAe,IAAKJ;AAClD,QAAM,EAAEK,cAAcC,YAAW,IAAKH;AAEtC,QAAM,EAAEI,SAAQ,IAAK,MAAM,iFAAO;AAClC,QAAMA,SAASL,aAAa;IAAEG;IAAcG,OAAOJ,gBAAgBI;EAAM;AAEzE,MAAIF,aAAa;AACf,UAAMV,iBAAiBI,SAASC;EAClC,OAAO;AACL,UAAMJ,iBAAiBG,SAASC;EAClC;AACF;AAEO,MAAML,mBAAmB,OAC9BI,SAKAC,QACG;AACH,QAAM,EAAEC,aAAaE,gBAAe,IAAKJ;AACzC,QAAMS,MAAML,gBAAgBK,MAAMP,YAAYO,MAAM;AACpD,QAAMC,eAAeR,YAAYO,MAAMP,YAAYO,IAAIE,OAAO;MAChDP;AAAd,QAAMI,SAAQJ,yCAAgBI,WAAK,QAArBJ,6DAAyB;AAEvC,MAAIK,QAAQ,OAAO;AAEjB,KAACC,gBAAiB,MAAMX,SAASG,aAAaD,KAAK;MAAEO;IAAM;EAC7D,OAAO;AACL,UAAMI,QAAQH,IAAIE,OAAO;MAACb;QAAgB;MAACC;MAAUD;;AACrD,UAAM,EAAEe,SAASC,K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AIA,mBAAmBD,GAAG;MAC9B3E;MACAE;MACAf;IACF;EACF;AACF;","names":["runBuildTask","buildInTsProject","buildInJsProject","generatorDts","buildLib","options","api","buildConfig","context","buildCmdOptions","appDirectory","isTsProject","copyTask","watch","dts","skipBuildLib","only","tasks","default","pMap","task","config","runRollup","runTsc","buildType","input","sourceDir","alias","useAppContext","tsconfigPath","distPath","abortOnError","getFinalExternals","finalExternals","distDir","externals","distAbsPath","target","sourceMap","format","outDir","asset","jsx","platform","splitting","minify","umdGlobals","umdModuleName","define","style","autoExternal","metafile","sideEffects","redirect","esbuildOptions","externalHelpers","transformImport","sourceType","disableSwcTransform","slash","root","outdir","assetOutDir","path","less","sass","postcss","inject","modules","autoModules","umdPlugin","swcTransformPlugin","es5Plugin","checkSwcHelpers","matchEs5PluginCondition","matchSwcTransformCondition","getProjectTsconfig","join","userTsconfig","plugins","push","pluginImport","Boolean","emitDecoratorMetadata","compilerOptions","svgr","svgrPlugin","watchPlugin","externalPlugin","resolve","globals","external","bundle","outbase","Libuilder","addOutputChunk","runner","useHookRunners","modifiedBuildConfig","modifyLibuild","onLast","c","builder","create","build","outputChunk","watchSectionTitle","SectionTitleStatus","titleText","logger","info","Success","e","InternalBuildError"],"sources":["../../src/builder/home/runner/work/modern.js/modern.js/packages/solutions/module-tools/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 redirect,\n esbuildOptions,\n externalHelpers,\n transformImport,\n sourceType,\n disableSwcTransform,\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 swc-transform, umd and emitDecoratorMetadata by swc\n const { umdPlugin, swcTransformPlugin, es5Plugin } = await import(\n '@modern-js/libuild-plugin-swc'\n );\n const {\n checkSwcHelpers,\n matchEs5PluginCondition,\n matchSwcTransformCondition,\n } = await import('../utils/builder');\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\n const plugins = [];\n\n if (\n matchSwcTransformCondition({\n sourceType,\n buildType,\n format,\n disableSwcTransform,\n })\n ) {\n plugins.push(\n swcTransformPlugin({\n pluginImport: transformImport,\n externalHelpers: Boolean(externalHelpers),\n emitDecoratorMetadata:\n userTsconfig?.compilerOptions?.emitDecoratorMetadata,\n }),\n );\n } else if (\n matchEs5PluginCondition({\n sourceType,\n buildType,\n format,\n target,\n disableSwcTransform,\n })\n ) {\n plugins.push(es5Plugin());\n }\n\n if (format === 'umd') {\n plugins.push(umdPlugin(umdModuleName));\n }\n\n await checkSwcHelpers({ appDirectory, externalHelpers });\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 redirect,\n bundle: buildType === 'bundle',\n sideEffects,\n // outbase for [dir]/[name]\n outbase: sourceDir,\n esbuildOptions,\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
|
@@ -1,74 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var __async = (__this, __arguments, generator) => {
|
|
29
|
-
return new Promise((resolve, reject) => {
|
|
30
|
-
var fulfilled = (value) => {
|
|
31
|
-
try {
|
|
32
|
-
step(generator.next(value));
|
|
33
|
-
} catch (e) {
|
|
34
|
-
reject(e);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
var rejected = (value) => {
|
|
38
|
-
try {
|
|
39
|
-
step(generator.throw(value));
|
|
40
|
-
} catch (e) {
|
|
41
|
-
reject(e);
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
45
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
46
|
-
});
|
|
47
|
-
};
|
|
48
|
-
var clear_exports = {};
|
|
49
|
-
__export(clear_exports, {
|
|
50
|
-
clearBuildConfigPaths: () => clearBuildConfigPaths,
|
|
51
|
-
clearDtsTemp: () => clearDtsTemp
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
52
4
|
});
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
Object.defineProperty(target, name, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: all[name]
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
_export(exports, {
|
|
13
|
+
clearDtsTemp: () => clearDtsTemp,
|
|
14
|
+
clearBuildConfigPaths: () => clearBuildConfigPaths
|
|
58
15
|
});
|
|
59
|
-
const
|
|
60
|
-
|
|
16
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
17
|
+
const clearDtsTemp = async () => {
|
|
18
|
+
const { fs } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/utils")));
|
|
19
|
+
const { dtsTempDirectory } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("../constants/dts")));
|
|
20
|
+
await fs.remove(dtsTempDirectory);
|
|
21
|
+
};
|
|
22
|
+
const clearBuildConfigPaths = async (configs, noClear) => {
|
|
23
|
+
const { fs } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/utils")));
|
|
61
24
|
if (noClear) {
|
|
62
25
|
return;
|
|
63
26
|
}
|
|
64
27
|
for (const config of configs) {
|
|
65
|
-
|
|
28
|
+
await fs.remove(config.outDir);
|
|
66
29
|
}
|
|
67
|
-
}
|
|
68
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
69
|
-
0 && (module.exports = {
|
|
70
|
-
clearBuildConfigPaths,
|
|
71
|
-
clearDtsTemp
|
|
72
|
-
});
|
|
30
|
+
};
|
|
73
31
|
|
|
74
32
|
//# sourceMappingURL=clear.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":"
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;EAEaA,cAAY,MAAZA;EAMAC,uBAAqB,MAArBA;;;AANN,MAAMD,eAAe,YAAY;AACtC,QAAM,EAAEE,GAAE,IAAK,MAAM,iFAAO;AAC5B,QAAM,EAAEC,iBAAgB,IAAK,MAAM,iFAAO;AAC1C,QAAMD,GAAGE,OAAOD;AAClB;AAEO,MAAMF,wBAAwB,OACnCI,SACAC,YACG;AACH,QAAM,EAAEJ,GAAE,IAAK,MAAM,iFAAO;AAE5B,MAAII,SAAS;AACX;EACF;AAEA,aAAWC,UAAUF,SAAS;AAC5B,UAAMH,GAAGE,OAAOG,OAAOC,MAAM;EAC/B;AACF;","names":["clearDtsTemp","clearBuildConfigPaths","fs","dtsTempDirectory","remove","configs","noClear","config","outDir"],"sources":["../../src/builder/home/runner/work/modern.js/modern.js/packages/solutions/module-tools/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 (\n configs: BaseBuildConfig[],\n noClear: boolean,\n) => {\n const { fs } = await import('@modern-js/utils');\n\n if (noClear) {\n return;\n }\n\n for (const config of configs) {\n await fs.remove(config.outDir);\n }\n};\n"]}
|