@modern-js/babel-compiler 2.0.0-beta.3 → 2.0.0-beta.4
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 +30 -0
- package/dist/js/modern/build.js +35 -9
- package/dist/js/modern/buildWatch.js +107 -68
- package/dist/js/modern/compiler.js +48 -26
- package/dist/js/modern/compilerErrorResult.js +12 -11
- package/dist/js/modern/constants.js +9 -6
- package/dist/js/modern/defaults.js +20 -4
- package/dist/js/modern/getFinalOption.js +40 -21
- package/dist/js/modern/index.js +37 -12
- package/dist/js/modern/utils.js +8 -4
- package/dist/js/modern/validate.js +17 -22
- package/dist/js/node/build.js +58 -20
- package/dist/js/node/buildWatch.js +131 -79
- package/dist/js/node/compiler.js +79 -44
- package/dist/js/node/compilerErrorResult.js +28 -15
- package/dist/js/node/constants.js +25 -10
- package/dist/js/node/defaults.js +40 -12
- package/dist/js/node/getFinalOption.js +61 -33
- package/dist/js/node/index.js +58 -43
- package/dist/js/node/utils.js +31 -10
- package/dist/js/node/validate.js +36 -33
- package/dist/js/treeshaking/build.js +224 -0
- package/dist/js/treeshaking/buildWatch.js +417 -0
- package/dist/js/treeshaking/compiler.js +140 -0
- package/dist/js/treeshaking/compilerErrorResult.js +110 -0
- package/dist/js/treeshaking/constants.js +7 -0
- package/dist/js/treeshaking/defaults.js +44 -0
- package/dist/js/treeshaking/getFinalOption.js +137 -0
- package/dist/js/treeshaking/index.js +166 -0
- package/dist/js/treeshaking/type.js +1 -0
- package/dist/js/treeshaking/utils.js +5 -0
- package/dist/js/treeshaking/validate.js +38 -0
- package/package.json +4 -4
|
@@ -1,24 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var stdin_exports = {};
|
|
19
|
+
__export(stdin_exports, {
|
|
20
|
+
CompilerErrorResult: () => CompilerErrorResult
|
|
5
21
|
});
|
|
6
|
-
exports
|
|
7
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
22
|
+
module.exports = __toCommonJS(stdin_exports);
|
|
8
23
|
class CompilerErrorResult {
|
|
9
24
|
constructor(initErrorResult) {
|
|
10
|
-
_defineProperty(this, "_messageDetails", void 0);
|
|
11
25
|
this.init(initErrorResult);
|
|
12
26
|
}
|
|
13
27
|
init(initErrorResult) {
|
|
14
|
-
this._messageDetails = (initErrorResult
|
|
28
|
+
this._messageDetails = (initErrorResult == null ? void 0 : initErrorResult.messageDetails) || [];
|
|
15
29
|
}
|
|
16
30
|
update(messageDetails) {
|
|
17
31
|
for (const messageDetail of messageDetails) {
|
|
18
|
-
|
|
19
|
-
const addError = !this._messageDetails.some(detail => {
|
|
32
|
+
const addError = !this._messageDetails.some((detail) => {
|
|
20
33
|
if (detail.filename === messageDetail.filename) {
|
|
21
|
-
// 如果错误栈里存在该文件报错信息,则更新内容
|
|
22
34
|
detail.content = messageDetail.content;
|
|
23
35
|
return true;
|
|
24
36
|
}
|
|
@@ -30,13 +42,15 @@ class CompilerErrorResult {
|
|
|
30
42
|
}
|
|
31
43
|
}
|
|
32
44
|
removeByFileName(filename) {
|
|
33
|
-
this._messageDetails = this._messageDetails.filter(
|
|
45
|
+
this._messageDetails = this._messageDetails.filter(
|
|
46
|
+
(detail) => detail.filename !== filename
|
|
47
|
+
);
|
|
34
48
|
}
|
|
35
49
|
get value() {
|
|
36
|
-
var
|
|
50
|
+
var _a;
|
|
37
51
|
return {
|
|
38
52
|
code: 1,
|
|
39
|
-
message: `Compilation failure ${(
|
|
53
|
+
message: `Compilation failure ${(_a = this._messageDetails) == null ? void 0 : _a.length} files with Babel.`,
|
|
40
54
|
messageDetails: this._messageDetails
|
|
41
55
|
};
|
|
42
56
|
}
|
|
@@ -44,4 +58,3 @@ class CompilerErrorResult {
|
|
|
44
58
|
return this._messageDetails.length > 0;
|
|
45
59
|
}
|
|
46
60
|
}
|
|
47
|
-
exports.CompilerErrorResult = CompilerErrorResult;
|
|
@@ -1,13 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var stdin_exports = {};
|
|
19
|
+
__export(stdin_exports, {
|
|
20
|
+
defaultDistFileExtMap: () => defaultDistFileExtMap
|
|
5
21
|
});
|
|
6
|
-
exports
|
|
22
|
+
module.exports = __toCommonJS(stdin_exports);
|
|
7
23
|
const defaultDistFileExtMap = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
24
|
+
".js": ".js",
|
|
25
|
+
".jsx": ".js",
|
|
26
|
+
".ts": ".js",
|
|
27
|
+
".tsx": ".js"
|
|
12
28
|
};
|
|
13
|
-
exports.defaultDistFileExtMap = defaultDistFileExtMap;
|
package/dist/js/node/defaults.js
CHANGED
|
@@ -1,23 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var stdin_exports = {};
|
|
19
|
+
__export(stdin_exports, {
|
|
20
|
+
mergeDefaultOption: () => mergeDefaultOption
|
|
5
21
|
});
|
|
6
|
-
exports
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
22
|
+
module.exports = __toCommonJS(stdin_exports);
|
|
23
|
+
var import_constants = require("./constants");
|
|
24
|
+
var __defProp2 = Object.defineProperty;
|
|
25
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
26
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
27
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
28
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
29
|
+
var __spreadValues = (a, b) => {
|
|
30
|
+
for (var prop in b || (b = {}))
|
|
31
|
+
if (__hasOwnProp2.call(b, prop))
|
|
32
|
+
__defNormalProp(a, prop, b[prop]);
|
|
33
|
+
if (__getOwnPropSymbols)
|
|
34
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
35
|
+
if (__propIsEnum.call(b, prop))
|
|
36
|
+
__defNormalProp(a, prop, b[prop]);
|
|
37
|
+
}
|
|
38
|
+
return a;
|
|
39
|
+
};
|
|
11
40
|
const defaultOptions = {
|
|
12
41
|
enableWatch: false,
|
|
13
42
|
enableVirtualDist: false,
|
|
14
43
|
extensions: [],
|
|
15
44
|
filenames: [],
|
|
16
|
-
distFileExtMap:
|
|
45
|
+
distFileExtMap: import_constants.defaultDistFileExtMap,
|
|
17
46
|
ignore: [],
|
|
18
47
|
quiet: false,
|
|
19
48
|
verbose: false,
|
|
20
49
|
clean: false
|
|
21
50
|
};
|
|
22
|
-
const mergeDefaultOption = compilerOptions =>
|
|
23
|
-
exports.mergeDefaultOption = mergeDefaultOption;
|
|
51
|
+
const mergeDefaultOption = (compilerOptions) => __spreadValues(__spreadValues({}, defaultOptions), compilerOptions);
|
|
@@ -1,58 +1,88 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var stdin_exports = {};
|
|
19
|
+
__export(stdin_exports, {
|
|
20
|
+
getFilesFromDir: () => getFilesFromDir,
|
|
21
|
+
getFinalCompilerOption: () => getFinalCompilerOption,
|
|
22
|
+
getFinalExtensions: () => getFinalExtensions,
|
|
23
|
+
getGlobPattern: () => getGlobPattern
|
|
5
24
|
});
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
25
|
+
module.exports = __toCommonJS(stdin_exports);
|
|
26
|
+
var import_utils = require("@modern-js/utils");
|
|
27
|
+
var import_core = require("@babel/core");
|
|
28
|
+
var import_defaults = require("./defaults");
|
|
29
|
+
var __defProp2 = Object.defineProperty;
|
|
30
|
+
var __defProps = Object.defineProperties;
|
|
31
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
32
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
33
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
34
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
35
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
36
|
+
var __spreadValues = (a, b) => {
|
|
37
|
+
for (var prop in b || (b = {}))
|
|
38
|
+
if (__hasOwnProp2.call(b, prop))
|
|
39
|
+
__defNormalProp(a, prop, b[prop]);
|
|
40
|
+
if (__getOwnPropSymbols)
|
|
41
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
42
|
+
if (__propIsEnum.call(b, prop))
|
|
43
|
+
__defNormalProp(a, prop, b[prop]);
|
|
44
|
+
}
|
|
45
|
+
return a;
|
|
46
|
+
};
|
|
47
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
13
48
|
const getGlobPattern = (dir, extensions) => {
|
|
14
49
|
if (extensions.length > 1) {
|
|
15
|
-
return `${dir}/**/*{${extensions.join(
|
|
50
|
+
return `${dir}/**/*{${extensions.join(",")}}`;
|
|
16
51
|
} else if (extensions.length === 1) {
|
|
17
52
|
return `${dir}/**/*${extensions[0]}`;
|
|
18
53
|
} else {
|
|
19
54
|
return `${dir}/**/*`;
|
|
20
55
|
}
|
|
21
56
|
};
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const isExtensionsFunc = ext => typeof ext === 'function';
|
|
57
|
+
const getFinalExtensions = (extensions) => {
|
|
58
|
+
const isExtensions = (ext) => Array.isArray(ext);
|
|
59
|
+
const isExtensionsFunc = (ext) => typeof ext === "function";
|
|
26
60
|
if (isExtensions(extensions)) {
|
|
27
|
-
return [...extensions, ...
|
|
61
|
+
return [...extensions, ...import_core.DEFAULT_EXTENSIONS];
|
|
28
62
|
} else if (isExtensionsFunc(extensions)) {
|
|
29
|
-
return extensions(
|
|
63
|
+
return extensions(import_core.DEFAULT_EXTENSIONS);
|
|
30
64
|
} else {
|
|
31
|
-
return
|
|
65
|
+
return import_core.DEFAULT_EXTENSIONS;
|
|
32
66
|
}
|
|
33
67
|
};
|
|
34
|
-
exports.getFinalExtensions = getFinalExtensions;
|
|
35
68
|
const getFilesFromDir = ({
|
|
36
69
|
dir,
|
|
37
|
-
finalExt
|
|
38
|
-
ignore
|
|
70
|
+
finalExt = [],
|
|
71
|
+
ignore = []
|
|
39
72
|
}) => {
|
|
40
73
|
let globFindFilenames = [];
|
|
41
|
-
const globPattern = getGlobPattern(dir,
|
|
42
|
-
globFindFilenames =
|
|
43
|
-
ignore: _ignore
|
|
44
|
-
});
|
|
74
|
+
const globPattern = getGlobPattern(dir, finalExt);
|
|
75
|
+
globFindFilenames = import_utils.glob.sync(globPattern, { ignore });
|
|
45
76
|
return globFindFilenames;
|
|
46
77
|
};
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
const optionWithDefault = (0, _defaults.mergeDefaultOption)(option);
|
|
78
|
+
const getFinalCompilerOption = (option) => {
|
|
79
|
+
const optionWithDefault = (0, import_defaults.mergeDefaultOption)(option);
|
|
50
80
|
const {
|
|
51
81
|
sourceDir,
|
|
52
82
|
ignore,
|
|
53
83
|
enableWatch = false,
|
|
54
84
|
watchDir,
|
|
55
|
-
extensions =
|
|
85
|
+
extensions = import_core.DEFAULT_EXTENSIONS
|
|
56
86
|
} = option;
|
|
57
87
|
let globFindFilenames = [];
|
|
58
88
|
const finalExt = getFinalExtensions(extensions);
|
|
@@ -64,15 +94,13 @@ const getFinalCompilerOption = option => {
|
|
|
64
94
|
});
|
|
65
95
|
}
|
|
66
96
|
if (enableWatch) {
|
|
67
|
-
// 开启watch模式,清空通过 sourceDir 找到的文件,而改为使用watchDirs
|
|
68
97
|
globFindFilenames = getFilesFromDir({
|
|
69
98
|
dir: watchDir,
|
|
70
99
|
ignore,
|
|
71
100
|
finalExt
|
|
72
101
|
});
|
|
73
102
|
}
|
|
74
|
-
return
|
|
103
|
+
return __spreadProps(__spreadValues({}, optionWithDefault), {
|
|
75
104
|
filenames: [...optionWithDefault.filenames, ...globFindFilenames]
|
|
76
105
|
});
|
|
77
106
|
};
|
|
78
|
-
exports.getFinalCompilerOption = getFinalCompilerOption;
|
package/dist/js/node/index.js
CHANGED
|
@@ -1,48 +1,63 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var stdin_exports = {};
|
|
20
|
+
__export(stdin_exports, {
|
|
21
|
+
compiler: () => compiler
|
|
5
22
|
});
|
|
6
|
-
|
|
7
|
-
|
|
23
|
+
module.exports = __toCommonJS(stdin_exports);
|
|
24
|
+
var import_getFinalOption = require("./getFinalOption");
|
|
25
|
+
var import_build = require("./build");
|
|
26
|
+
var import_buildWatch = require("./buildWatch");
|
|
27
|
+
var import_validate = require("./validate");
|
|
28
|
+
__reExport(stdin_exports, require("./buildWatch"), module.exports);
|
|
29
|
+
__reExport(stdin_exports, require("./type"), module.exports);
|
|
30
|
+
var __async = (__this, __arguments, generator) => {
|
|
31
|
+
return new Promise((resolve, reject) => {
|
|
32
|
+
var fulfilled = (value) => {
|
|
33
|
+
try {
|
|
34
|
+
step(generator.next(value));
|
|
35
|
+
} catch (e) {
|
|
36
|
+
reject(e);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
var rejected = (value) => {
|
|
40
|
+
try {
|
|
41
|
+
step(generator.throw(value));
|
|
42
|
+
} catch (e) {
|
|
43
|
+
reject(e);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
47
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
48
|
+
});
|
|
8
49
|
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
if (key === "default" || key === "__esModule") return;
|
|
15
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
16
|
-
if (key in exports && exports[key] === _buildWatch[key]) return;
|
|
17
|
-
Object.defineProperty(exports, key, {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
get: function () {
|
|
20
|
-
return _buildWatch[key];
|
|
50
|
+
function compiler(_0) {
|
|
51
|
+
return __async(this, arguments, function* (compilerOptions, babelOptions = {}) {
|
|
52
|
+
const validRet = (0, import_validate.validate)(compilerOptions);
|
|
53
|
+
if (validRet) {
|
|
54
|
+
return validRet;
|
|
21
55
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if (key === "default" || key === "__esModule") return;
|
|
28
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
29
|
-
if (key in exports && exports[key] === _type[key]) return;
|
|
30
|
-
Object.defineProperty(exports, key, {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: function () {
|
|
33
|
-
return _type[key];
|
|
56
|
+
const finalCompilerOption = (0, import_getFinalOption.getFinalCompilerOption)(compilerOptions);
|
|
57
|
+
if (compilerOptions.enableWatch) {
|
|
58
|
+
return (0, import_buildWatch.buildWatch)(finalCompilerOption, babelOptions);
|
|
59
|
+
} else {
|
|
60
|
+
return (0, import_build.build)(finalCompilerOption, babelOptions);
|
|
34
61
|
}
|
|
35
62
|
});
|
|
36
|
-
}
|
|
37
|
-
async function compiler(compilerOptions, babelOptions = {}) {
|
|
38
|
-
const validRet = (0, _validate.validate)(compilerOptions);
|
|
39
|
-
if (validRet) {
|
|
40
|
-
return validRet;
|
|
41
|
-
}
|
|
42
|
-
const finalCompilerOption = (0, _getFinalOption.getFinalCompilerOption)(compilerOptions);
|
|
43
|
-
if (compilerOptions.enableWatch) {
|
|
44
|
-
return (0, _buildWatch.buildWatch)(finalCompilerOption, babelOptions);
|
|
45
|
-
} else {
|
|
46
|
-
return (0, _build.build)(finalCompilerOption, babelOptions);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
63
|
+
}
|
package/dist/js/node/utils.js
CHANGED
|
@@ -1,12 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
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
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
var stdin_exports = {};
|
|
25
|
+
__export(stdin_exports, {
|
|
26
|
+
addSourceMappingUrl: () => addSourceMappingUrl
|
|
5
27
|
});
|
|
6
|
-
exports
|
|
7
|
-
var path =
|
|
8
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
9
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
28
|
+
module.exports = __toCommonJS(stdin_exports);
|
|
29
|
+
var path = __toESM(require("path"));
|
|
10
30
|
function addSourceMappingUrl(code, loc) {
|
|
11
|
-
return `${code}
|
|
12
|
-
}
|
|
31
|
+
return `${code}
|
|
32
|
+
//# sourceMappingURL=${path.normalize(path.basename(loc))}`;
|
|
33
|
+
}
|
package/dist/js/node/validate.js
CHANGED
|
@@ -1,23 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var stdin_exports = {};
|
|
19
|
+
__export(stdin_exports, {
|
|
20
|
+
sourceDirAndFileNamesValidMessage: () => sourceDirAndFileNamesValidMessage,
|
|
21
|
+
validate: () => validate,
|
|
22
|
+
validateSourceDirAndFileNames: () => validateSourceDirAndFileNames,
|
|
23
|
+
validateWatchDir: () => validateWatchDir,
|
|
24
|
+
watchDirValidMessage: () => watchDirValidMessage
|
|
5
25
|
});
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
const sourceDirAndFileNamesValidMessage =
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
const validateSourceDirAndFileNames = compilerOptions => {
|
|
13
|
-
const {
|
|
14
|
-
sourceDir,
|
|
15
|
-
filenames,
|
|
16
|
-
quiet
|
|
17
|
-
} = compilerOptions;
|
|
26
|
+
module.exports = __toCommonJS(stdin_exports);
|
|
27
|
+
var import_utils = require("@modern-js/utils");
|
|
28
|
+
const sourceDirAndFileNamesValidMessage = "At least one of the sourceDir and filenames configurations must be configured";
|
|
29
|
+
const watchDirValidMessage = "should set watchDir when enableWatch is true";
|
|
30
|
+
const validateSourceDirAndFileNames = (compilerOptions) => {
|
|
31
|
+
const { sourceDir, filenames, quiet } = compilerOptions;
|
|
18
32
|
if (!sourceDir && !filenames) {
|
|
19
33
|
if (!quiet) {
|
|
20
|
-
|
|
34
|
+
import_utils.logger.error(sourceDirAndFileNamesValidMessage);
|
|
21
35
|
}
|
|
22
36
|
return {
|
|
23
37
|
code: 1,
|
|
@@ -27,30 +41,19 @@ const validateSourceDirAndFileNames = compilerOptions => {
|
|
|
27
41
|
}
|
|
28
42
|
return null;
|
|
29
43
|
};
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
const {
|
|
33
|
-
watchDir,
|
|
34
|
-
enableWatch,
|
|
35
|
-
quiet
|
|
36
|
-
} = compilerOptions;
|
|
44
|
+
const validateWatchDir = (compilerOptions) => {
|
|
45
|
+
const { watchDir, enableWatch, quiet } = compilerOptions;
|
|
37
46
|
if (enableWatch && !watchDir) {
|
|
38
47
|
if (!quiet) {
|
|
39
|
-
|
|
48
|
+
import_utils.logger.error(watchDirValidMessage);
|
|
40
49
|
}
|
|
41
|
-
return {
|
|
42
|
-
code: 1,
|
|
43
|
-
message: watchDirValidMessage,
|
|
44
|
-
virtualDists: []
|
|
45
|
-
};
|
|
50
|
+
return { code: 1, message: watchDirValidMessage, virtualDists: [] };
|
|
46
51
|
}
|
|
47
52
|
return null;
|
|
48
53
|
};
|
|
49
|
-
|
|
50
|
-
const validate = compilerOptions => {
|
|
54
|
+
const validate = (compilerOptions) => {
|
|
51
55
|
if (compilerOptions.enableWatch) {
|
|
52
56
|
return validateWatchDir(compilerOptions);
|
|
53
57
|
}
|
|
54
58
|
return validateSourceDirAndFileNames(compilerOptions);
|
|
55
59
|
};
|
|
56
|
-
exports.validate = validate;
|