@modern-js/babel-compiler 2.4.0 → 2.5.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 +15 -0
- package/dist/{js/node → cjs}/build.js +3 -23
- package/dist/{js/node → cjs}/buildWatch.js +15 -53
- package/dist/{js/node → cjs}/compiler.js +12 -25
- package/dist/{js/node → cjs}/compilerErrorResult.js +0 -0
- package/dist/{js/node → cjs}/constants.js +0 -0
- package/dist/{js/node → cjs}/defaults.js +4 -15
- package/dist/{js/node → cjs}/getFinalOption.js +3 -19
- package/dist/{js/node → cjs}/index.js +11 -33
- package/dist/{js/node → cjs}/type.js +0 -0
- package/dist/{js/node → cjs}/utils.js +0 -0
- package/dist/{js/node → cjs}/validate.js +0 -0
- package/dist/{js/treeshaking → esm}/build.js +2 -2
- package/dist/{js/treeshaking → esm}/buildWatch.js +2 -2
- package/dist/{js/treeshaking → esm}/compiler.js +2 -2
- package/dist/{js/treeshaking → esm}/compilerErrorResult.js +2 -2
- package/dist/{js/treeshaking → esm}/constants.js +0 -0
- package/dist/{js/treeshaking → esm}/defaults.js +0 -0
- package/dist/{js/treeshaking → esm}/getFinalOption.js +2 -2
- package/dist/{js/treeshaking → esm}/index.js +0 -0
- package/dist/{js/treeshaking → esm}/type.js +0 -0
- package/dist/{js/treeshaking → esm}/utils.js +0 -0
- package/dist/{js/treeshaking → esm}/validate.js +0 -0
- package/dist/{js/modern → esm-node}/build.js +3 -23
- package/dist/{js/modern → esm-node}/buildWatch.js +15 -55
- package/dist/{js/modern → esm-node}/compiler.js +12 -27
- package/dist/{js/modern → esm-node}/compilerErrorResult.js +0 -0
- package/dist/{js/modern → esm-node}/constants.js +0 -0
- package/dist/esm-node/defaults.js +19 -0
- package/dist/{js/modern → esm-node}/getFinalOption.js +3 -21
- package/dist/esm-node/index.js +21 -0
- package/dist/{js/modern → esm-node}/type.js +0 -0
- package/dist/{js/modern → esm-node}/utils.js +0 -0
- package/dist/{js/modern → esm-node}/validate.js +0 -0
- package/package.json +9 -10
- package/dist/js/modern/defaults.js +0 -32
- package/dist/js/modern/index.js +0 -43
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @modern-js/babel-compiler
|
|
2
2
|
|
|
3
|
+
## 2.5.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 89ca6cc: refactor: merge build-config into scripts/build
|
|
8
|
+
|
|
9
|
+
refactor: 把 build-config 合并进 scripts/build
|
|
10
|
+
|
|
11
|
+
- 30614fa: chore: modify package.json entry fields and build config
|
|
12
|
+
chore: 更改 package.json entry 字段以及构建配置
|
|
13
|
+
- Updated dependencies [30614fa]
|
|
14
|
+
- Updated dependencies [1b0ce87]
|
|
15
|
+
- Updated dependencies [11c053b]
|
|
16
|
+
- @modern-js/utils@2.5.0
|
|
17
|
+
|
|
3
18
|
## 2.4.0
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -15,26 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
15
|
return to;
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var __async = (__this, __arguments, generator) => {
|
|
19
|
-
return new Promise((resolve, reject) => {
|
|
20
|
-
var fulfilled = (value) => {
|
|
21
|
-
try {
|
|
22
|
-
step(generator.next(value));
|
|
23
|
-
} catch (e) {
|
|
24
|
-
reject(e);
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
var rejected = (value) => {
|
|
28
|
-
try {
|
|
29
|
-
step(generator.throw(value));
|
|
30
|
-
} catch (e) {
|
|
31
|
-
reject(e);
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
35
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
18
|
var build_exports = {};
|
|
39
19
|
__export(build_exports, {
|
|
40
20
|
build: () => build
|
|
@@ -43,7 +23,7 @@ module.exports = __toCommonJS(build_exports);
|
|
|
43
23
|
var import_utils = require("@modern-js/utils");
|
|
44
24
|
var import_constants = require("./constants");
|
|
45
25
|
var import_compiler = require("./compiler");
|
|
46
|
-
const build =
|
|
26
|
+
const build = async (option, babelConfig = {}) => {
|
|
47
27
|
const {
|
|
48
28
|
rootDir,
|
|
49
29
|
enableVirtualDist,
|
|
@@ -56,7 +36,7 @@ const build = (_0, ..._1) => __async(void 0, [_0, ..._1], function* (option, bab
|
|
|
56
36
|
} = option;
|
|
57
37
|
const virtualDists = [];
|
|
58
38
|
if (clean) {
|
|
59
|
-
|
|
39
|
+
await import_utils.fs.remove(distDir);
|
|
60
40
|
}
|
|
61
41
|
import_utils.fs.ensureDir(distDir);
|
|
62
42
|
const messageDetails = [];
|
|
@@ -106,7 +86,7 @@ const build = (_0, ..._1) => __async(void 0, [_0, ..._1], function* (option, bab
|
|
|
106
86
|
message: `Successfully compiled ${filenames.length} ${filenames.length !== 1 ? "files" : "file"} with Babel.`,
|
|
107
87
|
virtualDists
|
|
108
88
|
};
|
|
109
|
-
}
|
|
89
|
+
};
|
|
110
90
|
// Annotate the CommonJS export names for ESM import in node:
|
|
111
91
|
0 && (module.exports = {
|
|
112
92
|
build
|
|
@@ -1,26 +1,9 @@
|
|
|
1
1
|
var __create = Object.create;
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
-
var __defProps = Object.defineProperties;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
9
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
-
var __spreadValues = (a, b) => {
|
|
13
|
-
for (var prop in b || (b = {}))
|
|
14
|
-
if (__hasOwnProp.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
if (__getOwnPropSymbols)
|
|
17
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
-
if (__propIsEnum.call(b, prop))
|
|
19
|
-
__defNormalProp(a, prop, b[prop]);
|
|
20
|
-
}
|
|
21
|
-
return a;
|
|
22
|
-
};
|
|
23
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
7
|
var __export = (target, all) => {
|
|
25
8
|
for (var name in all)
|
|
26
9
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -38,26 +21,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
38
21
|
mod
|
|
39
22
|
));
|
|
40
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
41
|
-
var __async = (__this, __arguments, generator) => {
|
|
42
|
-
return new Promise((resolve, reject) => {
|
|
43
|
-
var fulfilled = (value) => {
|
|
44
|
-
try {
|
|
45
|
-
step(generator.next(value));
|
|
46
|
-
} catch (e) {
|
|
47
|
-
reject(e);
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
var rejected = (value) => {
|
|
51
|
-
try {
|
|
52
|
-
step(generator.throw(value));
|
|
53
|
-
} catch (e) {
|
|
54
|
-
reject(e);
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
58
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
59
|
-
});
|
|
60
|
-
};
|
|
61
24
|
var buildWatch_exports = {};
|
|
62
25
|
__export(buildWatch_exports, {
|
|
63
26
|
BuildWatchEmitter: () => BuildWatchEmitter,
|
|
@@ -80,21 +43,19 @@ class BuildWatchEmitter extends Event.EventEmitter {
|
|
|
80
43
|
setInitFn(fn) {
|
|
81
44
|
this._initFn = fn;
|
|
82
45
|
}
|
|
83
|
-
watch() {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
return null;
|
|
89
|
-
});
|
|
46
|
+
async watch() {
|
|
47
|
+
if (typeof this._initFn === "function") {
|
|
48
|
+
return this._initFn(this);
|
|
49
|
+
}
|
|
50
|
+
return null;
|
|
90
51
|
}
|
|
91
52
|
}
|
|
92
|
-
const runBuildWatch =
|
|
53
|
+
const runBuildWatch = async (option, babelConfig = {}, emitter) => {
|
|
93
54
|
emitter.emit(BuildWatchEvent.compiling);
|
|
94
55
|
const errorResult = new import_compilerErrorResult.CompilerErrorResult();
|
|
95
56
|
const watchDir = option.watchDir;
|
|
96
57
|
const { distDir, quiet } = option;
|
|
97
|
-
const firstBuildResult =
|
|
58
|
+
const firstBuildResult = await (0, import_build.build)(option, babelConfig);
|
|
98
59
|
const { code } = firstBuildResult;
|
|
99
60
|
if (code === 1) {
|
|
100
61
|
errorResult.init(firstBuildResult);
|
|
@@ -104,7 +65,7 @@ const runBuildWatch = (_0, ..._1) => __async(void 0, [_0, ..._1], function* (opt
|
|
|
104
65
|
}
|
|
105
66
|
return (0, import_utils.watch)(
|
|
106
67
|
`${watchDir}/**/*.{js,jsx,ts,tsx}`,
|
|
107
|
-
|
|
68
|
+
async ({ changeType, changedFilePath }) => {
|
|
108
69
|
emitter.emit(BuildWatchEvent.compiling);
|
|
109
70
|
if (changeType === import_utils.WatchChangeType.UNLINK) {
|
|
110
71
|
const removeFiles = [
|
|
@@ -123,8 +84,8 @@ const runBuildWatch = (_0, ..._1) => __async(void 0, [_0, ..._1], function* (opt
|
|
|
123
84
|
emitter.emit(BuildWatchEvent.watchingCompiler, result2);
|
|
124
85
|
return;
|
|
125
86
|
}
|
|
126
|
-
const result =
|
|
127
|
-
|
|
87
|
+
const result = await (0, import_build.build)(
|
|
88
|
+
{ ...option, filenames: [changedFilePath] },
|
|
128
89
|
babelConfig
|
|
129
90
|
);
|
|
130
91
|
if (result.code === 1) {
|
|
@@ -134,19 +95,20 @@ const runBuildWatch = (_0, ..._1) => __async(void 0, [_0, ..._1], function* (opt
|
|
|
134
95
|
} else {
|
|
135
96
|
errorResult.removeByFileName(changedFilePath);
|
|
136
97
|
if (errorResult.checkExistError()) {
|
|
137
|
-
emitter.emit(BuildWatchEvent.watchingCompiler,
|
|
98
|
+
emitter.emit(BuildWatchEvent.watchingCompiler, {
|
|
99
|
+
...errorResult.value,
|
|
138
100
|
virtualDists: result.virtualDists
|
|
139
|
-
})
|
|
101
|
+
});
|
|
140
102
|
!quiet && import_utils.logger.info(errorResult.value.message);
|
|
141
103
|
} else {
|
|
142
104
|
emitter.emit(BuildWatchEvent.watchingCompiler, result);
|
|
143
105
|
!quiet && import_utils.logger.info(result.message);
|
|
144
106
|
}
|
|
145
107
|
}
|
|
146
|
-
}
|
|
108
|
+
},
|
|
147
109
|
[`${watchDir}/**/*.d.ts`]
|
|
148
110
|
);
|
|
149
|
-
}
|
|
111
|
+
};
|
|
150
112
|
const buildWatch = (option, babelConfig = {}) => {
|
|
151
113
|
const buildWatchEmitter = new BuildWatchEmitter();
|
|
152
114
|
buildWatchEmitter.setInitFn(runBuildWatch.bind(null, option, babelConfig));
|
|
@@ -1,26 +1,9 @@
|
|
|
1
1
|
var __create = Object.create;
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
-
var __defProps = Object.defineProperties;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
9
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
-
var __spreadValues = (a, b) => {
|
|
13
|
-
for (var prop in b || (b = {}))
|
|
14
|
-
if (__hasOwnProp.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
if (__getOwnPropSymbols)
|
|
17
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
-
if (__propIsEnum.call(b, prop))
|
|
19
|
-
__defNormalProp(a, prop, b[prop]);
|
|
20
|
-
}
|
|
21
|
-
return a;
|
|
22
|
-
};
|
|
23
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
7
|
var __export = (target, all) => {
|
|
25
8
|
for (var name in all)
|
|
26
9
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -119,12 +102,15 @@ const compiler = (option) => {
|
|
|
119
102
|
}
|
|
120
103
|
if ((babelRes == null ? void 0 : babelRes.map) && babelConfig.sourceMaps && babelConfig.sourceMaps !== "inline") {
|
|
121
104
|
if (virtualDist) {
|
|
122
|
-
virtualDist =
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
105
|
+
virtualDist = {
|
|
106
|
+
...virtualDist,
|
|
107
|
+
...resolveSourceMap({
|
|
108
|
+
babelRes,
|
|
109
|
+
sourceFilePath: filepath,
|
|
110
|
+
distFilePath,
|
|
111
|
+
enableVirtualDist
|
|
112
|
+
})
|
|
113
|
+
};
|
|
128
114
|
} else {
|
|
129
115
|
resolveSourceMap({
|
|
130
116
|
babelRes,
|
|
@@ -135,10 +121,11 @@ const compiler = (option) => {
|
|
|
135
121
|
}
|
|
136
122
|
}
|
|
137
123
|
if (virtualDist) {
|
|
138
|
-
virtualDist =
|
|
124
|
+
virtualDist = {
|
|
125
|
+
...virtualDist,
|
|
139
126
|
distPath: distFilePath,
|
|
140
127
|
code: babelRes.code
|
|
141
|
-
}
|
|
128
|
+
};
|
|
142
129
|
} else {
|
|
143
130
|
import_utils.fs.ensureDirSync(path.dirname(distFilePath));
|
|
144
131
|
import_utils.fs.writeFileSync(distFilePath, babelRes.code);
|
|
File without changes
|
|
File without changes
|
|
@@ -1,21 +1,7 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
5
|
var __export = (target, all) => {
|
|
20
6
|
for (var name in all)
|
|
21
7
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -46,7 +32,10 @@ const defaultOptions = {
|
|
|
46
32
|
verbose: false,
|
|
47
33
|
clean: false
|
|
48
34
|
};
|
|
49
|
-
const mergeDefaultOption = (compilerOptions) =>
|
|
35
|
+
const mergeDefaultOption = (compilerOptions) => ({
|
|
36
|
+
...defaultOptions,
|
|
37
|
+
...compilerOptions
|
|
38
|
+
});
|
|
50
39
|
// Annotate the CommonJS export names for ESM import in node:
|
|
51
40
|
0 && (module.exports = {
|
|
52
41
|
mergeDefaultOption
|
|
@@ -1,24 +1,7 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
5
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
7
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
-
var __spreadValues = (a, b) => {
|
|
11
|
-
for (var prop in b || (b = {}))
|
|
12
|
-
if (__hasOwnProp.call(b, prop))
|
|
13
|
-
__defNormalProp(a, prop, b[prop]);
|
|
14
|
-
if (__getOwnPropSymbols)
|
|
15
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
16
|
-
if (__propIsEnum.call(b, prop))
|
|
17
|
-
__defNormalProp(a, prop, b[prop]);
|
|
18
|
-
}
|
|
19
|
-
return a;
|
|
20
|
-
};
|
|
21
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
22
5
|
var __export = (target, all) => {
|
|
23
6
|
for (var name in all)
|
|
24
7
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -98,9 +81,10 @@ const getFinalCompilerOption = (option) => {
|
|
|
98
81
|
finalExt
|
|
99
82
|
});
|
|
100
83
|
}
|
|
101
|
-
return
|
|
84
|
+
return {
|
|
85
|
+
...optionWithDefault,
|
|
102
86
|
filenames: [...optionWithDefault.filenames, ...globFindFilenames]
|
|
103
|
-
}
|
|
87
|
+
};
|
|
104
88
|
};
|
|
105
89
|
// Annotate the CommonJS export names for ESM import in node:
|
|
106
90
|
0 && (module.exports = {
|
|
@@ -16,26 +16,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
};
|
|
17
17
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var __async = (__this, __arguments, generator) => {
|
|
20
|
-
return new Promise((resolve, reject) => {
|
|
21
|
-
var fulfilled = (value) => {
|
|
22
|
-
try {
|
|
23
|
-
step(generator.next(value));
|
|
24
|
-
} catch (e) {
|
|
25
|
-
reject(e);
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
var rejected = (value) => {
|
|
29
|
-
try {
|
|
30
|
-
step(generator.throw(value));
|
|
31
|
-
} catch (e) {
|
|
32
|
-
reject(e);
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
36
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
37
|
-
});
|
|
38
|
-
};
|
|
39
19
|
var src_exports = {};
|
|
40
20
|
__export(src_exports, {
|
|
41
21
|
compiler: () => compiler
|
|
@@ -47,19 +27,17 @@ var import_buildWatch = require("./buildWatch");
|
|
|
47
27
|
var import_validate = require("./validate");
|
|
48
28
|
__reExport(src_exports, require("./buildWatch"), module.exports);
|
|
49
29
|
__reExport(src_exports, require("./type"), module.exports);
|
|
50
|
-
function compiler(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
});
|
|
30
|
+
async function compiler(compilerOptions, babelOptions = {}) {
|
|
31
|
+
const validRet = (0, import_validate.validate)(compilerOptions);
|
|
32
|
+
if (validRet) {
|
|
33
|
+
return validRet;
|
|
34
|
+
}
|
|
35
|
+
const finalCompilerOption = (0, import_getFinalOption.getFinalCompilerOption)(compilerOptions);
|
|
36
|
+
if (compilerOptions.enableWatch) {
|
|
37
|
+
return (0, import_buildWatch.buildWatch)(finalCompilerOption, babelOptions);
|
|
38
|
+
} else {
|
|
39
|
+
return (0, import_build.build)(finalCompilerOption, babelOptions);
|
|
40
|
+
}
|
|
63
41
|
}
|
|
64
42
|
// Annotate the CommonJS export names for ESM import in node:
|
|
65
43
|
0 && (module.exports = {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -127,13 +127,13 @@ import { defaultDistFileExtMap } from "./constants";
|
|
|
127
127
|
import { compiler } from "./compiler";
|
|
128
128
|
var build = function() {
|
|
129
129
|
var _ref = _asyncToGenerator(function(option) {
|
|
130
|
-
var babelConfig, rootDir, enableVirtualDist, filenames, clean, distDir,
|
|
130
|
+
var babelConfig, rootDir, enableVirtualDist, filenames, clean, distDir, _option_distFileExtMap, distFileExtMap, _option_verbose, verbose, _option_quiet, quiet, virtualDists, messageDetails, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, filename, dist, happenError;
|
|
131
131
|
var _arguments = arguments;
|
|
132
132
|
return __generator(this, function(_state) {
|
|
133
133
|
switch(_state.label){
|
|
134
134
|
case 0:
|
|
135
135
|
babelConfig = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {};
|
|
136
|
-
rootDir = option.rootDir, enableVirtualDist = option.enableVirtualDist, filenames = option.filenames, clean = option.clean, distDir = option.distDir,
|
|
136
|
+
rootDir = option.rootDir, enableVirtualDist = option.enableVirtualDist, filenames = option.filenames, clean = option.clean, distDir = option.distDir, _option_distFileExtMap = option.distFileExtMap, distFileExtMap = _option_distFileExtMap === void 0 ? defaultDistFileExtMap : _option_distFileExtMap, _option_verbose = option.verbose, verbose = _option_verbose === void 0 ? false : _option_verbose, _option_quiet = option.quiet, quiet = _option_quiet === void 0 ? false : _option_quiet;
|
|
137
137
|
virtualDists = [];
|
|
138
138
|
if (!clean) return [
|
|
139
139
|
3,
|
|
@@ -269,9 +269,9 @@ var BuildWatchEvent = {
|
|
|
269
269
|
compiling: "compiling",
|
|
270
270
|
watchingCompiler: "watching-compiler"
|
|
271
271
|
};
|
|
272
|
-
var BuildWatchEmitter = /*#__PURE__*/ function(
|
|
272
|
+
var BuildWatchEmitter = /*#__PURE__*/ function(_Event_EventEmitter) {
|
|
273
273
|
"use strict";
|
|
274
|
-
_inherits(BuildWatchEmitter,
|
|
274
|
+
_inherits(BuildWatchEmitter, _Event_EventEmitter);
|
|
275
275
|
var _super = _createSuper(BuildWatchEmitter);
|
|
276
276
|
function BuildWatchEmitter() {
|
|
277
277
|
_classCallCheck(this, BuildWatchEmitter);
|
|
@@ -65,7 +65,7 @@ var getDistFilePath = function(option) {
|
|
|
65
65
|
return path.join(distDir, path.relative(rootDir, filepath).replace(ext, extMap[ext]));
|
|
66
66
|
};
|
|
67
67
|
var resolveSourceMap = function(option) {
|
|
68
|
-
var babelRes = option.babelRes, sourceFilePath = option.sourceFilePath, distFilePath = option.distFilePath,
|
|
68
|
+
var babelRes = option.babelRes, sourceFilePath = option.sourceFilePath, distFilePath = option.distFilePath, _option_enableVirtualDist = option.enableVirtualDist, enableVirtualDist = _option_enableVirtualDist === void 0 ? false : _option_enableVirtualDist;
|
|
69
69
|
var mapLoc = "".concat(distFilePath, ".map");
|
|
70
70
|
babelRes.code = utils.addSourceMappingUrl(babelRes.code, mapLoc);
|
|
71
71
|
if (babelRes.map) {
|
|
@@ -86,7 +86,7 @@ var resolveSourceMap = function(option) {
|
|
|
86
86
|
return sourceMapVirtualDist;
|
|
87
87
|
};
|
|
88
88
|
var compiler = function(option) {
|
|
89
|
-
var filepath = option.filepath, rootDir = option.rootDir,
|
|
89
|
+
var filepath = option.filepath, rootDir = option.rootDir, _option_enableVirtualDist = option.enableVirtualDist, enableVirtualDist = _option_enableVirtualDist === void 0 ? false : _option_enableVirtualDist, _option_distDir = option.distDir, distDir = _option_distDir === void 0 ? path.join(path.dirname(rootDir), defaultDistDir) : _option_distDir, _option_verbose = option.verbose, verbose = _option_verbose === void 0 ? false : _option_verbose, _option_babelConfig = option.babelConfig, babelConfig = _option_babelConfig === void 0 ? {} : _option_babelConfig, _option_distFileExtMap = option.distFileExtMap, distFileExtMap = _option_distFileExtMap === void 0 ? defaultDistFileExtMap : _option_distFileExtMap, _option_quiet = option.quiet, quiet = _option_quiet === void 0 ? false : _option_quiet;
|
|
90
90
|
var babelRes = babel.transformFileSync(filepath, babelConfig);
|
|
91
91
|
var virtualDist = null;
|
|
92
92
|
if (!isRes(babelRes)) {
|
|
@@ -90,10 +90,10 @@ var CompilerErrorResult = /*#__PURE__*/ function() {
|
|
|
90
90
|
{
|
|
91
91
|
key: "value",
|
|
92
92
|
get: function get() {
|
|
93
|
-
var
|
|
93
|
+
var _this__messageDetails;
|
|
94
94
|
return {
|
|
95
95
|
code: 1,
|
|
96
|
-
message: "Compilation failure ".concat((
|
|
96
|
+
message: "Compilation failure ".concat((_this__messageDetails = this._messageDetails) === null || _this__messageDetails === void 0 ? void 0 : _this__messageDetails.length, " files with Babel."),
|
|
97
97
|
messageDetails: this._messageDetails
|
|
98
98
|
};
|
|
99
99
|
}
|
|
File without changes
|
|
File without changes
|
|
@@ -103,7 +103,7 @@ var getFinalExtensions = function(extensions) {
|
|
|
103
103
|
}
|
|
104
104
|
};
|
|
105
105
|
var getFilesFromDir = function(param) {
|
|
106
|
-
var dir = param.dir,
|
|
106
|
+
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;
|
|
107
107
|
var globFindFilenames = [];
|
|
108
108
|
var globPattern = getGlobPattern(dir, finalExt);
|
|
109
109
|
globFindFilenames = glob.sync(globPattern, {
|
|
@@ -113,7 +113,7 @@ var getFilesFromDir = function(param) {
|
|
|
113
113
|
};
|
|
114
114
|
var getFinalCompilerOption = function(option) {
|
|
115
115
|
var optionWithDefault = mergeDefaultOption(option);
|
|
116
|
-
var sourceDir = option.sourceDir, ignore = option.ignore,
|
|
116
|
+
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;
|
|
117
117
|
var globFindFilenames = [];
|
|
118
118
|
var finalExt = getFinalExtensions(extensions);
|
|
119
119
|
if (sourceDir) {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,27 +1,7 @@
|
|
|
1
|
-
var __async = (__this, __arguments, generator) => {
|
|
2
|
-
return new Promise((resolve, reject) => {
|
|
3
|
-
var fulfilled = (value) => {
|
|
4
|
-
try {
|
|
5
|
-
step(generator.next(value));
|
|
6
|
-
} catch (e) {
|
|
7
|
-
reject(e);
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
var rejected = (value) => {
|
|
11
|
-
try {
|
|
12
|
-
step(generator.throw(value));
|
|
13
|
-
} catch (e) {
|
|
14
|
-
reject(e);
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
18
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
1
|
import { fs, logger } from "@modern-js/utils";
|
|
22
2
|
import { defaultDistFileExtMap } from "./constants";
|
|
23
3
|
import { compiler } from "./compiler";
|
|
24
|
-
const build =
|
|
4
|
+
const build = async (option, babelConfig = {}) => {
|
|
25
5
|
const {
|
|
26
6
|
rootDir,
|
|
27
7
|
enableVirtualDist,
|
|
@@ -34,7 +14,7 @@ const build = (_0, ..._1) => __async(void 0, [_0, ..._1], function* (option, bab
|
|
|
34
14
|
} = option;
|
|
35
15
|
const virtualDists = [];
|
|
36
16
|
if (clean) {
|
|
37
|
-
|
|
17
|
+
await fs.remove(distDir);
|
|
38
18
|
}
|
|
39
19
|
fs.ensureDir(distDir);
|
|
40
20
|
const messageDetails = [];
|
|
@@ -84,7 +64,7 @@ const build = (_0, ..._1) => __async(void 0, [_0, ..._1], function* (option, bab
|
|
|
84
64
|
message: `Successfully compiled ${filenames.length} ${filenames.length !== 1 ? "files" : "file"} with Babel.`,
|
|
85
65
|
virtualDists
|
|
86
66
|
};
|
|
87
|
-
}
|
|
67
|
+
};
|
|
88
68
|
export {
|
|
89
69
|
build
|
|
90
70
|
};
|
|
@@ -1,42 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
var __async = (__this, __arguments, generator) => {
|
|
21
|
-
return new Promise((resolve, reject) => {
|
|
22
|
-
var fulfilled = (value) => {
|
|
23
|
-
try {
|
|
24
|
-
step(generator.next(value));
|
|
25
|
-
} catch (e) {
|
|
26
|
-
reject(e);
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
var rejected = (value) => {
|
|
30
|
-
try {
|
|
31
|
-
step(generator.throw(value));
|
|
32
|
-
} catch (e) {
|
|
33
|
-
reject(e);
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
37
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
1
|
import * as path from "path";
|
|
41
2
|
import * as Event from "events";
|
|
42
3
|
import { logger, watch, WatchChangeType } from "@modern-js/utils";
|
|
@@ -51,21 +12,19 @@ class BuildWatchEmitter extends Event.EventEmitter {
|
|
|
51
12
|
setInitFn(fn) {
|
|
52
13
|
this._initFn = fn;
|
|
53
14
|
}
|
|
54
|
-
watch() {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
return null;
|
|
60
|
-
});
|
|
15
|
+
async watch() {
|
|
16
|
+
if (typeof this._initFn === "function") {
|
|
17
|
+
return this._initFn(this);
|
|
18
|
+
}
|
|
19
|
+
return null;
|
|
61
20
|
}
|
|
62
21
|
}
|
|
63
|
-
const runBuildWatch =
|
|
22
|
+
const runBuildWatch = async (option, babelConfig = {}, emitter) => {
|
|
64
23
|
emitter.emit(BuildWatchEvent.compiling);
|
|
65
24
|
const errorResult = new CompilerErrorResult();
|
|
66
25
|
const watchDir = option.watchDir;
|
|
67
26
|
const { distDir, quiet } = option;
|
|
68
|
-
const firstBuildResult =
|
|
27
|
+
const firstBuildResult = await build(option, babelConfig);
|
|
69
28
|
const { code } = firstBuildResult;
|
|
70
29
|
if (code === 1) {
|
|
71
30
|
errorResult.init(firstBuildResult);
|
|
@@ -75,7 +34,7 @@ const runBuildWatch = (_0, ..._1) => __async(void 0, [_0, ..._1], function* (opt
|
|
|
75
34
|
}
|
|
76
35
|
return watch(
|
|
77
36
|
`${watchDir}/**/*.{js,jsx,ts,tsx}`,
|
|
78
|
-
|
|
37
|
+
async ({ changeType, changedFilePath }) => {
|
|
79
38
|
emitter.emit(BuildWatchEvent.compiling);
|
|
80
39
|
if (changeType === WatchChangeType.UNLINK) {
|
|
81
40
|
const removeFiles = [
|
|
@@ -94,8 +53,8 @@ const runBuildWatch = (_0, ..._1) => __async(void 0, [_0, ..._1], function* (opt
|
|
|
94
53
|
emitter.emit(BuildWatchEvent.watchingCompiler, result2);
|
|
95
54
|
return;
|
|
96
55
|
}
|
|
97
|
-
const result =
|
|
98
|
-
|
|
56
|
+
const result = await build(
|
|
57
|
+
{ ...option, filenames: [changedFilePath] },
|
|
99
58
|
babelConfig
|
|
100
59
|
);
|
|
101
60
|
if (result.code === 1) {
|
|
@@ -105,19 +64,20 @@ const runBuildWatch = (_0, ..._1) => __async(void 0, [_0, ..._1], function* (opt
|
|
|
105
64
|
} else {
|
|
106
65
|
errorResult.removeByFileName(changedFilePath);
|
|
107
66
|
if (errorResult.checkExistError()) {
|
|
108
|
-
emitter.emit(BuildWatchEvent.watchingCompiler,
|
|
67
|
+
emitter.emit(BuildWatchEvent.watchingCompiler, {
|
|
68
|
+
...errorResult.value,
|
|
109
69
|
virtualDists: result.virtualDists
|
|
110
|
-
})
|
|
70
|
+
});
|
|
111
71
|
!quiet && logger.info(errorResult.value.message);
|
|
112
72
|
} else {
|
|
113
73
|
emitter.emit(BuildWatchEvent.watchingCompiler, result);
|
|
114
74
|
!quiet && logger.info(result.message);
|
|
115
75
|
}
|
|
116
76
|
}
|
|
117
|
-
}
|
|
77
|
+
},
|
|
118
78
|
[`${watchDir}/**/*.d.ts`]
|
|
119
79
|
);
|
|
120
|
-
}
|
|
80
|
+
};
|
|
121
81
|
const buildWatch = (option, babelConfig = {}) => {
|
|
122
82
|
const buildWatchEmitter = new BuildWatchEmitter();
|
|
123
83
|
buildWatchEmitter.setInitFn(runBuildWatch.bind(null, option, babelConfig));
|
|
@@ -1,22 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
1
|
import * as path from "path";
|
|
21
2
|
import * as babel from "@babel/core";
|
|
22
3
|
import { logger, fs } from "@modern-js/utils";
|
|
@@ -90,12 +71,15 @@ const compiler = (option) => {
|
|
|
90
71
|
}
|
|
91
72
|
if ((babelRes == null ? void 0 : babelRes.map) && babelConfig.sourceMaps && babelConfig.sourceMaps !== "inline") {
|
|
92
73
|
if (virtualDist) {
|
|
93
|
-
virtualDist =
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
74
|
+
virtualDist = {
|
|
75
|
+
...virtualDist,
|
|
76
|
+
...resolveSourceMap({
|
|
77
|
+
babelRes,
|
|
78
|
+
sourceFilePath: filepath,
|
|
79
|
+
distFilePath,
|
|
80
|
+
enableVirtualDist
|
|
81
|
+
})
|
|
82
|
+
};
|
|
99
83
|
} else {
|
|
100
84
|
resolveSourceMap({
|
|
101
85
|
babelRes,
|
|
@@ -106,10 +90,11 @@ const compiler = (option) => {
|
|
|
106
90
|
}
|
|
107
91
|
}
|
|
108
92
|
if (virtualDist) {
|
|
109
|
-
virtualDist =
|
|
93
|
+
virtualDist = {
|
|
94
|
+
...virtualDist,
|
|
110
95
|
distPath: distFilePath,
|
|
111
96
|
code: babelRes.code
|
|
112
|
-
}
|
|
97
|
+
};
|
|
113
98
|
} else {
|
|
114
99
|
fs.ensureDirSync(path.dirname(distFilePath));
|
|
115
100
|
fs.writeFileSync(distFilePath, babelRes.code);
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { defaultDistFileExtMap } from "./constants";
|
|
2
|
+
const defaultOptions = {
|
|
3
|
+
enableWatch: false,
|
|
4
|
+
enableVirtualDist: false,
|
|
5
|
+
extensions: [],
|
|
6
|
+
filenames: [],
|
|
7
|
+
distFileExtMap: defaultDistFileExtMap,
|
|
8
|
+
ignore: [],
|
|
9
|
+
quiet: false,
|
|
10
|
+
verbose: false,
|
|
11
|
+
clean: false
|
|
12
|
+
};
|
|
13
|
+
const mergeDefaultOption = (compilerOptions) => ({
|
|
14
|
+
...defaultOptions,
|
|
15
|
+
...compilerOptions
|
|
16
|
+
});
|
|
17
|
+
export {
|
|
18
|
+
mergeDefaultOption
|
|
19
|
+
};
|
|
@@ -1,22 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
1
|
import { glob } from "@modern-js/utils";
|
|
21
2
|
import { DEFAULT_EXTENSIONS } from "@babel/core";
|
|
22
3
|
import { mergeDefaultOption } from "./defaults";
|
|
@@ -75,9 +56,10 @@ const getFinalCompilerOption = (option) => {
|
|
|
75
56
|
finalExt
|
|
76
57
|
});
|
|
77
58
|
}
|
|
78
|
-
return
|
|
59
|
+
return {
|
|
60
|
+
...optionWithDefault,
|
|
79
61
|
filenames: [...optionWithDefault.filenames, ...globFindFilenames]
|
|
80
|
-
}
|
|
62
|
+
};
|
|
81
63
|
};
|
|
82
64
|
export {
|
|
83
65
|
getFilesFromDir,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { getFinalCompilerOption } from "./getFinalOption";
|
|
2
|
+
import { build } from "./build";
|
|
3
|
+
import { buildWatch } from "./buildWatch";
|
|
4
|
+
import { validate } from "./validate";
|
|
5
|
+
async function compiler(compilerOptions, babelOptions = {}) {
|
|
6
|
+
const validRet = validate(compilerOptions);
|
|
7
|
+
if (validRet) {
|
|
8
|
+
return validRet;
|
|
9
|
+
}
|
|
10
|
+
const finalCompilerOption = getFinalCompilerOption(compilerOptions);
|
|
11
|
+
if (compilerOptions.enableWatch) {
|
|
12
|
+
return buildWatch(finalCompilerOption, babelOptions);
|
|
13
|
+
} else {
|
|
14
|
+
return build(finalCompilerOption, babelOptions);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export * from "./buildWatch";
|
|
18
|
+
export * from "./type";
|
|
19
|
+
export {
|
|
20
|
+
compiler
|
|
21
|
+
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -11,26 +11,25 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "2.
|
|
14
|
+
"version": "2.5.0",
|
|
15
15
|
"jsnext:source": "./src/index.ts",
|
|
16
16
|
"types": "./dist/types/index.d.ts",
|
|
17
|
-
"main": "./dist/
|
|
18
|
-
"module": "./dist/
|
|
19
|
-
"jsnext:modern": "./dist/js/modern/index.js",
|
|
17
|
+
"main": "./dist/cjs/index.js",
|
|
18
|
+
"module": "./dist/esm/index.js",
|
|
20
19
|
"exports": {
|
|
21
20
|
".": {
|
|
22
21
|
"node": {
|
|
23
22
|
"jsnext:source": "./src/index.ts",
|
|
24
|
-
"import": "./dist/
|
|
25
|
-
"require": "./dist/
|
|
23
|
+
"import": "./dist/esm-node/index.js",
|
|
24
|
+
"require": "./dist/cjs/index.js"
|
|
26
25
|
},
|
|
27
|
-
"default": "./dist/
|
|
26
|
+
"default": "./dist/esm/index.js"
|
|
28
27
|
}
|
|
29
28
|
},
|
|
30
29
|
"dependencies": {
|
|
31
30
|
"@babel/core": "^7.18.0",
|
|
32
31
|
"@babel/runtime": "^7.18.0",
|
|
33
|
-
"@modern-js/utils": "2.
|
|
32
|
+
"@modern-js/utils": "2.5.0"
|
|
34
33
|
},
|
|
35
34
|
"devDependencies": {
|
|
36
35
|
"@babel/plugin-transform-classes": "^7.18.0",
|
|
@@ -41,8 +40,8 @@
|
|
|
41
40
|
"@types/node": "^14",
|
|
42
41
|
"typescript": "^4",
|
|
43
42
|
"jest": "^27",
|
|
44
|
-
"@scripts/
|
|
45
|
-
"@scripts/
|
|
43
|
+
"@scripts/jest-config": "2.5.0",
|
|
44
|
+
"@scripts/build": "2.5.0"
|
|
46
45
|
},
|
|
47
46
|
"sideEffects": false,
|
|
48
47
|
"modernConfig": {
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
-
var __spreadValues = (a, b) => {
|
|
7
|
-
for (var prop in b || (b = {}))
|
|
8
|
-
if (__hasOwnProp.call(b, prop))
|
|
9
|
-
__defNormalProp(a, prop, b[prop]);
|
|
10
|
-
if (__getOwnPropSymbols)
|
|
11
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
-
if (__propIsEnum.call(b, prop))
|
|
13
|
-
__defNormalProp(a, prop, b[prop]);
|
|
14
|
-
}
|
|
15
|
-
return a;
|
|
16
|
-
};
|
|
17
|
-
import { defaultDistFileExtMap } from "./constants";
|
|
18
|
-
const defaultOptions = {
|
|
19
|
-
enableWatch: false,
|
|
20
|
-
enableVirtualDist: false,
|
|
21
|
-
extensions: [],
|
|
22
|
-
filenames: [],
|
|
23
|
-
distFileExtMap: defaultDistFileExtMap,
|
|
24
|
-
ignore: [],
|
|
25
|
-
quiet: false,
|
|
26
|
-
verbose: false,
|
|
27
|
-
clean: false
|
|
28
|
-
};
|
|
29
|
-
const mergeDefaultOption = (compilerOptions) => __spreadValues(__spreadValues({}, defaultOptions), compilerOptions);
|
|
30
|
-
export {
|
|
31
|
-
mergeDefaultOption
|
|
32
|
-
};
|
package/dist/js/modern/index.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
var __async = (__this, __arguments, generator) => {
|
|
2
|
-
return new Promise((resolve, reject) => {
|
|
3
|
-
var fulfilled = (value) => {
|
|
4
|
-
try {
|
|
5
|
-
step(generator.next(value));
|
|
6
|
-
} catch (e) {
|
|
7
|
-
reject(e);
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
var rejected = (value) => {
|
|
11
|
-
try {
|
|
12
|
-
step(generator.throw(value));
|
|
13
|
-
} catch (e) {
|
|
14
|
-
reject(e);
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
18
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
import { getFinalCompilerOption } from "./getFinalOption";
|
|
22
|
-
import { build } from "./build";
|
|
23
|
-
import { buildWatch } from "./buildWatch";
|
|
24
|
-
import { validate } from "./validate";
|
|
25
|
-
function compiler(_0) {
|
|
26
|
-
return __async(this, arguments, function* (compilerOptions, babelOptions = {}) {
|
|
27
|
-
const validRet = validate(compilerOptions);
|
|
28
|
-
if (validRet) {
|
|
29
|
-
return validRet;
|
|
30
|
-
}
|
|
31
|
-
const finalCompilerOption = getFinalCompilerOption(compilerOptions);
|
|
32
|
-
if (compilerOptions.enableWatch) {
|
|
33
|
-
return buildWatch(finalCompilerOption, babelOptions);
|
|
34
|
-
} else {
|
|
35
|
-
return build(finalCompilerOption, babelOptions);
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
export * from "./buildWatch";
|
|
40
|
-
export * from "./type";
|
|
41
|
-
export {
|
|
42
|
-
compiler
|
|
43
|
-
};
|