@modern-js/babel-compiler 2.0.0-beta.3 → 2.0.0-beta.6

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.
Files changed (34) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/dist/js/modern/build.js +35 -9
  3. package/dist/js/modern/buildWatch.js +107 -68
  4. package/dist/js/modern/compiler.js +48 -26
  5. package/dist/js/modern/compilerErrorResult.js +12 -11
  6. package/dist/js/modern/constants.js +9 -6
  7. package/dist/js/modern/defaults.js +20 -4
  8. package/dist/js/modern/getFinalOption.js +40 -21
  9. package/dist/js/modern/index.js +37 -12
  10. package/dist/js/modern/utils.js +8 -4
  11. package/dist/js/modern/validate.js +17 -22
  12. package/dist/js/node/build.js +62 -20
  13. package/dist/js/node/buildWatch.js +136 -79
  14. package/dist/js/node/compiler.js +84 -44
  15. package/dist/js/node/compilerErrorResult.js +32 -15
  16. package/dist/js/node/constants.js +29 -10
  17. package/dist/js/node/defaults.js +42 -12
  18. package/dist/js/node/getFinalOption.js +66 -33
  19. package/dist/js/node/index.js +61 -42
  20. package/dist/js/node/type.js +15 -0
  21. package/dist/js/node/utils.js +35 -10
  22. package/dist/js/node/validate.js +44 -33
  23. package/dist/js/treeshaking/build.js +224 -0
  24. package/dist/js/treeshaking/buildWatch.js +417 -0
  25. package/dist/js/treeshaking/compiler.js +140 -0
  26. package/dist/js/treeshaking/compilerErrorResult.js +110 -0
  27. package/dist/js/treeshaking/constants.js +7 -0
  28. package/dist/js/treeshaking/defaults.js +44 -0
  29. package/dist/js/treeshaking/getFinalOption.js +137 -0
  30. package/dist/js/treeshaking/index.js +166 -0
  31. package/dist/js/treeshaking/type.js +1 -0
  32. package/dist/js/treeshaking/utils.js +5 -0
  33. package/dist/js/treeshaking/validate.js +38 -0
  34. package/package.json +4 -4
@@ -1,18 +1,43 @@
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
+ };
1
21
  import { getFinalCompilerOption } from "./getFinalOption";
2
22
  import { build } from "./build";
3
23
  import { buildWatch } from "./buildWatch";
4
24
  import { validate } from "./validate";
5
- export 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
- }
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
+ });
16
38
  }
17
39
  export * from "./buildWatch";
18
- export * from "./type";
40
+ export * from "./type";
41
+ export {
42
+ compiler
43
+ };
@@ -1,4 +1,8 @@
1
- import * as path from 'path';
2
- export function addSourceMappingUrl(code, loc) {
3
- return `${code}\n//# sourceMappingURL=${path.normalize(path.basename(loc))}`;
4
- }
1
+ import * as path from "path";
2
+ function addSourceMappingUrl(code, loc) {
3
+ return `${code}
4
+ //# sourceMappingURL=${path.normalize(path.basename(loc))}`;
5
+ }
6
+ export {
7
+ addSourceMappingUrl
8
+ };
@@ -1,12 +1,8 @@
1
- import { logger } from '@modern-js/utils';
2
- export const sourceDirAndFileNamesValidMessage = 'At least one of the sourceDir and filenames configurations must be configured';
3
- export const watchDirValidMessage = 'should set watchDir when enableWatch is true';
4
- export const validateSourceDirAndFileNames = compilerOptions => {
5
- const {
6
- sourceDir,
7
- filenames,
8
- quiet
9
- } = compilerOptions;
1
+ import { logger } from "@modern-js/utils";
2
+ const sourceDirAndFileNamesValidMessage = "At least one of the sourceDir and filenames configurations must be configured";
3
+ const watchDirValidMessage = "should set watchDir when enableWatch is true";
4
+ const validateSourceDirAndFileNames = (compilerOptions) => {
5
+ const { sourceDir, filenames, quiet } = compilerOptions;
10
6
  if (!sourceDir && !filenames) {
11
7
  if (!quiet) {
12
8
  logger.error(sourceDirAndFileNamesValidMessage);
@@ -19,27 +15,26 @@ export const validateSourceDirAndFileNames = compilerOptions => {
19
15
  }
20
16
  return null;
21
17
  };
22
- export const validateWatchDir = compilerOptions => {
23
- const {
24
- watchDir,
25
- enableWatch,
26
- quiet
27
- } = compilerOptions;
18
+ const validateWatchDir = (compilerOptions) => {
19
+ const { watchDir, enableWatch, quiet } = compilerOptions;
28
20
  if (enableWatch && !watchDir) {
29
21
  if (!quiet) {
30
22
  logger.error(watchDirValidMessage);
31
23
  }
32
- return {
33
- code: 1,
34
- message: watchDirValidMessage,
35
- virtualDists: []
36
- };
24
+ return { code: 1, message: watchDirValidMessage, virtualDists: [] };
37
25
  }
38
26
  return null;
39
27
  };
40
- export const validate = compilerOptions => {
28
+ const validate = (compilerOptions) => {
41
29
  if (compilerOptions.enableWatch) {
42
30
  return validateWatchDir(compilerOptions);
43
31
  }
44
32
  return validateSourceDirAndFileNames(compilerOptions);
45
- };
33
+ };
34
+ export {
35
+ sourceDirAndFileNamesValidMessage,
36
+ validate,
37
+ validateSourceDirAndFileNames,
38
+ validateWatchDir,
39
+ watchDirValidMessage
40
+ };
@@ -1,32 +1,68 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
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 __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
+ var build_exports = {};
39
+ __export(build_exports, {
40
+ build: () => build
5
41
  });
6
- exports.build = void 0;
7
- var _utils = require("@modern-js/utils");
8
- var _constants = require("./constants");
9
- var _compiler = require("./compiler");
10
- const build = async (option, babelConfig = {}) => {
42
+ module.exports = __toCommonJS(build_exports);
43
+ var import_utils = require("@modern-js/utils");
44
+ var import_constants = require("./constants");
45
+ var import_compiler = require("./compiler");
46
+ const build = (_0, ..._1) => __async(void 0, [_0, ..._1], function* (option, babelConfig = {}) {
11
47
  const {
12
48
  rootDir,
13
49
  enableVirtualDist,
14
50
  filenames,
15
51
  clean,
16
52
  distDir,
17
- distFileExtMap = _constants.defaultDistFileExtMap,
53
+ distFileExtMap = import_constants.defaultDistFileExtMap,
18
54
  verbose = false,
19
55
  quiet = false
20
56
  } = option;
21
57
  const virtualDists = [];
22
58
  if (clean) {
23
- await _utils.fs.remove(distDir);
59
+ yield import_utils.fs.remove(distDir);
24
60
  }
25
- _utils.fs.ensureDir(distDir);
61
+ import_utils.fs.ensureDir(distDir);
26
62
  const messageDetails = [];
27
63
  for (const filename of filenames) {
28
64
  try {
29
- const dist = (0, _compiler.compiler)({
65
+ const dist = (0, import_compiler.compiler)({
30
66
  rootDir,
31
67
  enableVirtualDist,
32
68
  filepath: filename,
@@ -49,23 +85,29 @@ const build = async (option, babelConfig = {}) => {
49
85
  const happenError = messageDetails.length > 0;
50
86
  if (!quiet) {
51
87
  if (happenError) {
52
- _utils.logger.error(`Compilation failure ${messageDetails.length} ${messageDetails.length !== 1 ? 'files' : 'file'} with Babel.`);
53
- // TODO: 具体的报错信息打印
88
+ import_utils.logger.error(
89
+ `Compilation failure ${messageDetails.length} ${messageDetails.length !== 1 ? "files" : "file"} with Babel.`
90
+ );
54
91
  } else {
55
- _utils.logger.info(`Successfully compiled ${filenames.length} ${filenames.length !== 1 ? 'files' : 'file'} with Babel.`);
92
+ import_utils.logger.info(
93
+ `Successfully compiled ${filenames.length} ${filenames.length !== 1 ? "files" : "file"} with Babel.`
94
+ );
56
95
  }
57
96
  }
58
97
  if (happenError) {
59
98
  return {
60
99
  code: 1,
61
- message: `Compilation failure ${messageDetails.length} ${messageDetails.length !== 1 ? 'files' : 'file'} with Babel.`,
100
+ message: `Compilation failure ${messageDetails.length} ${messageDetails.length !== 1 ? "files" : "file"} with Babel.`,
62
101
  messageDetails
63
102
  };
64
103
  }
65
104
  return {
66
105
  code: 0,
67
- message: `Successfully compiled ${filenames.length} ${filenames.length !== 1 ? 'files' : 'file'} with Babel.`,
106
+ message: `Successfully compiled ${filenames.length} ${filenames.length !== 1 ? "files" : "file"} with Babel.`,
68
107
  virtualDists
69
108
  };
70
- };
71
- exports.build = build;
109
+ });
110
+ // Annotate the CommonJS export names for ESM import in node:
111
+ 0 && (module.exports = {
112
+ build
113
+ });
@@ -1,104 +1,161 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ 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
+ var __export = (target, all) => {
25
+ for (var name in all)
26
+ __defProp(target, name, { get: all[name], enumerable: true });
27
+ };
28
+ var __copyProps = (to, from, except, desc) => {
29
+ if (from && typeof from === "object" || typeof from === "function") {
30
+ for (let key of __getOwnPropNames(from))
31
+ if (!__hasOwnProp.call(to, key) && key !== except)
32
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
33
+ }
34
+ return to;
35
+ };
36
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
37
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
38
+ mod
39
+ ));
40
+ 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
+ var buildWatch_exports = {};
62
+ __export(buildWatch_exports, {
63
+ BuildWatchEmitter: () => BuildWatchEmitter,
64
+ BuildWatchEvent: () => BuildWatchEvent,
65
+ buildWatch: () => buildWatch,
66
+ runBuildWatch: () => runBuildWatch
5
67
  });
6
- exports.runBuildWatch = exports.buildWatch = exports.BuildWatchEvent = exports.BuildWatchEmitter = void 0;
7
- var path = _interopRequireWildcard(require("path"));
8
- var Event = _interopRequireWildcard(require("events"));
9
- var _utils = require("@modern-js/utils");
10
- var _build = require("./build");
11
- var _compilerErrorResult = require("./compilerErrorResult");
12
- 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); }
13
- 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; }
14
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
15
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
16
- 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; }
68
+ module.exports = __toCommonJS(buildWatch_exports);
69
+ var path = __toESM(require("path"));
70
+ var Event = __toESM(require("events"));
71
+ var import_utils = require("@modern-js/utils");
72
+ var import_build = require("./build");
73
+ var import_compilerErrorResult = require("./compilerErrorResult");
17
74
  const BuildWatchEvent = {
18
- firstCompiler: 'first-compiler',
19
- compiling: 'compiling',
20
- watchingCompiler: 'watching-compiler'
75
+ firstCompiler: "first-compiler",
76
+ compiling: "compiling",
77
+ watchingCompiler: "watching-compiler"
21
78
  };
22
- exports.BuildWatchEvent = BuildWatchEvent;
23
79
  class BuildWatchEmitter extends Event.EventEmitter {
24
- constructor(...args) {
25
- super(...args);
26
- _defineProperty(this, "_initFn", void 0);
27
- }
28
80
  setInitFn(fn) {
29
81
  this._initFn = fn;
30
82
  }
31
- async watch() {
32
- if (typeof this._initFn === 'function') {
33
- return this._initFn(this);
34
- }
35
- return null;
83
+ watch() {
84
+ return __async(this, null, function* () {
85
+ if (typeof this._initFn === "function") {
86
+ return this._initFn(this);
87
+ }
88
+ return null;
89
+ });
36
90
  }
37
91
  }
38
- exports.BuildWatchEmitter = BuildWatchEmitter;
39
- const runBuildWatch = async (option, babelConfig = {}, emitter) => {
92
+ const runBuildWatch = (_0, ..._1) => __async(void 0, [_0, ..._1], function* (option, babelConfig = {}, emitter) {
40
93
  emitter.emit(BuildWatchEvent.compiling);
41
- const errorResult = new _compilerErrorResult.CompilerErrorResult();
94
+ const errorResult = new import_compilerErrorResult.CompilerErrorResult();
42
95
  const watchDir = option.watchDir;
43
- const {
44
- distDir,
45
- quiet
46
- } = option;
47
- // 第一次正常构建
48
- const firstBuildResult = await (0, _build.build)(option, babelConfig);
49
- const {
50
- code
51
- } = firstBuildResult;
96
+ const { distDir, quiet } = option;
97
+ const firstBuildResult = yield (0, import_build.build)(option, babelConfig);
98
+ const { code } = firstBuildResult;
52
99
  if (code === 1) {
53
100
  errorResult.init(firstBuildResult);
54
101
  emitter.emit(BuildWatchEvent.firstCompiler, errorResult.value);
55
102
  } else {
56
103
  emitter.emit(BuildWatchEvent.firstCompiler, firstBuildResult);
57
104
  }
58
- return (0, _utils.watch)(`${watchDir}/**/*.{js,jsx,ts,tsx}`, async ({
59
- changeType,
60
- changedFilePath
61
- }) => {
62
- emitter.emit(BuildWatchEvent.compiling);
63
- if (changeType === _utils.WatchChangeType.UNLINK) {
64
- const removeFiles = [path.normalize(`./${distDir}/${path.relative(watchDir, changedFilePath)}`)];
65
- if (!quiet) {
66
- _utils.logger.info(`remove file: ${removeFiles.join(',')}`);
105
+ return (0, import_utils.watch)(
106
+ `${watchDir}/**/*.{js,jsx,ts,tsx}`,
107
+ (_02) => __async(void 0, [_02], function* ({ changeType, changedFilePath }) {
108
+ emitter.emit(BuildWatchEvent.compiling);
109
+ if (changeType === import_utils.WatchChangeType.UNLINK) {
110
+ const removeFiles = [
111
+ path.normalize(
112
+ `./${distDir}/${path.relative(watchDir, changedFilePath)}`
113
+ )
114
+ ];
115
+ if (!quiet) {
116
+ import_utils.logger.info(`remove file: ${removeFiles.join(",")}`);
117
+ }
118
+ const result2 = {
119
+ code: 0,
120
+ message: `remove file: ${removeFiles.join(",")}`,
121
+ removeFiles
122
+ };
123
+ emitter.emit(BuildWatchEvent.watchingCompiler, result2);
124
+ return;
67
125
  }
68
- const result = {
69
- code: 0,
70
- message: `remove file: ${removeFiles.join(',')}`,
71
- removeFiles
72
- };
73
- emitter.emit(BuildWatchEvent.watchingCompiler, result);
74
- return;
75
- }
76
- const result = await (0, _build.build)(_objectSpread(_objectSpread({}, option), {}, {
77
- filenames: [changedFilePath]
78
- }), babelConfig);
79
- if (result.code === 1) {
80
- errorResult.update(result.messageDetails || []);
81
- emitter.emit(BuildWatchEvent.watchingCompiler, errorResult.value);
82
- !quiet && _utils.logger.info(errorResult.value.message);
83
- } else {
84
- errorResult.removeByFileName(changedFilePath);
85
- // 如果该文件没有报错,则更新该文件状态并检查是否还存在其他报错文件
86
- if (errorResult.checkExistError()) {
87
- emitter.emit(BuildWatchEvent.watchingCompiler, _objectSpread(_objectSpread({}, errorResult.value), {}, {
88
- virtualDists: result.virtualDists
89
- }));
90
- !quiet && _utils.logger.info(errorResult.value.message);
126
+ const result = yield (0, import_build.build)(
127
+ __spreadProps(__spreadValues({}, option), { filenames: [changedFilePath] }),
128
+ babelConfig
129
+ );
130
+ if (result.code === 1) {
131
+ errorResult.update(result.messageDetails || []);
132
+ emitter.emit(BuildWatchEvent.watchingCompiler, errorResult.value);
133
+ !quiet && import_utils.logger.info(errorResult.value.message);
91
134
  } else {
92
- emitter.emit(BuildWatchEvent.watchingCompiler, result);
93
- !quiet && _utils.logger.info(result.message);
135
+ errorResult.removeByFileName(changedFilePath);
136
+ if (errorResult.checkExistError()) {
137
+ emitter.emit(BuildWatchEvent.watchingCompiler, __spreadProps(__spreadValues({}, errorResult.value), {
138
+ virtualDists: result.virtualDists
139
+ }));
140
+ !quiet && import_utils.logger.info(errorResult.value.message);
141
+ } else {
142
+ emitter.emit(BuildWatchEvent.watchingCompiler, result);
143
+ !quiet && import_utils.logger.info(result.message);
144
+ }
94
145
  }
95
- }
96
- }, [`${watchDir}/**/*.d.ts`]);
97
- };
98
- exports.runBuildWatch = runBuildWatch;
146
+ }),
147
+ [`${watchDir}/**/*.d.ts`]
148
+ );
149
+ });
99
150
  const buildWatch = (option, babelConfig = {}) => {
100
151
  const buildWatchEmitter = new BuildWatchEmitter();
101
152
  buildWatchEmitter.setInitFn(runBuildWatch.bind(null, option, babelConfig));
102
153
  return buildWatchEmitter;
103
154
  };
104
- exports.buildWatch = buildWatch;
155
+ // Annotate the CommonJS export names for ESM import in node:
156
+ 0 && (module.exports = {
157
+ BuildWatchEmitter,
158
+ BuildWatchEvent,
159
+ buildWatch,
160
+ runBuildWatch
161
+ });