@modern-js/babel-compiler 2.14.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 +19 -0
- package/dist/cjs/build.js +16 -47
- package/dist/cjs/buildWatch.js +119 -89
- package/dist/cjs/compiler.js +73 -75
- package/dist/cjs/compilerErrorResult.js +28 -34
- package/dist/cjs/constants.js +7 -25
- package/dist/cjs/defaults.js +9 -27
- package/dist/cjs/getFinalOption.js +33 -50
- package/dist/cjs/index.js +29 -36
- package/dist/cjs/type.js +4 -15
- package/dist/cjs/utils.js +49 -37
- package/dist/cjs/validate.js +21 -33
- package/dist/esm/build.js +217 -210
- package/dist/esm/buildWatch.js +389 -375
- package/dist/esm/compiler.js +118 -119
- package/dist/esm/compilerErrorResult.js +103 -100
- package/dist/esm/constants.js +5 -6
- package/dist/esm/defaults.js +36 -37
- package/dist/esm/getFinalOption.js +124 -116
- package/dist/esm/index.js +154 -148
- package/dist/esm/type.js +1 -1
- package/dist/esm/utils.js +2 -3
- package/dist/esm/validate.js +31 -32
- package/dist/esm-node/build.js +4 -20
- package/dist/esm-node/buildWatch.js +60 -51
- package/dist/esm-node/compiler.js +8 -31
- package/dist/esm-node/compilerErrorResult.js +21 -12
- package/dist/esm-node/constants.js +1 -4
- package/dist/esm-node/defaults.js +1 -4
- package/dist/esm-node/getFinalOption.js +16 -24
- package/dist/esm-node/index.js +1 -4
- package/dist/esm-node/type.js +1 -0
- package/dist/esm-node/utils.js +1 -4
- package/dist/esm-node/validate.js +10 -13
- package/package.json +9 -5
|
@@ -1,137 +1,145 @@
|
|
|
1
|
-
function
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
function _array_like_to_array(arr, len) {
|
|
2
|
+
if (len == null || len > arr.length)
|
|
3
|
+
len = arr.length;
|
|
4
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++)
|
|
5
|
+
arr2[i] = arr[i];
|
|
6
|
+
return arr2;
|
|
5
7
|
}
|
|
6
|
-
function
|
|
7
|
-
|
|
8
|
+
function _array_without_holes(arr) {
|
|
9
|
+
if (Array.isArray(arr))
|
|
10
|
+
return _array_like_to_array(arr);
|
|
8
11
|
}
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
function _define_property(obj, key, value) {
|
|
13
|
+
if (key in obj) {
|
|
14
|
+
Object.defineProperty(obj, key, {
|
|
15
|
+
value,
|
|
16
|
+
enumerable: true,
|
|
17
|
+
configurable: true,
|
|
18
|
+
writable: true
|
|
19
|
+
});
|
|
20
|
+
} else {
|
|
21
|
+
obj[key] = value;
|
|
22
|
+
}
|
|
23
|
+
return obj;
|
|
21
24
|
}
|
|
22
|
-
function
|
|
23
|
-
|
|
25
|
+
function _iterable_to_array(iter) {
|
|
26
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null)
|
|
27
|
+
return Array.from(iter);
|
|
24
28
|
}
|
|
25
|
-
function
|
|
26
|
-
|
|
29
|
+
function _non_iterable_spread() {
|
|
30
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
27
31
|
}
|
|
28
|
-
function
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
ownKeys.forEach(function(key) {
|
|
38
|
-
_defineProperty(target, key, source[key]);
|
|
39
|
-
});
|
|
32
|
+
function _object_spread(target) {
|
|
33
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
34
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
35
|
+
var ownKeys2 = Object.keys(source);
|
|
36
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
37
|
+
ownKeys2 = ownKeys2.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
38
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
39
|
+
}));
|
|
40
40
|
}
|
|
41
|
-
|
|
41
|
+
ownKeys2.forEach(function(key) {
|
|
42
|
+
_define_property(target, key, source[key]);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
return target;
|
|
42
46
|
}
|
|
43
47
|
function ownKeys(object, enumerableOnly) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
keys.push.apply(keys, symbols);
|
|
48
|
+
var keys = Object.keys(object);
|
|
49
|
+
if (Object.getOwnPropertySymbols) {
|
|
50
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
51
|
+
if (enumerableOnly) {
|
|
52
|
+
symbols = symbols.filter(function(sym) {
|
|
53
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
54
|
+
});
|
|
53
55
|
}
|
|
54
|
-
|
|
56
|
+
keys.push.apply(keys, symbols);
|
|
57
|
+
}
|
|
58
|
+
return keys;
|
|
55
59
|
}
|
|
56
|
-
function
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
60
|
+
function _object_spread_props(target, source) {
|
|
61
|
+
source = source != null ? source : {};
|
|
62
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
63
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
64
|
+
} else {
|
|
65
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
66
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
return target;
|
|
66
70
|
}
|
|
67
|
-
function
|
|
68
|
-
|
|
71
|
+
function _to_consumable_array(arr) {
|
|
72
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
69
73
|
}
|
|
70
|
-
function
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
74
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
75
|
+
if (!o)
|
|
76
|
+
return;
|
|
77
|
+
if (typeof o === "string")
|
|
78
|
+
return _array_like_to_array(o, minLen);
|
|
79
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
80
|
+
if (n === "Object" && o.constructor)
|
|
81
|
+
n = o.constructor.name;
|
|
82
|
+
if (n === "Map" || n === "Set")
|
|
83
|
+
return Array.from(n);
|
|
84
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
|
|
85
|
+
return _array_like_to_array(o, minLen);
|
|
77
86
|
}
|
|
78
87
|
import { glob } from "@modern-js/utils";
|
|
79
88
|
import { DEFAULT_EXTENSIONS } from "@babel/core";
|
|
80
89
|
import { mergeDefaultOption } from "./defaults";
|
|
81
|
-
var getGlobPattern = function(dir, extensions) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
90
|
+
export var getGlobPattern = function(dir, extensions) {
|
|
91
|
+
if (extensions.length > 1) {
|
|
92
|
+
return "".concat(dir, "/**/*{").concat(extensions.join(","), "}");
|
|
93
|
+
} else if (extensions.length === 1) {
|
|
94
|
+
return "".concat(dir, "/**/*").concat(extensions[0]);
|
|
95
|
+
} else {
|
|
96
|
+
return "".concat(dir, "/**/*");
|
|
97
|
+
}
|
|
89
98
|
};
|
|
90
|
-
var getFinalExtensions = function(extensions) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
99
|
+
export var getFinalExtensions = function(extensions) {
|
|
100
|
+
var isExtensions = function(ext) {
|
|
101
|
+
return Array.isArray(ext);
|
|
102
|
+
};
|
|
103
|
+
var isExtensionsFunc = function(ext) {
|
|
104
|
+
return typeof ext === "function";
|
|
105
|
+
};
|
|
106
|
+
if (isExtensions(extensions)) {
|
|
107
|
+
return _to_consumable_array(extensions).concat(_to_consumable_array(DEFAULT_EXTENSIONS));
|
|
108
|
+
} else if (isExtensionsFunc(extensions)) {
|
|
109
|
+
return extensions(DEFAULT_EXTENSIONS);
|
|
110
|
+
} else {
|
|
111
|
+
return DEFAULT_EXTENSIONS;
|
|
112
|
+
}
|
|
104
113
|
};
|
|
105
|
-
var getFilesFromDir = function(param) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
114
|
+
export var getFilesFromDir = function(param) {
|
|
115
|
+
var dir = param.dir, _param_finalExt = param.finalExt, finalExt = _param_finalExt === void 0 ? [] : _param_finalExt, _param_ignore = param.ignore, ignore = _param_ignore === void 0 ? [] : _param_ignore;
|
|
116
|
+
var globFindFilenames = [];
|
|
117
|
+
var globPattern = getGlobPattern(dir, finalExt);
|
|
118
|
+
globFindFilenames = glob.sync(globPattern, {
|
|
119
|
+
ignore
|
|
120
|
+
});
|
|
121
|
+
return globFindFilenames;
|
|
113
122
|
};
|
|
114
|
-
var getFinalCompilerOption = function(option) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
return _objectSpreadProps(_objectSpread({}, optionWithDefault), {
|
|
134
|
-
filenames: _toConsumableArray(optionWithDefault.filenames).concat(_toConsumableArray(globFindFilenames))
|
|
123
|
+
export var getFinalCompilerOption = function(option) {
|
|
124
|
+
var optionWithDefault = mergeDefaultOption(option);
|
|
125
|
+
var sourceDir = option.sourceDir, ignore = option.ignore, _option_enableWatch = option.enableWatch, enableWatch = _option_enableWatch === void 0 ? false : _option_enableWatch, watchDir = option.watchDir, _option_extensions = option.extensions, extensions = _option_extensions === void 0 ? DEFAULT_EXTENSIONS : _option_extensions;
|
|
126
|
+
var globFindFilenames = [];
|
|
127
|
+
var finalExt = getFinalExtensions(extensions);
|
|
128
|
+
if (sourceDir) {
|
|
129
|
+
globFindFilenames = getFilesFromDir({
|
|
130
|
+
dir: sourceDir,
|
|
131
|
+
ignore,
|
|
132
|
+
finalExt
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
if (enableWatch) {
|
|
136
|
+
globFindFilenames = getFilesFromDir({
|
|
137
|
+
dir: watchDir,
|
|
138
|
+
ignore,
|
|
139
|
+
finalExt
|
|
135
140
|
});
|
|
141
|
+
}
|
|
142
|
+
return _object_spread_props(_object_spread({}, optionWithDefault), {
|
|
143
|
+
filenames: _to_consumable_array(optionWithDefault.filenames).concat(_to_consumable_array(globFindFilenames))
|
|
144
|
+
});
|
|
136
145
|
};
|
|
137
|
-
export { getFilesFromDir, getFinalCompilerOption, getFinalExtensions, getGlobPattern };
|
package/dist/esm/index.js
CHANGED
|
@@ -1,166 +1,172 @@
|
|
|
1
1
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
2
|
+
try {
|
|
3
|
+
var info = gen[key](arg);
|
|
4
|
+
var value = info.value;
|
|
5
|
+
} catch (error) {
|
|
6
|
+
reject(error);
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
if (info.done) {
|
|
10
|
+
resolve(value);
|
|
11
|
+
} else {
|
|
12
|
+
Promise.resolve(value).then(_next, _throw);
|
|
13
|
+
}
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
15
|
+
function _async_to_generator(fn) {
|
|
16
|
+
return function() {
|
|
17
|
+
var self = this, args = arguments;
|
|
18
|
+
return new Promise(function(resolve, reject) {
|
|
19
|
+
var gen = fn.apply(self, args);
|
|
20
|
+
function _next(value) {
|
|
21
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
22
|
+
}
|
|
23
|
+
function _throw(err) {
|
|
24
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
25
|
+
}
|
|
26
|
+
_next(void 0);
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
29
|
}
|
|
30
|
-
var __generator =
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
30
|
+
var __generator = function(thisArg, body) {
|
|
31
|
+
var f, y, t, g, _ = {
|
|
32
|
+
label: 0,
|
|
33
|
+
sent: function() {
|
|
34
|
+
if (t[0] & 1)
|
|
35
|
+
throw t[1];
|
|
36
|
+
return t[1];
|
|
37
|
+
},
|
|
38
|
+
trys: [],
|
|
39
|
+
ops: []
|
|
40
|
+
};
|
|
41
|
+
return g = {
|
|
42
|
+
next: verb(0),
|
|
43
|
+
"throw": verb(1),
|
|
44
|
+
"return": verb(2)
|
|
45
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
46
|
+
return this;
|
|
47
|
+
}), g;
|
|
48
|
+
function verb(n) {
|
|
49
|
+
return function(v) {
|
|
50
|
+
return step([
|
|
51
|
+
n,
|
|
52
|
+
v
|
|
53
|
+
]);
|
|
39
54
|
};
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
break;
|
|
68
|
-
case 4:
|
|
69
|
-
_.label++;
|
|
70
|
-
return {
|
|
71
|
-
value: op[1],
|
|
72
|
-
done: false
|
|
73
|
-
};
|
|
74
|
-
case 5:
|
|
75
|
-
_.label++;
|
|
76
|
-
y = op[1];
|
|
77
|
-
op = [
|
|
78
|
-
0
|
|
79
|
-
];
|
|
80
|
-
continue;
|
|
81
|
-
case 7:
|
|
82
|
-
op = _.ops.pop();
|
|
83
|
-
_.trys.pop();
|
|
84
|
-
continue;
|
|
85
|
-
default:
|
|
86
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
87
|
-
_ = 0;
|
|
88
|
-
continue;
|
|
89
|
-
}
|
|
90
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
91
|
-
_.label = op[1];
|
|
92
|
-
break;
|
|
93
|
-
}
|
|
94
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
95
|
-
_.label = t[1];
|
|
96
|
-
t = op;
|
|
97
|
-
break;
|
|
98
|
-
}
|
|
99
|
-
if (t && _.label < t[2]) {
|
|
100
|
-
_.label = t[2];
|
|
101
|
-
_.ops.push(op);
|
|
102
|
-
break;
|
|
103
|
-
}
|
|
104
|
-
if (t[2]) _.ops.pop();
|
|
105
|
-
_.trys.pop();
|
|
106
|
-
continue;
|
|
107
|
-
}
|
|
108
|
-
op = body.call(thisArg, _);
|
|
109
|
-
} catch (e) {
|
|
55
|
+
}
|
|
56
|
+
function step(op) {
|
|
57
|
+
if (f)
|
|
58
|
+
throw new TypeError("Generator is already executing.");
|
|
59
|
+
while (_)
|
|
60
|
+
try {
|
|
61
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
|
|
62
|
+
return t;
|
|
63
|
+
if (y = 0, t)
|
|
64
|
+
op = [
|
|
65
|
+
op[0] & 2,
|
|
66
|
+
t.value
|
|
67
|
+
];
|
|
68
|
+
switch (op[0]) {
|
|
69
|
+
case 0:
|
|
70
|
+
case 1:
|
|
71
|
+
t = op;
|
|
72
|
+
break;
|
|
73
|
+
case 4:
|
|
74
|
+
_.label++;
|
|
75
|
+
return {
|
|
76
|
+
value: op[1],
|
|
77
|
+
done: false
|
|
78
|
+
};
|
|
79
|
+
case 5:
|
|
80
|
+
_.label++;
|
|
81
|
+
y = op[1];
|
|
110
82
|
op = [
|
|
111
|
-
|
|
112
|
-
e
|
|
83
|
+
0
|
|
113
84
|
];
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
85
|
+
continue;
|
|
86
|
+
case 7:
|
|
87
|
+
op = _.ops.pop();
|
|
88
|
+
_.trys.pop();
|
|
89
|
+
continue;
|
|
90
|
+
default:
|
|
91
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
92
|
+
_ = 0;
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
96
|
+
_.label = op[1];
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
100
|
+
_.label = t[1];
|
|
101
|
+
t = op;
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
if (t && _.label < t[2]) {
|
|
105
|
+
_.label = t[2];
|
|
106
|
+
_.ops.push(op);
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
if (t[2])
|
|
110
|
+
_.ops.pop();
|
|
111
|
+
_.trys.pop();
|
|
112
|
+
continue;
|
|
117
113
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
114
|
+
op = body.call(thisArg, _);
|
|
115
|
+
} catch (e) {
|
|
116
|
+
op = [
|
|
117
|
+
6,
|
|
118
|
+
e
|
|
119
|
+
];
|
|
120
|
+
y = 0;
|
|
121
|
+
} finally {
|
|
122
|
+
f = t = 0;
|
|
123
|
+
}
|
|
124
|
+
if (op[0] & 5)
|
|
125
|
+
throw op[1];
|
|
126
|
+
return {
|
|
127
|
+
value: op[0] ? op[1] : void 0,
|
|
128
|
+
done: true
|
|
129
|
+
};
|
|
130
|
+
}
|
|
124
131
|
};
|
|
125
132
|
import { getFinalCompilerOption } from "./getFinalOption";
|
|
126
133
|
import { build } from "./build";
|
|
127
134
|
import { buildWatch } from "./buildWatch";
|
|
128
135
|
import { validate } from "./validate";
|
|
129
|
-
function compiler(compilerOptions) {
|
|
130
|
-
|
|
136
|
+
export function compiler(compilerOptions) {
|
|
137
|
+
return _compiler.apply(this, arguments);
|
|
131
138
|
}
|
|
132
139
|
function _compiler() {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
});
|
|
140
|
+
_compiler = _async_to_generator(function(compilerOptions) {
|
|
141
|
+
var babelOptions, validRet, finalCompilerOption;
|
|
142
|
+
var _arguments = arguments;
|
|
143
|
+
return __generator(this, function(_state) {
|
|
144
|
+
babelOptions = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {};
|
|
145
|
+
validRet = validate(compilerOptions);
|
|
146
|
+
if (validRet) {
|
|
147
|
+
return [
|
|
148
|
+
2,
|
|
149
|
+
validRet
|
|
150
|
+
];
|
|
151
|
+
}
|
|
152
|
+
finalCompilerOption = getFinalCompilerOption(compilerOptions);
|
|
153
|
+
if (compilerOptions.enableWatch) {
|
|
154
|
+
return [
|
|
155
|
+
2,
|
|
156
|
+
buildWatch(finalCompilerOption, babelOptions)
|
|
157
|
+
];
|
|
158
|
+
} else {
|
|
159
|
+
return [
|
|
160
|
+
2,
|
|
161
|
+
build(finalCompilerOption, babelOptions)
|
|
162
|
+
];
|
|
163
|
+
}
|
|
164
|
+
return [
|
|
165
|
+
2
|
|
166
|
+
];
|
|
161
167
|
});
|
|
162
|
-
|
|
168
|
+
});
|
|
169
|
+
return _compiler.apply(this, arguments);
|
|
163
170
|
}
|
|
164
171
|
export * from "./buildWatch";
|
|
165
172
|
export * from "./type";
|
|
166
|
-
export { compiler };
|
package/dist/esm/type.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export {};
|
package/dist/esm/utils.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as path from "path";
|
|
2
|
-
function addSourceMappingUrl(code, loc) {
|
|
3
|
-
|
|
2
|
+
export function addSourceMappingUrl(code, loc) {
|
|
3
|
+
return "".concat(code, "\n//# sourceMappingURL=").concat(path.normalize(path.basename(loc)));
|
|
4
4
|
}
|
|
5
|
-
export { addSourceMappingUrl };
|
package/dist/esm/validate.js
CHANGED
|
@@ -1,38 +1,37 @@
|
|
|
1
1
|
import { logger } from "@modern-js/utils";
|
|
2
|
-
var sourceDirAndFileNamesValidMessage = "At least one of the sourceDir and filenames configurations must be configured";
|
|
3
|
-
var watchDirValidMessage = "should set watchDir when enableWatch is true";
|
|
4
|
-
var validateSourceDirAndFileNames = function(compilerOptions) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
return {
|
|
11
|
-
code: 1,
|
|
12
|
-
message: sourceDirAndFileNamesValidMessage,
|
|
13
|
-
virtualDists: []
|
|
14
|
-
};
|
|
2
|
+
export var sourceDirAndFileNamesValidMessage = "At least one of the sourceDir and filenames configurations must be configured";
|
|
3
|
+
export var watchDirValidMessage = "should set watchDir when enableWatch is true";
|
|
4
|
+
export var validateSourceDirAndFileNames = function(compilerOptions) {
|
|
5
|
+
var sourceDir = compilerOptions.sourceDir, filenames = compilerOptions.filenames, quiet = compilerOptions.quiet;
|
|
6
|
+
if (!sourceDir && !filenames) {
|
|
7
|
+
if (!quiet) {
|
|
8
|
+
logger.error(sourceDirAndFileNamesValidMessage);
|
|
15
9
|
}
|
|
16
|
-
return
|
|
10
|
+
return {
|
|
11
|
+
code: 1,
|
|
12
|
+
message: sourceDirAndFileNamesValidMessage,
|
|
13
|
+
virtualDists: []
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
return null;
|
|
17
17
|
};
|
|
18
|
-
var validateWatchDir = function(compilerOptions) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
return {
|
|
25
|
-
code: 1,
|
|
26
|
-
message: watchDirValidMessage,
|
|
27
|
-
virtualDists: []
|
|
28
|
-
};
|
|
18
|
+
export var validateWatchDir = function(compilerOptions) {
|
|
19
|
+
var watchDir = compilerOptions.watchDir, enableWatch = compilerOptions.enableWatch, quiet = compilerOptions.quiet;
|
|
20
|
+
if (enableWatch && !watchDir) {
|
|
21
|
+
if (!quiet) {
|
|
22
|
+
logger.error(watchDirValidMessage);
|
|
29
23
|
}
|
|
30
|
-
return
|
|
24
|
+
return {
|
|
25
|
+
code: 1,
|
|
26
|
+
message: watchDirValidMessage,
|
|
27
|
+
virtualDists: []
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
return null;
|
|
31
31
|
};
|
|
32
|
-
var validate = function(compilerOptions) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
export var validate = function(compilerOptions) {
|
|
33
|
+
if (compilerOptions.enableWatch) {
|
|
34
|
+
return validateWatchDir(compilerOptions);
|
|
35
|
+
}
|
|
36
|
+
return validateSourceDirAndFileNames(compilerOptions);
|
|
37
37
|
};
|
|
38
|
-
export { sourceDirAndFileNamesValidMessage, validate, validateSourceDirAndFileNames, validateWatchDir, watchDirValidMessage };
|