@modern-js/babel-compiler 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/dist/cjs/build.js +33 -16
- package/dist/cjs/buildWatch.js +57 -40
- package/dist/cjs/compiler.js +57 -41
- package/dist/cjs/compilerErrorResult.js +27 -11
- package/dist/cjs/constants.js +24 -7
- package/dist/cjs/defaults.js +26 -9
- package/dist/cjs/getFinalOption.js +38 -30
- package/dist/cjs/index.js +37 -17
- package/dist/cjs/type.js +15 -3
- package/dist/cjs/utils.js +36 -10
- package/dist/cjs/validate.js +34 -27
- package/dist/esm/build.js +14 -11
- package/dist/esm/buildWatch.js +11 -5
- package/dist/esm/compiler.js +20 -15
- package/dist/esm/compilerErrorResult.js +5 -3
- package/dist/esm/constants.js +4 -1
- package/dist/esm/defaults.js +4 -1
- package/dist/esm/getFinalOption.js +15 -9
- package/dist/esm/index.js +4 -1
- package/dist/esm/type.js +0 -1
- package/dist/esm/utils.js +4 -1
- package/dist/esm/validate.js +12 -5
- package/dist/esm-node/build.js +4 -1
- package/dist/esm-node/buildWatch.js +10 -4
- package/dist/esm-node/compiler.js +11 -6
- package/dist/esm-node/compilerErrorResult.js +5 -3
- package/dist/esm-node/constants.js +4 -1
- package/dist/esm-node/defaults.js +4 -1
- package/dist/esm-node/getFinalOption.js +10 -4
- package/dist/esm-node/index.js +4 -1
- package/dist/esm-node/type.js +0 -1
- package/dist/esm-node/utils.js +4 -1
- package/dist/esm-node/validate.js +12 -5
- package/package.json +4 -4
package/dist/cjs/build.js
CHANGED
|
@@ -1,27 +1,40 @@
|
|
|
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 build_exports = {};
|
|
20
|
+
__export(build_exports, {
|
|
21
|
+
build: () => build
|
|
10
22
|
});
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
23
|
+
module.exports = __toCommonJS(build_exports);
|
|
24
|
+
var import_utils = require("@modern-js/utils");
|
|
25
|
+
var import_constants = require("./constants");
|
|
26
|
+
var import_compiler = require("./compiler");
|
|
14
27
|
const build = async (option, babelConfig = {}) => {
|
|
15
|
-
const { rootDir, enableVirtualDist, filenames, clean, distDir, distFileExtMap =
|
|
28
|
+
const { rootDir, enableVirtualDist, filenames, clean, distDir, distFileExtMap = import_constants.defaultDistFileExtMap, verbose = false, quiet = false } = option;
|
|
16
29
|
const virtualDists = [];
|
|
17
30
|
if (clean) {
|
|
18
|
-
await
|
|
31
|
+
await import_utils.fs.remove(distDir);
|
|
19
32
|
}
|
|
20
|
-
|
|
33
|
+
import_utils.fs.ensureDir(distDir);
|
|
21
34
|
const messageDetails = [];
|
|
22
35
|
for (const filename of filenames) {
|
|
23
36
|
try {
|
|
24
|
-
const dist = (0,
|
|
37
|
+
const dist = (0, import_compiler.compiler)({
|
|
25
38
|
rootDir,
|
|
26
39
|
enableVirtualDist,
|
|
27
40
|
filepath: filename,
|
|
@@ -44,9 +57,9 @@ const build = async (option, babelConfig = {}) => {
|
|
|
44
57
|
const happenError = messageDetails.length > 0;
|
|
45
58
|
if (!quiet) {
|
|
46
59
|
if (happenError) {
|
|
47
|
-
|
|
60
|
+
import_utils.logger.error(`Compilation failure ${messageDetails.length} ${messageDetails.length !== 1 ? "files" : "file"} with Babel.`);
|
|
48
61
|
} else {
|
|
49
|
-
|
|
62
|
+
import_utils.logger.info(`Successfully compiled ${filenames.length} ${filenames.length !== 1 ? "files" : "file"} with Babel.`);
|
|
50
63
|
}
|
|
51
64
|
}
|
|
52
65
|
if (happenError) {
|
|
@@ -62,3 +75,7 @@ const build = async (option, babelConfig = {}) => {
|
|
|
62
75
|
virtualDists
|
|
63
76
|
};
|
|
64
77
|
};
|
|
78
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
79
|
+
0 && (module.exports = {
|
|
80
|
+
build
|
|
81
|
+
});
|
package/dist/cjs/buildWatch.js
CHANGED
|
@@ -1,41 +1,51 @@
|
|
|
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 BuildWatchEvent;
|
|
15
|
-
},
|
|
16
|
-
BuildWatchEmitter: function() {
|
|
17
|
-
return BuildWatchEmitter;
|
|
18
|
-
},
|
|
19
|
-
runBuildWatch: function() {
|
|
20
|
-
return runBuildWatch;
|
|
21
|
-
},
|
|
22
|
-
buildWatch: function() {
|
|
23
|
-
return buildWatch;
|
|
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 });
|
|
24
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 buildWatch_exports = {};
|
|
30
|
+
__export(buildWatch_exports, {
|
|
31
|
+
BuildWatchEmitter: () => BuildWatchEmitter,
|
|
32
|
+
BuildWatchEvent: () => BuildWatchEvent,
|
|
33
|
+
buildWatch: () => buildWatch,
|
|
34
|
+
runBuildWatch: () => runBuildWatch
|
|
25
35
|
});
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
36
|
+
module.exports = __toCommonJS(buildWatch_exports);
|
|
37
|
+
var import_define_property = require("@swc/helpers/_/_define_property");
|
|
38
|
+
var path = __toESM(require("path"));
|
|
39
|
+
var Event = __toESM(require("events"));
|
|
40
|
+
var import_utils = require("@modern-js/utils");
|
|
41
|
+
var import_build = require("./build");
|
|
42
|
+
var import_compilerErrorResult = require("./compilerErrorResult");
|
|
33
43
|
const BuildWatchEvent = {
|
|
34
44
|
firstCompiler: "first-compiler",
|
|
35
45
|
compiling: "compiling",
|
|
36
46
|
watchingCompiler: "watching-compiler"
|
|
37
47
|
};
|
|
38
|
-
class BuildWatchEmitter extends
|
|
48
|
+
class BuildWatchEmitter extends Event.EventEmitter {
|
|
39
49
|
setInitFn(fn) {
|
|
40
50
|
this._initFn = fn;
|
|
41
51
|
}
|
|
@@ -47,15 +57,15 @@ class BuildWatchEmitter extends _events.EventEmitter {
|
|
|
47
57
|
}
|
|
48
58
|
constructor(...args) {
|
|
49
59
|
super(...args);
|
|
50
|
-
|
|
60
|
+
(0, import_define_property._)(this, "_initFn", void 0);
|
|
51
61
|
}
|
|
52
62
|
}
|
|
53
63
|
const runBuildWatch = async (option, babelConfig = {}, emitter) => {
|
|
54
64
|
emitter.emit(BuildWatchEvent.compiling);
|
|
55
|
-
const errorResult = new
|
|
65
|
+
const errorResult = new import_compilerErrorResult.CompilerErrorResult();
|
|
56
66
|
const watchDir = option.watchDir;
|
|
57
67
|
const { distDir, quiet } = option;
|
|
58
|
-
const firstBuildResult = await (0,
|
|
68
|
+
const firstBuildResult = await (0, import_build.build)(option, babelConfig);
|
|
59
69
|
const { code } = firstBuildResult;
|
|
60
70
|
if (code === 1) {
|
|
61
71
|
errorResult.init(firstBuildResult);
|
|
@@ -63,14 +73,14 @@ const runBuildWatch = async (option, babelConfig = {}, emitter) => {
|
|
|
63
73
|
} else {
|
|
64
74
|
emitter.emit(BuildWatchEvent.firstCompiler, firstBuildResult);
|
|
65
75
|
}
|
|
66
|
-
return (0,
|
|
76
|
+
return (0, import_utils.watch)(`${watchDir}/**/*.{js,jsx,ts,tsx}`, async ({ changeType, changedFilePath }) => {
|
|
67
77
|
emitter.emit(BuildWatchEvent.compiling);
|
|
68
|
-
if (changeType ===
|
|
78
|
+
if (changeType === import_utils.WatchChangeType.UNLINK) {
|
|
69
79
|
const removeFiles = [
|
|
70
|
-
|
|
80
|
+
path.normalize(`./${distDir}/${path.relative(watchDir, changedFilePath)}`)
|
|
71
81
|
];
|
|
72
82
|
if (!quiet) {
|
|
73
|
-
|
|
83
|
+
import_utils.logger.info(`remove file: ${removeFiles.join(",")}`);
|
|
74
84
|
}
|
|
75
85
|
const result2 = {
|
|
76
86
|
code: 0,
|
|
@@ -80,7 +90,7 @@ const runBuildWatch = async (option, babelConfig = {}, emitter) => {
|
|
|
80
90
|
emitter.emit(BuildWatchEvent.watchingCompiler, result2);
|
|
81
91
|
return;
|
|
82
92
|
}
|
|
83
|
-
const result = await (0,
|
|
93
|
+
const result = await (0, import_build.build)({
|
|
84
94
|
...option,
|
|
85
95
|
filenames: [
|
|
86
96
|
changedFilePath
|
|
@@ -89,7 +99,7 @@ const runBuildWatch = async (option, babelConfig = {}, emitter) => {
|
|
|
89
99
|
if (result.code === 1) {
|
|
90
100
|
errorResult.update(result.messageDetails || []);
|
|
91
101
|
emitter.emit(BuildWatchEvent.watchingCompiler, errorResult.value);
|
|
92
|
-
!quiet &&
|
|
102
|
+
!quiet && import_utils.logger.info(errorResult.value.message);
|
|
93
103
|
} else {
|
|
94
104
|
errorResult.removeByFileName(changedFilePath);
|
|
95
105
|
if (errorResult.checkExistError()) {
|
|
@@ -97,10 +107,10 @@ const runBuildWatch = async (option, babelConfig = {}, emitter) => {
|
|
|
97
107
|
...errorResult.value,
|
|
98
108
|
virtualDists: result.virtualDists
|
|
99
109
|
});
|
|
100
|
-
!quiet &&
|
|
110
|
+
!quiet && import_utils.logger.info(errorResult.value.message);
|
|
101
111
|
} else {
|
|
102
112
|
emitter.emit(BuildWatchEvent.watchingCompiler, result);
|
|
103
|
-
!quiet &&
|
|
113
|
+
!quiet && import_utils.logger.info(result.message);
|
|
104
114
|
}
|
|
105
115
|
}
|
|
106
116
|
}, [
|
|
@@ -112,3 +122,10 @@ const buildWatch = (option, babelConfig = {}) => {
|
|
|
112
122
|
buildWatchEmitter.setInitFn(runBuildWatch.bind(null, option, babelConfig));
|
|
113
123
|
return buildWatchEmitter;
|
|
114
124
|
};
|
|
125
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
126
|
+
0 && (module.exports = {
|
|
127
|
+
BuildWatchEmitter,
|
|
128
|
+
BuildWatchEvent,
|
|
129
|
+
buildWatch,
|
|
130
|
+
runBuildWatch
|
|
131
|
+
});
|
package/dist/cjs/compiler.js
CHANGED
|
@@ -1,49 +1,59 @@
|
|
|
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 isRes;
|
|
15
|
-
},
|
|
16
|
-
getDistFilePath: function() {
|
|
17
|
-
return getDistFilePath;
|
|
18
|
-
},
|
|
19
|
-
resolveSourceMap: function() {
|
|
20
|
-
return resolveSourceMap;
|
|
21
|
-
},
|
|
22
|
-
compiler: function() {
|
|
23
|
-
return compiler;
|
|
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 });
|
|
24
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 compiler_exports = {};
|
|
30
|
+
__export(compiler_exports, {
|
|
31
|
+
compiler: () => compiler,
|
|
32
|
+
getDistFilePath: () => getDistFilePath,
|
|
33
|
+
isRes: () => isRes,
|
|
34
|
+
resolveSourceMap: () => resolveSourceMap
|
|
25
35
|
});
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
36
|
+
module.exports = __toCommonJS(compiler_exports);
|
|
37
|
+
var path = __toESM(require("path"));
|
|
38
|
+
var babel = __toESM(require("@babel/core"));
|
|
39
|
+
var import_utils = require("@modern-js/utils");
|
|
40
|
+
var utils = __toESM(require("./utils"));
|
|
41
|
+
var import_constants = require("./constants");
|
|
32
42
|
const defaultDistDir = "dist";
|
|
33
43
|
const isRes = (r) => Boolean(r);
|
|
34
44
|
const getDistFilePath = (option) => {
|
|
35
45
|
const { filepath, rootDir, distDir, extMap } = option;
|
|
36
|
-
const ext =
|
|
37
|
-
return
|
|
46
|
+
const ext = path.extname(filepath);
|
|
47
|
+
return path.join(distDir, path.relative(rootDir, filepath).replace(ext, extMap[ext]));
|
|
38
48
|
};
|
|
39
49
|
const resolveSourceMap = (option) => {
|
|
40
50
|
const { babelRes, sourceFilePath, distFilePath, enableVirtualDist = false } = option;
|
|
41
51
|
const mapLoc = `${distFilePath}.map`;
|
|
42
|
-
babelRes.code =
|
|
52
|
+
babelRes.code = utils.addSourceMappingUrl(babelRes.code, mapLoc);
|
|
43
53
|
if (babelRes.map) {
|
|
44
|
-
babelRes.map.file =
|
|
54
|
+
babelRes.map.file = path.basename(distFilePath);
|
|
45
55
|
babelRes.map.sources = [
|
|
46
|
-
|
|
56
|
+
path.relative(path.dirname(distFilePath), sourceFilePath)
|
|
47
57
|
];
|
|
48
58
|
}
|
|
49
59
|
const sourceMapVirtualDist = {
|
|
@@ -53,14 +63,13 @@ const resolveSourceMap = (option) => {
|
|
|
53
63
|
if (enableVirtualDist) {
|
|
54
64
|
return sourceMapVirtualDist;
|
|
55
65
|
}
|
|
56
|
-
|
|
57
|
-
|
|
66
|
+
import_utils.fs.ensureDirSync(path.dirname(mapLoc));
|
|
67
|
+
import_utils.fs.writeFileSync(mapLoc, JSON.stringify(babelRes.map));
|
|
58
68
|
return sourceMapVirtualDist;
|
|
59
69
|
};
|
|
60
70
|
const compiler = (option) => {
|
|
61
|
-
|
|
62
|
-
const
|
|
63
|
-
const babelRes = _core.transformFileSync(filepath, babelConfig);
|
|
71
|
+
const { filepath, rootDir, enableVirtualDist = false, distDir = path.join(path.dirname(rootDir), defaultDistDir), verbose = false, babelConfig = {}, distFileExtMap = import_constants.defaultDistFileExtMap, quiet = false } = option;
|
|
72
|
+
const babelRes = babel.transformFileSync(filepath, babelConfig);
|
|
64
73
|
let virtualDist = null;
|
|
65
74
|
if (!isRes(babelRes)) {
|
|
66
75
|
throw new Error(`${filepath} happen error`);
|
|
@@ -79,7 +88,7 @@ const compiler = (option) => {
|
|
|
79
88
|
sourcemap: ""
|
|
80
89
|
};
|
|
81
90
|
}
|
|
82
|
-
if ((
|
|
91
|
+
if ((babelRes === null || babelRes === void 0 ? void 0 : babelRes.map) && babelConfig.sourceMaps && babelConfig.sourceMaps !== "inline") {
|
|
83
92
|
if (virtualDist) {
|
|
84
93
|
virtualDist = {
|
|
85
94
|
...virtualDist,
|
|
@@ -106,11 +115,18 @@ const compiler = (option) => {
|
|
|
106
115
|
code: babelRes.code
|
|
107
116
|
};
|
|
108
117
|
} else {
|
|
109
|
-
|
|
110
|
-
|
|
118
|
+
import_utils.fs.ensureDirSync(path.dirname(distFilePath));
|
|
119
|
+
import_utils.fs.writeFileSync(distFilePath, babelRes.code);
|
|
111
120
|
}
|
|
112
121
|
if (verbose && !quiet) {
|
|
113
|
-
|
|
122
|
+
import_utils.logger.info(`${filepath} => ${distFilePath}`);
|
|
114
123
|
}
|
|
115
124
|
return virtualDist;
|
|
116
125
|
};
|
|
126
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
127
|
+
0 && (module.exports = {
|
|
128
|
+
compiler,
|
|
129
|
+
getDistFilePath,
|
|
130
|
+
isRes,
|
|
131
|
+
resolveSourceMap
|
|
132
|
+
});
|
|
@@ -1,18 +1,30 @@
|
|
|
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 compilerErrorResult_exports = {};
|
|
20
|
+
__export(compilerErrorResult_exports, {
|
|
21
|
+
CompilerErrorResult: () => CompilerErrorResult
|
|
10
22
|
});
|
|
11
|
-
|
|
23
|
+
module.exports = __toCommonJS(compilerErrorResult_exports);
|
|
24
|
+
var import_define_property = require("@swc/helpers/_/_define_property");
|
|
12
25
|
class CompilerErrorResult {
|
|
13
26
|
init(initErrorResult) {
|
|
14
|
-
|
|
15
|
-
this._messageDetails = ((_initErrorResult = initErrorResult) === null || _initErrorResult === void 0 ? void 0 : _initErrorResult.messageDetails) || [];
|
|
27
|
+
this._messageDetails = (initErrorResult === null || initErrorResult === void 0 ? void 0 : initErrorResult.messageDetails) || [];
|
|
16
28
|
}
|
|
17
29
|
update(messageDetails) {
|
|
18
30
|
for (const messageDetail of messageDetails) {
|
|
@@ -43,7 +55,11 @@ class CompilerErrorResult {
|
|
|
43
55
|
return this._messageDetails.length > 0;
|
|
44
56
|
}
|
|
45
57
|
constructor(initErrorResult) {
|
|
46
|
-
|
|
58
|
+
(0, import_define_property._)(this, "_messageDetails", void 0);
|
|
47
59
|
this.init(initErrorResult);
|
|
48
60
|
}
|
|
49
61
|
}
|
|
62
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
63
|
+
0 && (module.exports = {
|
|
64
|
+
CompilerErrorResult
|
|
65
|
+
});
|
package/dist/cjs/constants.js
CHANGED
|
@@ -1,16 +1,33 @@
|
|
|
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 constants_exports = {};
|
|
20
|
+
__export(constants_exports, {
|
|
21
|
+
defaultDistFileExtMap: () => defaultDistFileExtMap
|
|
10
22
|
});
|
|
23
|
+
module.exports = __toCommonJS(constants_exports);
|
|
11
24
|
const defaultDistFileExtMap = {
|
|
12
25
|
".js": ".js",
|
|
13
26
|
".jsx": ".js",
|
|
14
27
|
".ts": ".js",
|
|
15
28
|
".tsx": ".js"
|
|
16
29
|
};
|
|
30
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
31
|
+
0 && (module.exports = {
|
|
32
|
+
defaultDistFileExtMap
|
|
33
|
+
});
|
package/dist/cjs/defaults.js
CHANGED
|
@@ -1,20 +1,33 @@
|
|
|
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 defaults_exports = {};
|
|
20
|
+
__export(defaults_exports, {
|
|
21
|
+
mergeDefaultOption: () => mergeDefaultOption
|
|
10
22
|
});
|
|
11
|
-
|
|
23
|
+
module.exports = __toCommonJS(defaults_exports);
|
|
24
|
+
var import_constants = require("./constants");
|
|
12
25
|
const defaultOptions = {
|
|
13
26
|
enableWatch: false,
|
|
14
27
|
enableVirtualDist: false,
|
|
15
28
|
extensions: [],
|
|
16
29
|
filenames: [],
|
|
17
|
-
distFileExtMap:
|
|
30
|
+
distFileExtMap: import_constants.defaultDistFileExtMap,
|
|
18
31
|
ignore: [],
|
|
19
32
|
quiet: false,
|
|
20
33
|
verbose: false,
|
|
@@ -24,3 +37,7 @@ const mergeDefaultOption = (compilerOptions) => ({
|
|
|
24
37
|
...defaultOptions,
|
|
25
38
|
...compilerOptions
|
|
26
39
|
});
|
|
40
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
41
|
+
0 && (module.exports = {
|
|
42
|
+
mergeDefaultOption
|
|
43
|
+
});
|
|
@@ -1,31 +1,32 @@
|
|
|
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 getGlobPattern;
|
|
15
|
-
},
|
|
16
|
-
getFinalExtensions: function() {
|
|
17
|
-
return getFinalExtensions;
|
|
18
|
-
},
|
|
19
|
-
getFilesFromDir: function() {
|
|
20
|
-
return getFilesFromDir;
|
|
21
|
-
},
|
|
22
|
-
getFinalCompilerOption: function() {
|
|
23
|
-
return getFinalCompilerOption;
|
|
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 });
|
|
24
15
|
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var getFinalOption_exports = {};
|
|
20
|
+
__export(getFinalOption_exports, {
|
|
21
|
+
getFilesFromDir: () => getFilesFromDir,
|
|
22
|
+
getFinalCompilerOption: () => getFinalCompilerOption,
|
|
23
|
+
getFinalExtensions: () => getFinalExtensions,
|
|
24
|
+
getGlobPattern: () => getGlobPattern
|
|
25
25
|
});
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
module.exports = __toCommonJS(getFinalOption_exports);
|
|
27
|
+
var import_utils = require("@modern-js/utils");
|
|
28
|
+
var import_core = require("@babel/core");
|
|
29
|
+
var import_defaults = require("./defaults");
|
|
29
30
|
const getGlobPattern = (dir, extensions) => {
|
|
30
31
|
if (extensions.length > 1) {
|
|
31
32
|
return `${dir}/**/*{${extensions.join(",")}}`;
|
|
@@ -41,25 +42,25 @@ const getFinalExtensions = (extensions) => {
|
|
|
41
42
|
if (isExtensions(extensions)) {
|
|
42
43
|
return [
|
|
43
44
|
...extensions,
|
|
44
|
-
...
|
|
45
|
+
...import_core.DEFAULT_EXTENSIONS
|
|
45
46
|
];
|
|
46
47
|
} else if (isExtensionsFunc(extensions)) {
|
|
47
|
-
return extensions(
|
|
48
|
+
return extensions(import_core.DEFAULT_EXTENSIONS);
|
|
48
49
|
} else {
|
|
49
|
-
return
|
|
50
|
+
return import_core.DEFAULT_EXTENSIONS;
|
|
50
51
|
}
|
|
51
52
|
};
|
|
52
53
|
const getFilesFromDir = ({ dir, finalExt = [], ignore = [] }) => {
|
|
53
54
|
let globFindFilenames = [];
|
|
54
55
|
const globPattern = getGlobPattern(dir, finalExt);
|
|
55
|
-
globFindFilenames =
|
|
56
|
+
globFindFilenames = import_utils.glob.sync(globPattern, {
|
|
56
57
|
ignore
|
|
57
58
|
});
|
|
58
59
|
return globFindFilenames;
|
|
59
60
|
};
|
|
60
61
|
const getFinalCompilerOption = (option) => {
|
|
61
|
-
const optionWithDefault = (0,
|
|
62
|
-
const { sourceDir, ignore, enableWatch = false, watchDir, extensions =
|
|
62
|
+
const optionWithDefault = (0, import_defaults.mergeDefaultOption)(option);
|
|
63
|
+
const { sourceDir, ignore, enableWatch = false, watchDir, extensions = import_core.DEFAULT_EXTENSIONS } = option;
|
|
63
64
|
let globFindFilenames = [];
|
|
64
65
|
const finalExt = getFinalExtensions(extensions);
|
|
65
66
|
if (sourceDir) {
|
|
@@ -84,3 +85,10 @@ const getFinalCompilerOption = (option) => {
|
|
|
84
85
|
]
|
|
85
86
|
};
|
|
86
87
|
};
|
|
88
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
89
|
+
0 && (module.exports = {
|
|
90
|
+
getFilesFromDir,
|
|
91
|
+
getFinalCompilerOption,
|
|
92
|
+
getFinalExtensions,
|
|
93
|
+
getGlobPattern
|
|
94
|
+
});
|