@modern-js/module-tools 2.35.0 → 2.36.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/compiled/postcss-nesting/index.js +2 -2
- package/compiled/postcss-nesting/package.json +1 -1
- package/dist/build.js +43 -16
- package/dist/builder/build.d.ts +1 -10
- package/dist/builder/build.js +96 -208
- package/dist/builder/clear.d.ts +1 -4
- package/dist/builder/clear.js +32 -28
- package/dist/builder/copy.js +79 -64
- package/dist/builder/dts/index.js +27 -19
- package/dist/builder/dts/rollup.d.ts +6 -14
- package/dist/builder/dts/rollup.js +60 -37
- package/dist/builder/dts/tsc.d.ts +3 -2
- package/dist/builder/dts/tsc.js +50 -37
- package/dist/builder/esbuild/adapter.d.ts +3 -0
- package/dist/builder/esbuild/adapter.js +275 -0
- package/dist/builder/esbuild/hook.d.ts +4 -0
- package/dist/builder/esbuild/hook.js +103 -0
- package/dist/builder/esbuild/index.d.ts +35 -0
- package/dist/builder/esbuild/index.js +268 -0
- package/dist/builder/esbuild/resolve.d.ts +17 -0
- package/dist/builder/esbuild/resolve.js +125 -0
- package/dist/builder/esbuild/sourcemap.d.ts +16 -0
- package/dist/builder/esbuild/sourcemap.js +86 -0
- package/dist/builder/esbuild/transform.d.ts +7 -0
- package/dist/builder/esbuild/transform.js +45 -0
- package/dist/builder/esbuild/watch.d.ts +2 -0
- package/dist/builder/esbuild/watch.js +115 -0
- package/dist/builder/esbuild/write-file.d.ts +2 -0
- package/dist/builder/esbuild/write-file.js +89 -0
- package/dist/builder/feature/asset.d.ts +19 -0
- package/dist/builder/feature/asset.js +149 -0
- package/dist/builder/feature/format-cjs.d.ts +5 -0
- package/dist/builder/feature/format-cjs.js +53 -0
- package/dist/builder/feature/index.d.ts +2 -0
- package/dist/builder/feature/index.js +74 -0
- package/dist/builder/feature/json.d.ts +5 -0
- package/dist/builder/feature/json.js +47 -0
- package/dist/builder/feature/redirect.d.ts +5 -0
- package/dist/builder/feature/redirect.js +217 -0
- package/dist/builder/feature/style/index.d.ts +5 -0
- package/dist/builder/feature/style/index.js +94 -0
- package/dist/builder/feature/style/lessAliasPlugin.d.ts +12 -0
- package/dist/builder/feature/style/lessAliasPlugin.js +70 -0
- package/dist/builder/feature/style/lessRender.d.ts +2 -0
- package/dist/builder/feature/style/lessRender.js +64 -0
- package/dist/builder/feature/style/postcssTransformer.d.ts +6 -0
- package/dist/builder/feature/style/postcssTransformer.js +95 -0
- package/dist/builder/feature/style/postcssUrlPlugin.d.ts +6 -0
- package/dist/builder/feature/style/postcssUrlPlugin.js +58 -0
- package/dist/builder/feature/style/sassRender.d.ts +2 -0
- package/dist/builder/feature/style/sassRender.js +85 -0
- package/dist/builder/feature/style/transformStyle.d.ts +13 -0
- package/dist/builder/feature/style/transformStyle.js +101 -0
- package/dist/builder/feature/style/utils.d.ts +18 -0
- package/dist/builder/feature/style/utils.js +124 -0
- package/dist/builder/feature/swc.d.ts +9 -0
- package/dist/builder/feature/swc.js +170 -0
- package/dist/builder/feature/terser.d.ts +5 -0
- package/dist/builder/feature/terser.js +83 -0
- package/dist/builder/index.d.ts +1 -0
- package/dist/builder/index.js +59 -28
- package/dist/builder/platform.js +38 -23
- package/dist/cli.js +58 -29
- package/dist/command.js +62 -38
- package/dist/config/defineConfig.js +25 -17
- package/dist/config/legacySchema.js +35 -32
- package/dist/config/merge.d.ts +1 -0
- package/dist/config/merge.js +69 -36
- package/dist/config/normalize.d.ts +1 -0
- package/dist/config/normalize.js +63 -46
- package/dist/config/schema.d.ts +48 -0
- package/dist/config/schema.js +53 -34
- package/dist/config/transformLegacyConfig.js +67 -61
- package/dist/config/valid.d.ts +2 -2
- package/dist/config/valid.js +44 -21
- package/dist/constants/build.d.ts +5 -1
- package/dist/constants/build.js +88 -46
- package/dist/constants/color.js +27 -20
- package/dist/constants/dts.js +27 -20
- package/dist/constants/file.d.ts +2 -2
- package/dist/constants/file.js +48 -25
- package/dist/constants/legacy-preset.js +45 -32
- package/dist/constants/loader.d.ts +2 -0
- package/dist/constants/loader.js +53 -0
- package/dist/constants/log.d.ts +0 -8
- package/dist/constants/log.js +27 -41
- package/dist/constants/preset.js +55 -62
- package/dist/debug.d.ts +4 -0
- package/dist/debug.js +37 -0
- package/dist/dev.js +42 -25
- package/dist/error.js +49 -42
- package/dist/hooks/build.d.ts +1 -2
- package/dist/hooks/build.js +36 -28
- package/dist/hooks/dev.js +32 -17
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/index.js +31 -16
- package/dist/hooks/misc.d.ts +5 -2
- package/dist/hooks/misc.js +31 -12
- package/dist/index.d.ts +2 -1
- package/dist/index.js +39 -32
- package/dist/locale/en.js +32 -17
- package/dist/locale/index.d.ts +2 -1
- package/dist/locale/index.js +31 -24
- package/dist/locale/zh.js +32 -17
- package/dist/plugins.js +28 -13
- package/dist/types/color.js +15 -5
- package/dist/types/command.d.ts +3 -3
- package/dist/types/command.js +15 -5
- package/dist/types/config/copy.js +15 -5
- package/dist/types/config/dev.js +15 -5
- package/dist/types/config/index.d.ts +87 -52
- package/dist/types/config/index.js +24 -6
- package/dist/types/config/style.d.ts +58 -6
- package/dist/types/config/style.js +15 -5
- package/dist/types/context.js +15 -5
- package/dist/types/dts.d.ts +14 -3
- package/dist/types/dts.js +15 -5
- package/dist/types/esbuild.d.ts +107 -0
- package/dist/types/esbuild.js +32 -0
- package/dist/types/hooks.js +15 -5
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +32 -11
- package/dist/types/legacyConfig/index.js +15 -5
- package/dist/types/legacyConfig/output.d.ts +4 -4
- package/dist/types/legacyConfig/output.js +15 -5
- package/dist/types/legacyConfig/source.js +15 -5
- package/dist/types/legacyConfig/tools.js +15 -5
- package/dist/utils/assert.d.ts +5 -0
- package/dist/utils/assert.js +50 -0
- package/dist/utils/builder.d.ts +10 -14
- package/dist/utils/builder.js +59 -59
- package/dist/utils/common.d.ts +1 -1
- package/dist/utils/common.js +25 -17
- package/dist/utils/dts.d.ts +26 -9
- package/dist/utils/dts.js +100 -66
- package/dist/utils/hash.d.ts +2 -0
- package/dist/utils/hash.js +31 -0
- package/dist/utils/index.d.ts +11 -0
- package/dist/utils/index.js +42 -0
- package/dist/utils/input.js +47 -24
- package/dist/utils/log.d.ts +1 -2
- package/dist/utils/log.js +36 -20
- package/dist/utils/map.d.ts +13 -0
- package/dist/utils/map.js +58 -0
- package/dist/utils/onExit.js +35 -11
- package/dist/utils/print.d.ts +2 -2
- package/dist/utils/print.js +52 -49
- package/dist/utils/style.d.ts +5 -23
- package/dist/utils/style.js +63 -43
- package/dist/utils/tspath.js +114 -0
- package/package.json +64 -50
- package/vitest.config.ts +20 -0
- package/dist/build.js.map +0 -1
- package/dist/builder/build.js.map +0 -1
- package/dist/builder/clear.js.map +0 -1
- package/dist/builder/copy.js.map +0 -1
- package/dist/builder/dts/index.js.map +0 -1
- package/dist/builder/dts/rollup.js.map +0 -1
- package/dist/builder/dts/tsc.js.map +0 -1
- package/dist/builder/index.js.map +0 -1
- package/dist/builder/platform.js.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/command.js.map +0 -1
- package/dist/config/defineConfig.js.map +0 -1
- package/dist/config/legacySchema.js.map +0 -1
- package/dist/config/merge.js.map +0 -1
- package/dist/config/normalize.js.map +0 -1
- package/dist/config/schema.js.map +0 -1
- package/dist/config/transformLegacyConfig.js.map +0 -1
- package/dist/config/valid.js.map +0 -1
- package/dist/constants/build.js.map +0 -1
- package/dist/constants/color.js.map +0 -1
- package/dist/constants/dts.js.map +0 -1
- package/dist/constants/file.js.map +0 -1
- package/dist/constants/legacy-preset.js.map +0 -1
- package/dist/constants/log.js.map +0 -1
- package/dist/constants/preset.js.map +0 -1
- package/dist/dev.js.map +0 -1
- package/dist/error.js.map +0 -1
- package/dist/hooks/build.js.map +0 -1
- package/dist/hooks/dev.js.map +0 -1
- package/dist/hooks/index.js.map +0 -1
- package/dist/hooks/misc.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/locale/en.js.map +0 -1
- package/dist/locale/index.js.map +0 -1
- package/dist/locale/zh.js.map +0 -1
- package/dist/plugins.js.map +0 -1
- package/dist/types/color.js.map +0 -1
- package/dist/types/command.js.map +0 -1
- package/dist/types/config/copy.js.map +0 -1
- package/dist/types/config/dev.js.map +0 -1
- package/dist/types/config/index.js.map +0 -1
- package/dist/types/config/style.js.map +0 -1
- package/dist/types/context.js.map +0 -1
- package/dist/types/dts.js.map +0 -1
- package/dist/types/hooks.js.map +0 -1
- package/dist/types/index.js.map +0 -1
- package/dist/types/legacyConfig/index.js.map +0 -1
- package/dist/types/legacyConfig/output.js.map +0 -1
- package/dist/types/legacyConfig/source.js.map +0 -1
- package/dist/types/legacyConfig/tools.js.map +0 -1
- package/dist/types/utils.d.ts +0 -5
- package/dist/types/utils.js +0 -4
- package/dist/utils/builder.js.map +0 -1
- package/dist/utils/common.js.map +0 -1
- package/dist/utils/context.d.ts +0 -7
- package/dist/utils/context.js +0 -23
- package/dist/utils/context.js.map +0 -1
- package/dist/utils/dts.js.map +0 -1
- package/dist/utils/input.js.map +0 -1
- package/dist/utils/language.d.ts +0 -1
- package/dist/utils/language.js +0 -22
- package/dist/utils/language.js.map +0 -1
- package/dist/utils/libuild-plugin.d.ts +0 -3
- package/dist/utils/libuild-plugin.js +0 -31
- package/dist/utils/libuild-plugin.js.map +0 -1
- package/dist/utils/log.js.map +0 -1
- package/dist/utils/onExit.js.map +0 -1
- package/dist/utils/path.d.ts +0 -1
- package/dist/utils/path.js +0 -19
- package/dist/utils/path.js.map +0 -1
- package/dist/utils/print.js.map +0 -1
- package/dist/utils/style.js.map +0 -1
- package/dist/utils/tspathsTransform.js +0 -91
- package/dist/utils/tspathsTransform.js.map +0 -1
- /package/dist/utils/{tspathsTransform.d.ts → tspath.d.ts} +0 -0
package/dist/builder/copy.js
CHANGED
|
@@ -1,54 +1,66 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
6
9
|
for (var name in all)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return runPatterns;
|
|
15
|
-
},
|
|
16
|
-
watchCopyFiles: function() {
|
|
17
|
-
return watchCopyFiles;
|
|
18
|
-
},
|
|
19
|
-
copyTask: function() {
|
|
20
|
-
return copyTask;
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
21
17
|
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var copy_exports = {};
|
|
30
|
+
__export(copy_exports, {
|
|
31
|
+
copyTask: () => copyTask,
|
|
32
|
+
runPatterns: () => runPatterns,
|
|
33
|
+
watchCopyFiles: () => watchCopyFiles
|
|
22
34
|
});
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
35
|
+
module.exports = __toCommonJS(copy_exports);
|
|
36
|
+
var import_path = __toESM(require("path"));
|
|
37
|
+
var import_utils = require("@modern-js/utils");
|
|
38
|
+
var import_p_map = __toESM(require("../../compiled/p-map"));
|
|
39
|
+
var import_debug = require("../debug");
|
|
28
40
|
const watchMap = /* @__PURE__ */ new Map();
|
|
29
41
|
const runPatterns = async (pattern, options) => {
|
|
30
|
-
const { default: normalizePath } = await Promise.resolve().then(() =>
|
|
42
|
+
const { default: normalizePath } = await Promise.resolve().then(() => __toESM(require("../../compiled/normalize-path")));
|
|
31
43
|
const { appDirectory, enableCopySync = false } = options;
|
|
32
44
|
const { from, globOptions = {} } = pattern;
|
|
33
45
|
const targetPattern = {
|
|
34
46
|
...pattern
|
|
35
47
|
};
|
|
36
|
-
const normalizedFrom =
|
|
48
|
+
const normalizedFrom = import_path.default.normalize(from);
|
|
37
49
|
const defaultAbsContext = options.defaultContext;
|
|
38
50
|
if (typeof pattern.context === "string") {
|
|
39
|
-
targetPattern.context =
|
|
51
|
+
targetPattern.context = import_path.default.isAbsolute(pattern.context) ? pattern.context : import_path.default.join(appDirectory, pattern.context);
|
|
40
52
|
} else {
|
|
41
53
|
targetPattern.context = defaultAbsContext;
|
|
42
54
|
}
|
|
43
55
|
let absoluteFrom;
|
|
44
|
-
if (
|
|
56
|
+
if (import_path.default.isAbsolute(normalizedFrom)) {
|
|
45
57
|
absoluteFrom = normalizedFrom;
|
|
46
58
|
} else {
|
|
47
|
-
absoluteFrom =
|
|
59
|
+
absoluteFrom = import_path.default.resolve(targetPattern.context, normalizedFrom);
|
|
48
60
|
}
|
|
49
61
|
let stats;
|
|
50
62
|
try {
|
|
51
|
-
stats = await
|
|
63
|
+
stats = await import_utils.fs.stat(absoluteFrom);
|
|
52
64
|
} catch (error) {
|
|
53
65
|
}
|
|
54
66
|
let fromType;
|
|
@@ -67,15 +79,15 @@ const runPatterns = async (pattern, options) => {
|
|
|
67
79
|
switch (fromType) {
|
|
68
80
|
case "dir":
|
|
69
81
|
targetPattern.context = absoluteFrom;
|
|
70
|
-
glob =
|
|
71
|
-
absoluteFrom =
|
|
82
|
+
glob = import_path.default.posix.join(import_utils.fastGlob.escapePath(normalizePath(import_path.default.resolve(absoluteFrom))), "**/*");
|
|
83
|
+
absoluteFrom = import_path.default.join(absoluteFrom, "**/*");
|
|
72
84
|
if (typeof globOptions.dot === "undefined") {
|
|
73
85
|
globOptions.dot = true;
|
|
74
86
|
}
|
|
75
87
|
break;
|
|
76
88
|
case "file":
|
|
77
|
-
targetPattern.context =
|
|
78
|
-
glob =
|
|
89
|
+
targetPattern.context = import_path.default.dirname(absoluteFrom);
|
|
90
|
+
glob = import_utils.fastGlob.escapePath(normalizePath(import_path.default.resolve(absoluteFrom)));
|
|
79
91
|
if (typeof globOptions.dot === "undefined") {
|
|
80
92
|
globOptions.dot = true;
|
|
81
93
|
}
|
|
@@ -83,10 +95,10 @@ const runPatterns = async (pattern, options) => {
|
|
|
83
95
|
case "glob":
|
|
84
96
|
default: {
|
|
85
97
|
var _targetPattern_context;
|
|
86
|
-
glob =
|
|
98
|
+
glob = import_path.default.isAbsolute(from) ? from : import_path.default.posix.join(import_utils.fastGlob.escapePath(normalizePath(import_path.default.resolve((_targetPattern_context = targetPattern.context) !== null && _targetPattern_context !== void 0 ? _targetPattern_context : appDirectory))), from);
|
|
87
99
|
}
|
|
88
100
|
}
|
|
89
|
-
const globEntries = await (0,
|
|
101
|
+
const globEntries = await (0, import_utils.globby)(glob, {
|
|
90
102
|
...{
|
|
91
103
|
followSymbolicLinks: true
|
|
92
104
|
},
|
|
@@ -94,64 +106,62 @@ const runPatterns = async (pattern, options) => {
|
|
|
94
106
|
cwd: targetPattern.context,
|
|
95
107
|
objectMode: true
|
|
96
108
|
});
|
|
97
|
-
(0,
|
|
109
|
+
(0, import_p_map.default)(globEntries, async (globEntry) => {
|
|
98
110
|
if (!globEntry.dirent.isFile()) {
|
|
99
111
|
return;
|
|
100
112
|
}
|
|
101
113
|
const from2 = globEntry.path;
|
|
102
|
-
const absoluteFrom2 =
|
|
103
|
-
const to =
|
|
104
|
-
const toType =
|
|
114
|
+
const absoluteFrom2 = import_path.default.resolve(targetPattern.context, from2);
|
|
115
|
+
const to = import_path.default.normalize(typeof targetPattern.to !== "undefined" ? targetPattern.to : "");
|
|
116
|
+
const toType = import_path.default.extname(to) === "" || to.slice(-1) === import_path.default.sep ? "dir" : "file";
|
|
105
117
|
var _targetPattern_context2;
|
|
106
|
-
const relativeFrom =
|
|
107
|
-
const filename = toType === "dir" ?
|
|
108
|
-
const absoluteTo =
|
|
118
|
+
const relativeFrom = import_path.default.relative((_targetPattern_context2 = targetPattern.context) !== null && _targetPattern_context2 !== void 0 ? _targetPattern_context2 : defaultAbsContext, absoluteFrom2);
|
|
119
|
+
const filename = toType === "dir" ? import_path.default.join(to, relativeFrom) : to;
|
|
120
|
+
const absoluteTo = import_path.default.isAbsolute(filename) ? filename : import_path.default.join(options.outDir, filename);
|
|
109
121
|
if (options.watch) {
|
|
110
122
|
watchMap.set(absoluteFrom2, absoluteTo);
|
|
111
123
|
}
|
|
112
124
|
if (enableCopySync) {
|
|
113
|
-
|
|
125
|
+
import_utils.fs.copySync(absoluteFrom2, absoluteTo);
|
|
114
126
|
} else {
|
|
115
|
-
await
|
|
127
|
+
await import_utils.fs.copy(absoluteFrom2, absoluteTo);
|
|
116
128
|
}
|
|
117
129
|
});
|
|
118
130
|
};
|
|
119
131
|
const watchCopyFiles = async (options, copyConfig) => {
|
|
120
|
-
|
|
121
|
-
debug("watchMap", watchMap);
|
|
122
|
-
const { SectionTitleStatus, CopyLogPrefix } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("../constants/log")));
|
|
123
|
-
const { watchSectionTitle } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("../utils/log")));
|
|
132
|
+
(0, import_debug.debug)("watchMap", watchMap);
|
|
124
133
|
const watchList = Array.from(watchMap.keys());
|
|
125
|
-
debug("watchList", watchList);
|
|
126
|
-
(0,
|
|
127
|
-
var _copyConfig_options
|
|
134
|
+
(0, import_debug.debug)("watchList", watchList);
|
|
135
|
+
(0, import_utils.watch)(watchList, async ({ changedFilePath, changeType }) => {
|
|
136
|
+
var _copyConfig_options;
|
|
128
137
|
const result = watchMap.get(changedFilePath);
|
|
129
138
|
if (!result) {
|
|
130
139
|
return;
|
|
131
140
|
}
|
|
132
|
-
const formatFilePath =
|
|
141
|
+
const formatFilePath = import_path.default.relative(options.appDirectory, changedFilePath);
|
|
133
142
|
if (changeType === "unlink") {
|
|
134
|
-
|
|
135
|
-
|
|
143
|
+
import_utils.fs.remove(result);
|
|
144
|
+
import_utils.logger.info(`Copied file removed: ${import_utils.chalk.dim(formatFilePath)}`);
|
|
136
145
|
return;
|
|
137
146
|
}
|
|
138
|
-
if (
|
|
139
|
-
|
|
147
|
+
if (copyConfig === null || copyConfig === void 0 ? void 0 : (_copyConfig_options = copyConfig.options) === null || _copyConfig_options === void 0 ? void 0 : _copyConfig_options.enableCopySync) {
|
|
148
|
+
import_utils.fs.copySync(changedFilePath, result);
|
|
140
149
|
} else {
|
|
141
|
-
await
|
|
150
|
+
await import_utils.fs.copy(changedFilePath, result);
|
|
142
151
|
}
|
|
143
|
-
|
|
152
|
+
import_utils.logger.info(`Copy file: ${import_utils.chalk.dim(formatFilePath)}`);
|
|
144
153
|
});
|
|
145
154
|
};
|
|
146
155
|
const copyTask = async (buildConfig, options) => {
|
|
147
|
-
var _copyConfig_options
|
|
156
|
+
var _copyConfig_options;
|
|
148
157
|
const copyConfig = buildConfig.copy;
|
|
149
158
|
if (!copyConfig.patterns || copyConfig.patterns.length === 0) {
|
|
150
159
|
return;
|
|
151
160
|
}
|
|
152
|
-
|
|
161
|
+
(0, import_debug.debug)("run copy task");
|
|
162
|
+
const concurrency = (copyConfig === null || copyConfig === void 0 ? void 0 : (_copyConfig_options = copyConfig.options) === null || _copyConfig_options === void 0 ? void 0 : _copyConfig_options.concurrency) || 100;
|
|
153
163
|
try {
|
|
154
|
-
await (0,
|
|
164
|
+
await (0, import_p_map.default)(copyConfig.patterns, async (copyOption) => {
|
|
155
165
|
var _copyConfig_options2;
|
|
156
166
|
await runPatterns(copyOption, {
|
|
157
167
|
...options,
|
|
@@ -164,12 +174,17 @@ const copyTask = async (buildConfig, options) => {
|
|
|
164
174
|
});
|
|
165
175
|
} catch (e) {
|
|
166
176
|
if (e instanceof Error) {
|
|
167
|
-
|
|
177
|
+
import_utils.logger.error(`copy error: ${e.message}`);
|
|
168
178
|
}
|
|
169
179
|
}
|
|
180
|
+
(0, import_debug.debug)("run copy task done");
|
|
170
181
|
if (options.watch) {
|
|
171
182
|
await watchCopyFiles(options, copyConfig);
|
|
172
183
|
}
|
|
173
184
|
};
|
|
174
|
-
|
|
175
|
-
|
|
185
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
186
|
+
0 && (module.exports = {
|
|
187
|
+
copyTask,
|
|
188
|
+
runPatterns,
|
|
189
|
+
watchCopyFiles
|
|
190
|
+
});
|
|
@@ -1,23 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
6
7
|
for (var name in all)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return _rollup.runRollup;
|
|
15
|
-
},
|
|
16
|
-
runTsc: function() {
|
|
17
|
-
return _tsc.runTsc;
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
15
|
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var dts_exports = {};
|
|
20
|
+
__export(dts_exports, {
|
|
21
|
+
runRollup: () => import_rollup.runRollup,
|
|
22
|
+
runTsc: () => import_tsc.runTsc
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(dts_exports);
|
|
25
|
+
var import_rollup = require("./rollup");
|
|
26
|
+
var import_tsc = require("./tsc");
|
|
27
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
+
0 && (module.exports = {
|
|
29
|
+
runRollup,
|
|
30
|
+
runTsc
|
|
19
31
|
});
|
|
20
|
-
const _rollup = require("./rollup");
|
|
21
|
-
const _tsc = require("./tsc");
|
|
22
|
-
|
|
23
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,23 +1,15 @@
|
|
|
1
1
|
import type { RollupWatcher } from '../../../compiled/rollup';
|
|
2
|
-
import type {
|
|
2
|
+
import type { GeneratorDtsConfig, PluginAPI, ModuleTools } from '../../types';
|
|
3
3
|
export type { RollupWatcher };
|
|
4
|
-
type Config = {
|
|
5
|
-
distDir: string;
|
|
6
|
-
tsconfigPath: string;
|
|
7
|
-
externals: BaseBuildConfig['externals'];
|
|
8
|
-
input: Input;
|
|
9
|
-
watch: boolean;
|
|
10
|
-
abortOnError: boolean;
|
|
11
|
-
respectExternal: boolean;
|
|
12
|
-
appDirectory: string;
|
|
13
|
-
};
|
|
14
4
|
export declare const runRollup: (api: PluginAPI<ModuleTools>, {
|
|
15
|
-
|
|
5
|
+
distPath,
|
|
16
6
|
tsconfigPath,
|
|
17
7
|
externals,
|
|
18
8
|
input,
|
|
19
9
|
watch,
|
|
20
10
|
abortOnError,
|
|
21
11
|
respectExternal,
|
|
22
|
-
appDirectory
|
|
23
|
-
|
|
12
|
+
appDirectory,
|
|
13
|
+
footer,
|
|
14
|
+
banner
|
|
15
|
+
}: GeneratorDtsConfig) => Promise<RollupWatcher | import("../../../compiled/rollup").RollupBuild | null>;
|
|
@@ -1,22 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
9
17
|
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var rollup_exports = {};
|
|
30
|
+
__export(rollup_exports, {
|
|
31
|
+
runRollup: () => runRollup
|
|
10
32
|
});
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
const runRollup = async (api, { distDir, tsconfigPath, externals, input, watch, abortOnError, respectExternal, appDirectory }) => {
|
|
33
|
+
module.exports = __toCommonJS(rollup_exports);
|
|
34
|
+
var import_path = __toESM(require("path"));
|
|
35
|
+
var import_utils = require("@modern-js/utils");
|
|
36
|
+
var import_typescript = __toESM(require("typescript"));
|
|
37
|
+
var import_plugin_json = __toESM(require("../../../compiled/@rollup/plugin-json"));
|
|
38
|
+
var import_rollup_plugin_dts = __toESM(require("../../../compiled/rollup-plugin-dts"));
|
|
39
|
+
var import_utils2 = require("../../utils");
|
|
40
|
+
const runRollup = async (api, { distPath, tsconfigPath, externals, input, watch, abortOnError, respectExternal, appDirectory, footer, banner }) => {
|
|
20
41
|
const ignoreFiles = {
|
|
21
42
|
name: "ignore-files",
|
|
22
43
|
load(id) {
|
|
@@ -26,24 +47,24 @@ const runRollup = async (api, { distDir, tsconfigPath, externals, input, watch,
|
|
|
26
47
|
return null;
|
|
27
48
|
}
|
|
28
49
|
};
|
|
29
|
-
const configFile =
|
|
30
|
-
const { options } =
|
|
31
|
-
const baseUrl =
|
|
50
|
+
const configFile = import_typescript.default.readConfigFile(tsconfigPath, import_typescript.default.sys.readFile);
|
|
51
|
+
const { options } = import_typescript.default.parseJsonConfigFileContent(configFile.config, import_typescript.default.sys, "./");
|
|
52
|
+
const baseUrl = import_path.default.isAbsolute(options.baseUrl || ".") ? options.baseUrl : import_path.default.join(import_path.default.dirname(tsconfigPath), options.baseUrl || ".");
|
|
32
53
|
const ignoreCompileOptions = [
|
|
33
54
|
"incremental",
|
|
34
55
|
"tsBuildInfoFile",
|
|
35
56
|
"sourceMap",
|
|
36
57
|
"inlineSources"
|
|
37
58
|
];
|
|
38
|
-
const resolveRelative = (p) =>
|
|
39
|
-
const dtsInput = Array.isArray(input) ? input.map(resolveRelative) : (0,
|
|
59
|
+
const resolveRelative = (p) => import_path.default.resolve(appDirectory, p);
|
|
60
|
+
const dtsInput = Array.isArray(input) ? input.map(resolveRelative) : (0, import_utils2.mapValue)(input, resolveRelative);
|
|
40
61
|
const inputConfig = {
|
|
41
62
|
input: dtsInput,
|
|
42
63
|
external: externals,
|
|
43
64
|
plugins: [
|
|
44
|
-
(0,
|
|
65
|
+
(0, import_plugin_json.default)(),
|
|
45
66
|
ignoreFiles,
|
|
46
|
-
(0,
|
|
67
|
+
(0, import_rollup_plugin_dts.default)({
|
|
47
68
|
respectExternal,
|
|
48
69
|
compilerOptions: {
|
|
49
70
|
skipLibCheck: true,
|
|
@@ -67,22 +88,22 @@ const runRollup = async (api, { distDir, tsconfigPath, externals, input, watch,
|
|
|
67
88
|
// Avoid extra work
|
|
68
89
|
checkJs: false,
|
|
69
90
|
// Ensure we can parse the latest code
|
|
70
|
-
target:
|
|
71
|
-
...(0,
|
|
91
|
+
target: import_typescript.default.ScriptTarget.ESNext,
|
|
92
|
+
...(0, import_utils2.transformUndefineObject)(ignoreCompileOptions)
|
|
72
93
|
},
|
|
73
94
|
tsconfig: tsconfigPath
|
|
74
95
|
})
|
|
75
96
|
].filter(Boolean)
|
|
76
97
|
};
|
|
77
98
|
const outputConfig = {
|
|
78
|
-
dir:
|
|
99
|
+
dir: distPath,
|
|
79
100
|
format: "esm",
|
|
80
|
-
exports: "named"
|
|
101
|
+
exports: "named",
|
|
102
|
+
footer,
|
|
103
|
+
banner
|
|
81
104
|
};
|
|
82
105
|
if (watch) {
|
|
83
|
-
const { watch: watch2 } = await Promise.resolve().then(() =>
|
|
84
|
-
const { watchSectionTitle } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("../../utils/log")));
|
|
85
|
-
const { SectionTitleStatus, BundleDtsLogPrefix } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("../../constants/log")));
|
|
106
|
+
const { watch: watch2 } = await Promise.resolve().then(() => __toESM(require("../../../compiled/rollup")));
|
|
86
107
|
const runner = api.useHookRunners();
|
|
87
108
|
const watcher = watch2({
|
|
88
109
|
...inputConfig,
|
|
@@ -90,9 +111,9 @@ const runRollup = async (api, { distDir, tsconfigPath, externals, input, watch,
|
|
|
90
111
|
output: outputConfig
|
|
91
112
|
}).on("event", async (event) => {
|
|
92
113
|
if (event.code === "START") {
|
|
93
|
-
|
|
114
|
+
import_utils.logger.info((0, import_utils2.withLogTitle)("bundle", "Start build types..."));
|
|
94
115
|
} else if (event.code === "BUNDLE_END") {
|
|
95
|
-
|
|
116
|
+
import_utils.logger.success((0, import_utils2.withLogTitle)("bundle", "Build types"));
|
|
96
117
|
runner.buildWatchDts({
|
|
97
118
|
buildType: "bundle"
|
|
98
119
|
});
|
|
@@ -102,14 +123,14 @@ const runRollup = async (api, { distDir, tsconfigPath, externals, input, watch,
|
|
|
102
123
|
return watcher;
|
|
103
124
|
} else {
|
|
104
125
|
try {
|
|
105
|
-
const { rollup } = await Promise.resolve().then(() =>
|
|
106
|
-
const { addRollupChunk } = await Promise.resolve().then(() =>
|
|
126
|
+
const { rollup } = await Promise.resolve().then(() => __toESM(require("../../../compiled/rollup")));
|
|
127
|
+
const { addRollupChunk } = await Promise.resolve().then(() => __toESM(require("../../utils")));
|
|
107
128
|
const bundle = await rollup(inputConfig);
|
|
108
129
|
const rollupOutput = await bundle.write(outputConfig);
|
|
109
130
|
addRollupChunk(rollupOutput, appDirectory, outputConfig.dir);
|
|
110
131
|
return bundle;
|
|
111
132
|
} catch (e) {
|
|
112
|
-
const { printOrThrowDtsErrors } = await Promise.resolve().then(() =>
|
|
133
|
+
const { printOrThrowDtsErrors } = await Promise.resolve().then(() => __toESM(require("../../utils")));
|
|
113
134
|
await printOrThrowDtsErrors(e, {
|
|
114
135
|
abortOnError,
|
|
115
136
|
buildType: "bundle"
|
|
@@ -118,5 +139,7 @@ const runRollup = async (api, { distDir, tsconfigPath, externals, input, watch,
|
|
|
118
139
|
}
|
|
119
140
|
}
|
|
120
141
|
};
|
|
121
|
-
|
|
122
|
-
|
|
142
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
143
|
+
0 && (module.exports = {
|
|
144
|
+
runRollup
|
|
145
|
+
});
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const
|
|
1
|
+
import type { GeneratorDtsConfig, PluginAPI, ModuleTools } from '../../types';
|
|
2
|
+
export declare const removeTscLogTime: (log: string) => string;
|
|
3
|
+
export declare const runTsc: (api: PluginAPI<ModuleTools>, config: GeneratorDtsConfig) => Promise<void>;
|
package/dist/builder/dts/tsc.js
CHANGED
|
@@ -1,48 +1,60 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
9
15
|
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var tsc_exports = {};
|
|
20
|
+
__export(tsc_exports, {
|
|
21
|
+
removeTscLogTime: () => removeTscLogTime,
|
|
22
|
+
runTsc: () => runTsc
|
|
10
23
|
});
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
const _dts1 = require("../../constants/dts");
|
|
24
|
+
module.exports = __toCommonJS(tsc_exports);
|
|
25
|
+
var import_utils = require("@modern-js/utils");
|
|
26
|
+
var import_utils2 = require("../../utils");
|
|
27
|
+
var import_dts = require("../../constants/dts");
|
|
28
|
+
const removeTscLogTime = (log) => log.replace(/\[.*\]\s/, "");
|
|
17
29
|
const resolveLog = async (childProgress, options) => {
|
|
18
30
|
var _childProgress_stdout, _childProgress_stdout1, _childProgress_stderr;
|
|
19
31
|
const { watch = false, watchFn = async () => void 0 } = options;
|
|
20
32
|
(_childProgress_stdout = childProgress.stdout) === null || _childProgress_stdout === void 0 ? void 0 : _childProgress_stdout.on("data", async (data) => {
|
|
21
33
|
if (watch) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if (data.toString().includes(
|
|
34
|
+
const lines = data.toString().split("\n").filter((line) => line.trim() !== "").map((line) => (0, import_utils2.withLogTitle)("tsc", removeTscLogTime(line)));
|
|
35
|
+
import_utils.logger.info(lines.join("\n"));
|
|
36
|
+
if (data.toString().includes(import_dts.watchDoneText)) {
|
|
25
37
|
await watchFn();
|
|
26
38
|
}
|
|
27
39
|
}
|
|
28
40
|
});
|
|
29
41
|
(_childProgress_stdout1 = childProgress.stdout) === null || _childProgress_stdout1 === void 0 ? void 0 : _childProgress_stdout1.on("error", (error) => {
|
|
30
|
-
|
|
42
|
+
import_utils.logger.error(error.message);
|
|
31
43
|
});
|
|
32
44
|
(_childProgress_stderr = childProgress.stderr) === null || _childProgress_stderr === void 0 ? void 0 : _childProgress_stderr.on("data", (chunk) => {
|
|
33
|
-
|
|
45
|
+
import_utils.logger.error(chunk.toString());
|
|
34
46
|
});
|
|
35
47
|
};
|
|
36
|
-
const
|
|
48
|
+
const runTscBin = async (api, config, info) => {
|
|
37
49
|
const { appDirectory, watch = false, abortOnError = true } = config;
|
|
38
|
-
const {
|
|
39
|
-
const tscBinFile = await (0,
|
|
50
|
+
const { tempTsconfigPath } = info;
|
|
51
|
+
const tscBinFile = await (0, import_utils2.getTscBinPath)(appDirectory);
|
|
40
52
|
const watchParams = watch ? [
|
|
41
53
|
"-w"
|
|
42
54
|
] : [];
|
|
43
|
-
const childProgress = (0,
|
|
55
|
+
const childProgress = (0, import_utils.execa)(tscBinFile, [
|
|
44
56
|
"-p",
|
|
45
|
-
|
|
57
|
+
tempTsconfigPath,
|
|
46
58
|
/* Required parameter, use it stdout have color */
|
|
47
59
|
"--pretty",
|
|
48
60
|
// https://github.com/microsoft/TypeScript/issues/21824
|
|
@@ -56,10 +68,9 @@ const generatorDts = async (api, config) => {
|
|
|
56
68
|
resolveLog(childProgress, {
|
|
57
69
|
watch,
|
|
58
70
|
watchFn: async () => {
|
|
59
|
-
await (0,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
});
|
|
71
|
+
const result = await (0, import_utils2.resolveAlias)(config, info);
|
|
72
|
+
const dtsFiles = (0, import_utils2.addBannerAndFooter)(result, config.banner, config.footer);
|
|
73
|
+
await (0, import_utils2.writeDtsFiles)(config, info, dtsFiles);
|
|
63
74
|
runner.buildWatchDts({
|
|
64
75
|
buildType: "bundleless"
|
|
65
76
|
});
|
|
@@ -68,20 +79,22 @@ const generatorDts = async (api, config) => {
|
|
|
68
79
|
try {
|
|
69
80
|
await childProgress;
|
|
70
81
|
} catch (e) {
|
|
71
|
-
await (0,
|
|
82
|
+
await (0, import_utils2.printOrThrowDtsErrors)(e, {
|
|
72
83
|
abortOnError,
|
|
73
84
|
buildType: "bundleless"
|
|
74
85
|
});
|
|
75
86
|
}
|
|
76
|
-
return {
|
|
77
|
-
...result,
|
|
78
|
-
userTsconfig
|
|
79
|
-
};
|
|
80
87
|
};
|
|
81
88
|
const runTsc = async (api, config) => {
|
|
82
|
-
const
|
|
83
|
-
await (
|
|
84
|
-
await (0,
|
|
89
|
+
const generatedDtsInfo = await (0, import_utils2.generateDtsInfo)(config);
|
|
90
|
+
await runTscBin(api, config, generatedDtsInfo);
|
|
91
|
+
const result = await (0, import_utils2.resolveAlias)(config, generatedDtsInfo);
|
|
92
|
+
const dtsFiles = (0, import_utils2.addBannerAndFooter)(result, config.banner, config.footer);
|
|
93
|
+
await (0, import_utils2.writeDtsFiles)(config, generatedDtsInfo, dtsFiles);
|
|
94
|
+
await (0, import_utils2.addDtsFiles)(config.distPath, config.appDirectory);
|
|
85
95
|
};
|
|
86
|
-
|
|
87
|
-
|
|
96
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
97
|
+
0 && (module.exports = {
|
|
98
|
+
removeTscLogTime,
|
|
99
|
+
runTsc
|
|
100
|
+
});
|