@modern-js/babel-compiler 2.35.0 → 2.36.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -1,28 +1,48 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "compiler", {
6
- enumerable: true,
7
- get: function() {
8
- return compiler;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
9
15
  }
16
+ return to;
17
+ };
18
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var src_exports = {};
21
+ __export(src_exports, {
22
+ compiler: () => compiler
10
23
  });
11
- const _export_star = require("@swc/helpers/_/_export_star");
12
- const _getFinalOption = require("./getFinalOption");
13
- const _build = require("./build");
14
- const _buildWatch = _export_star._(require("./buildWatch"), exports);
15
- const _validate = require("./validate");
16
- _export_star._(require("./type"), exports);
24
+ module.exports = __toCommonJS(src_exports);
25
+ var import_getFinalOption = require("./getFinalOption");
26
+ var import_build = require("./build");
27
+ var import_buildWatch = require("./buildWatch");
28
+ var import_validate = require("./validate");
29
+ __reExport(src_exports, require("./buildWatch"), module.exports);
30
+ __reExport(src_exports, require("./type"), module.exports);
17
31
  async function compiler(compilerOptions, babelOptions = {}) {
18
- const validRet = (0, _validate.validate)(compilerOptions);
32
+ const validRet = (0, import_validate.validate)(compilerOptions);
19
33
  if (validRet) {
20
34
  return validRet;
21
35
  }
22
- const finalCompilerOption = (0, _getFinalOption.getFinalCompilerOption)(compilerOptions);
36
+ const finalCompilerOption = (0, import_getFinalOption.getFinalCompilerOption)(compilerOptions);
23
37
  if (compilerOptions.enableWatch) {
24
- return (0, _buildWatch.buildWatch)(finalCompilerOption, babelOptions);
38
+ return (0, import_buildWatch.buildWatch)(finalCompilerOption, babelOptions);
25
39
  } else {
26
- return (0, _build.build)(finalCompilerOption, babelOptions);
40
+ return (0, import_build.build)(finalCompilerOption, babelOptions);
27
41
  }
28
42
  }
43
+ // Annotate the CommonJS export names for ESM import in node:
44
+ 0 && (module.exports = {
45
+ compiler,
46
+ ...require("./buildWatch"),
47
+ ...require("./type")
48
+ });
package/dist/cjs/type.js CHANGED
@@ -1,4 +1,16 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var type_exports = {};
16
+ module.exports = __toCommonJS(type_exports);
package/dist/cjs/utils.js CHANGED
@@ -1,16 +1,42 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "addSourceMappingUrl", {
6
- enumerable: true,
7
- get: function() {
8
- return addSourceMappingUrl;
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
9
17
  }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var utils_exports = {};
30
+ __export(utils_exports, {
31
+ addSourceMappingUrl: () => addSourceMappingUrl
10
32
  });
11
- const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
12
- const _path = /* @__PURE__ */ _interop_require_wildcard._(require("path"));
33
+ module.exports = __toCommonJS(utils_exports);
34
+ var path = __toESM(require("path"));
13
35
  function addSourceMappingUrl(code, loc) {
14
36
  return `${code}
15
- //# sourceMappingURL=${_path.normalize(_path.basename(loc))}`;
37
+ //# sourceMappingURL=${path.normalize(path.basename(loc))}`;
16
38
  }
39
+ // Annotate the CommonJS export names for ESM import in node:
40
+ 0 && (module.exports = {
41
+ addSourceMappingUrl
42
+ });
@@ -1,39 +1,38 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
6
7
  for (var name in all)
7
- Object.defineProperty(target, name, {
8
- enumerable: true,
9
- get: all[name]
10
- });
11
- }
12
- _export(exports, {
13
- sourceDirAndFileNamesValidMessage: function() {
14
- return sourceDirAndFileNamesValidMessage;
15
- },
16
- watchDirValidMessage: function() {
17
- return watchDirValidMessage;
18
- },
19
- validateSourceDirAndFileNames: function() {
20
- return validateSourceDirAndFileNames;
21
- },
22
- validateWatchDir: function() {
23
- return validateWatchDir;
24
- },
25
- validate: function() {
26
- return validate;
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
27
15
  }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var validate_exports = {};
20
+ __export(validate_exports, {
21
+ sourceDirAndFileNamesValidMessage: () => sourceDirAndFileNamesValidMessage,
22
+ validate: () => validate,
23
+ validateSourceDirAndFileNames: () => validateSourceDirAndFileNames,
24
+ validateWatchDir: () => validateWatchDir,
25
+ watchDirValidMessage: () => watchDirValidMessage
28
26
  });
29
- const _utils = require("@modern-js/utils");
27
+ module.exports = __toCommonJS(validate_exports);
28
+ var import_utils = require("@modern-js/utils");
30
29
  const sourceDirAndFileNamesValidMessage = "At least one of the sourceDir and filenames configurations must be configured";
31
30
  const watchDirValidMessage = "should set watchDir when enableWatch is true";
32
31
  const validateSourceDirAndFileNames = (compilerOptions) => {
33
32
  const { sourceDir, filenames, quiet } = compilerOptions;
34
33
  if (!sourceDir && !filenames) {
35
34
  if (!quiet) {
36
- _utils.logger.error(sourceDirAndFileNamesValidMessage);
35
+ import_utils.logger.error(sourceDirAndFileNamesValidMessage);
37
36
  }
38
37
  return {
39
38
  code: 1,
@@ -47,7 +46,7 @@ const validateWatchDir = (compilerOptions) => {
47
46
  const { watchDir, enableWatch, quiet } = compilerOptions;
48
47
  if (enableWatch && !watchDir) {
49
48
  if (!quiet) {
50
- _utils.logger.error(watchDirValidMessage);
49
+ import_utils.logger.error(watchDirValidMessage);
51
50
  }
52
51
  return {
53
52
  code: 1,
@@ -63,3 +62,11 @@ const validate = (compilerOptions) => {
63
62
  }
64
63
  return validateSourceDirAndFileNames(compilerOptions);
65
64
  };
65
+ // Annotate the CommonJS export names for ESM import in node:
66
+ 0 && (module.exports = {
67
+ sourceDirAndFileNamesValidMessage,
68
+ validate,
69
+ validateSourceDirAndFileNames,
70
+ validateWatchDir,
71
+ watchDirValidMessage
72
+ });
package/dist/esm/build.js CHANGED
@@ -3,7 +3,7 @@ import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
3
3
  import { fs, logger } from "@modern-js/utils";
4
4
  import { defaultDistFileExtMap } from "./constants";
5
5
  import { compiler } from "./compiler";
6
- export var build = function() {
6
+ var build = function() {
7
7
  var _ref = _async_to_generator(function(option) {
8
8
  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;
9
9
  var _arguments = arguments;
@@ -34,21 +34,21 @@ export var build = function() {
34
34
  filename = _step.value;
35
35
  try {
36
36
  dist = compiler({
37
- rootDir: rootDir,
38
- enableVirtualDist: enableVirtualDist,
37
+ rootDir,
38
+ enableVirtualDist,
39
39
  filepath: filename,
40
- distDir: distDir,
41
- verbose: verbose,
42
- quiet: quiet,
43
- babelConfig: babelConfig,
44
- distFileExtMap: distFileExtMap
40
+ distDir,
41
+ verbose,
42
+ quiet,
43
+ babelConfig,
44
+ distFileExtMap
45
45
  });
46
46
  if (enableVirtualDist && dist) {
47
47
  virtualDists.push(dist);
48
48
  }
49
49
  } catch (e) {
50
50
  messageDetails.push({
51
- filename: filename,
51
+ filename,
52
52
  content: e.toString()
53
53
  });
54
54
  }
@@ -81,7 +81,7 @@ export var build = function() {
81
81
  {
82
82
  code: 1,
83
83
  message: "Compilation failure ".concat(messageDetails.length, " ").concat(messageDetails.length !== 1 ? "files" : "file", " with Babel."),
84
- messageDetails: messageDetails
84
+ messageDetails
85
85
  }
86
86
  ];
87
87
  }
@@ -90,7 +90,7 @@ export var build = function() {
90
90
  {
91
91
  code: 0,
92
92
  message: "Successfully compiled ".concat(filenames.length, " ").concat(filenames.length !== 1 ? "files" : "file", " with Babel."),
93
- virtualDists: virtualDists
93
+ virtualDists
94
94
  }
95
95
  ];
96
96
  }
@@ -100,3 +100,6 @@ export var build = function() {
100
100
  return _ref.apply(this, arguments);
101
101
  };
102
102
  }();
103
+ export {
104
+ build
105
+ };
@@ -13,12 +13,12 @@ import * as Event from "events";
13
13
  import { logger, watch, WatchChangeType } from "@modern-js/utils";
14
14
  import { build } from "./build";
15
15
  import { CompilerErrorResult } from "./compilerErrorResult";
16
- export var BuildWatchEvent = {
16
+ var BuildWatchEvent = {
17
17
  firstCompiler: "first-compiler",
18
18
  compiling: "compiling",
19
19
  watchingCompiler: "watching-compiler"
20
20
  };
21
- export var BuildWatchEmitter = /* @__PURE__ */ function(_Event_EventEmitter) {
21
+ var BuildWatchEmitter = /* @__PURE__ */ function(_Event_EventEmitter) {
22
22
  "use strict";
23
23
  _inherits(BuildWatchEmitter2, _Event_EventEmitter);
24
24
  var _super = _create_super(BuildWatchEmitter2);
@@ -59,7 +59,7 @@ export var BuildWatchEmitter = /* @__PURE__ */ function(_Event_EventEmitter) {
59
59
  ]);
60
60
  return BuildWatchEmitter2;
61
61
  }(Event.EventEmitter);
62
- export var runBuildWatch = function() {
62
+ var runBuildWatch = function() {
63
63
  var _ref = _async_to_generator(function(option) {
64
64
  var babelConfig, emitter, errorResult, watchDir, distDir, quiet, firstBuildResult, code;
65
65
  var _arguments = arguments;
@@ -104,7 +104,7 @@ export var runBuildWatch = function() {
104
104
  result = {
105
105
  code: 0,
106
106
  message: "remove file: ".concat(removeFiles.join(",")),
107
- removeFiles: removeFiles
107
+ removeFiles
108
108
  };
109
109
  emitter.emit(BuildWatchEvent.watchingCompiler, result);
110
110
  return [
@@ -157,9 +157,15 @@ export var runBuildWatch = function() {
157
157
  return _ref.apply(this, arguments);
158
158
  };
159
159
  }();
160
- export var buildWatch = function(option) {
160
+ var buildWatch = function(option) {
161
161
  var babelConfig = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
162
162
  var buildWatchEmitter = new BuildWatchEmitter();
163
163
  buildWatchEmitter.setInitFn(runBuildWatch.bind(null, option, babelConfig));
164
164
  return buildWatchEmitter;
165
165
  };
166
+ export {
167
+ BuildWatchEmitter,
168
+ BuildWatchEvent,
169
+ buildWatch,
170
+ runBuildWatch
171
+ };
@@ -6,15 +6,15 @@ import { logger, fs } from "@modern-js/utils";
6
6
  import * as utils from "./utils";
7
7
  import { defaultDistFileExtMap } from "./constants";
8
8
  var defaultDistDir = "dist";
9
- export var isRes = function(r) {
9
+ var isRes = function(r) {
10
10
  return Boolean(r);
11
11
  };
12
- export var getDistFilePath = function(option) {
12
+ var getDistFilePath = function(option) {
13
13
  var filepath = option.filepath, rootDir = option.rootDir, distDir = option.distDir, extMap = option.extMap;
14
14
  var ext = path.extname(filepath);
15
15
  return path.join(distDir, path.relative(rootDir, filepath).replace(ext, extMap[ext]));
16
16
  };
17
- export var resolveSourceMap = function(option) {
17
+ var resolveSourceMap = function(option) {
18
18
  var babelRes = option.babelRes, sourceFilePath = option.sourceFilePath, distFilePath = option.distFilePath, _option_enableVirtualDist = option.enableVirtualDist, enableVirtualDist = _option_enableVirtualDist === void 0 ? false : _option_enableVirtualDist;
19
19
  var mapLoc = "".concat(distFilePath, ".map");
20
20
  babelRes.code = utils.addSourceMappingUrl(babelRes.code, mapLoc);
@@ -35,8 +35,7 @@ export var resolveSourceMap = function(option) {
35
35
  fs.writeFileSync(mapLoc, JSON.stringify(babelRes.map));
36
36
  return sourceMapVirtualDist;
37
37
  };
38
- export var compiler = function(option) {
39
- var _babelRes;
38
+ var compiler = function(option) {
40
39
  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;
41
40
  var babelRes = babel.transformFileSync(filepath, babelConfig);
42
41
  var virtualDist = null;
@@ -44,9 +43,9 @@ export var compiler = function(option) {
44
43
  throw new Error("".concat(filepath, " happen error"));
45
44
  }
46
45
  var distFilePath = getDistFilePath({
47
- filepath: filepath,
48
- rootDir: rootDir,
49
- distDir: distDir,
46
+ filepath,
47
+ rootDir,
48
+ distDir,
50
49
  extMap: distFileExtMap
51
50
  });
52
51
  if (enableVirtualDist) {
@@ -57,20 +56,20 @@ export var compiler = function(option) {
57
56
  sourcemap: ""
58
57
  };
59
58
  }
60
- if (((_babelRes = babelRes) === null || _babelRes === void 0 ? void 0 : _babelRes.map) && babelConfig.sourceMaps && babelConfig.sourceMaps !== "inline") {
59
+ if ((babelRes === null || babelRes === void 0 ? void 0 : babelRes.map) && babelConfig.sourceMaps && babelConfig.sourceMaps !== "inline") {
61
60
  if (virtualDist) {
62
61
  virtualDist = _object_spread({}, virtualDist, resolveSourceMap({
63
- babelRes: babelRes,
62
+ babelRes,
64
63
  sourceFilePath: filepath,
65
- distFilePath: distFilePath,
66
- enableVirtualDist: enableVirtualDist
64
+ distFilePath,
65
+ enableVirtualDist
67
66
  }));
68
67
  } else {
69
68
  resolveSourceMap({
70
- babelRes: babelRes,
69
+ babelRes,
71
70
  sourceFilePath: filepath,
72
- distFilePath: distFilePath,
73
- enableVirtualDist: enableVirtualDist
71
+ distFilePath,
72
+ enableVirtualDist
74
73
  });
75
74
  }
76
75
  }
@@ -88,3 +87,9 @@ export var compiler = function(option) {
88
87
  }
89
88
  return virtualDist;
90
89
  };
90
+ export {
91
+ compiler,
92
+ getDistFilePath,
93
+ isRes,
94
+ resolveSourceMap
95
+ };
@@ -1,7 +1,7 @@
1
1
  import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
2
2
  import { _ as _create_class } from "@swc/helpers/_/_create_class";
3
3
  import { _ as _define_property } from "@swc/helpers/_/_define_property";
4
- export var CompilerErrorResult = /* @__PURE__ */ function() {
4
+ var CompilerErrorResult = /* @__PURE__ */ function() {
5
5
  "use strict";
6
6
  function CompilerErrorResult2(initErrorResult) {
7
7
  _class_call_check(this, CompilerErrorResult2);
@@ -12,8 +12,7 @@ export var CompilerErrorResult = /* @__PURE__ */ function() {
12
12
  {
13
13
  key: "init",
14
14
  value: function init(initErrorResult) {
15
- var _initErrorResult;
16
- this._messageDetails = ((_initErrorResult = initErrorResult) === null || _initErrorResult === void 0 ? void 0 : _initErrorResult.messageDetails) || [];
15
+ this._messageDetails = (initErrorResult === null || initErrorResult === void 0 ? void 0 : initErrorResult.messageDetails) || [];
17
16
  }
18
17
  },
19
18
  {
@@ -80,3 +79,6 @@ export var CompilerErrorResult = /* @__PURE__ */ function() {
80
79
  ]);
81
80
  return CompilerErrorResult2;
82
81
  }();
82
+ export {
83
+ CompilerErrorResult
84
+ };
@@ -1,6 +1,9 @@
1
- export var defaultDistFileExtMap = {
1
+ var defaultDistFileExtMap = {
2
2
  ".js": ".js",
3
3
  ".jsx": ".js",
4
4
  ".ts": ".js",
5
5
  ".tsx": ".js"
6
6
  };
7
+ export {
8
+ defaultDistFileExtMap
9
+ };
@@ -11,6 +11,9 @@ var defaultOptions = {
11
11
  verbose: false,
12
12
  clean: false
13
13
  };
14
- export var mergeDefaultOption = function(compilerOptions) {
14
+ var mergeDefaultOption = function(compilerOptions) {
15
15
  return _object_spread({}, defaultOptions, compilerOptions);
16
16
  };
17
+ export {
18
+ mergeDefaultOption
19
+ };
@@ -4,7 +4,7 @@ import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
4
4
  import { glob } from "@modern-js/utils";
5
5
  import { DEFAULT_EXTENSIONS } from "@babel/core";
6
6
  import { mergeDefaultOption } from "./defaults";
7
- export var getGlobPattern = function(dir, extensions) {
7
+ var getGlobPattern = function(dir, extensions) {
8
8
  if (extensions.length > 1) {
9
9
  return "".concat(dir, "/**/*{").concat(extensions.join(","), "}");
10
10
  } else if (extensions.length === 1) {
@@ -13,7 +13,7 @@ export var getGlobPattern = function(dir, extensions) {
13
13
  return "".concat(dir, "/**/*");
14
14
  }
15
15
  };
16
- export var getFinalExtensions = function(extensions) {
16
+ var getFinalExtensions = function(extensions) {
17
17
  var isExtensions = function(ext) {
18
18
  return Array.isArray(ext);
19
19
  };
@@ -28,16 +28,16 @@ export var getFinalExtensions = function(extensions) {
28
28
  return DEFAULT_EXTENSIONS;
29
29
  }
30
30
  };
31
- export var getFilesFromDir = function(param) {
31
+ var getFilesFromDir = function(param) {
32
32
  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;
33
33
  var globFindFilenames = [];
34
34
  var globPattern = getGlobPattern(dir, finalExt);
35
35
  globFindFilenames = glob.sync(globPattern, {
36
- ignore: ignore
36
+ ignore
37
37
  });
38
38
  return globFindFilenames;
39
39
  };
40
- export var getFinalCompilerOption = function(option) {
40
+ var getFinalCompilerOption = function(option) {
41
41
  var optionWithDefault = mergeDefaultOption(option);
42
42
  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;
43
43
  var globFindFilenames = [];
@@ -45,18 +45,24 @@ export var getFinalCompilerOption = function(option) {
45
45
  if (sourceDir) {
46
46
  globFindFilenames = getFilesFromDir({
47
47
  dir: sourceDir,
48
- ignore: ignore,
49
- finalExt: finalExt
48
+ ignore,
49
+ finalExt
50
50
  });
51
51
  }
52
52
  if (enableWatch) {
53
53
  globFindFilenames = getFilesFromDir({
54
54
  dir: watchDir,
55
- ignore: ignore,
56
- finalExt: finalExt
55
+ ignore,
56
+ finalExt
57
57
  });
58
58
  }
59
59
  return _object_spread_props(_object_spread({}, optionWithDefault), {
60
60
  filenames: _to_consumable_array(optionWithDefault.filenames).concat(_to_consumable_array(globFindFilenames))
61
61
  });
62
62
  };
63
+ export {
64
+ getFilesFromDir,
65
+ getFinalCompilerOption,
66
+ getFinalExtensions,
67
+ getGlobPattern
68
+ };
package/dist/esm/index.js CHANGED
@@ -4,7 +4,7 @@ import { getFinalCompilerOption } from "./getFinalOption";
4
4
  import { build } from "./build";
5
5
  import { buildWatch } from "./buildWatch";
6
6
  import { validate } from "./validate";
7
- export function compiler(compilerOptions) {
7
+ function compiler(compilerOptions) {
8
8
  return _compiler.apply(this, arguments);
9
9
  }
10
10
  function _compiler() {
@@ -41,3 +41,6 @@ function _compiler() {
41
41
  }
42
42
  export * from "./buildWatch";
43
43
  export * from "./type";
44
+ export {
45
+ compiler
46
+ };
package/dist/esm/type.js CHANGED
@@ -1 +0,0 @@
1
- export {};
package/dist/esm/utils.js CHANGED
@@ -1,4 +1,7 @@
1
1
  import * as path from "path";
2
- export function addSourceMappingUrl(code, loc) {
2
+ function addSourceMappingUrl(code, loc) {
3
3
  return "".concat(code, "\n//# sourceMappingURL=").concat(path.normalize(path.basename(loc)));
4
4
  }
5
+ export {
6
+ addSourceMappingUrl
7
+ };
@@ -1,7 +1,7 @@
1
1
  import { logger } from "@modern-js/utils";
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) {
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
5
  var sourceDir = compilerOptions.sourceDir, filenames = compilerOptions.filenames, quiet = compilerOptions.quiet;
6
6
  if (!sourceDir && !filenames) {
7
7
  if (!quiet) {
@@ -15,7 +15,7 @@ export var validateSourceDirAndFileNames = function(compilerOptions) {
15
15
  }
16
16
  return null;
17
17
  };
18
- export var validateWatchDir = function(compilerOptions) {
18
+ var validateWatchDir = function(compilerOptions) {
19
19
  var watchDir = compilerOptions.watchDir, enableWatch = compilerOptions.enableWatch, quiet = compilerOptions.quiet;
20
20
  if (enableWatch && !watchDir) {
21
21
  if (!quiet) {
@@ -29,9 +29,16 @@ export var validateWatchDir = function(compilerOptions) {
29
29
  }
30
30
  return null;
31
31
  };
32
- export var validate = function(compilerOptions) {
32
+ var validate = function(compilerOptions) {
33
33
  if (compilerOptions.enableWatch) {
34
34
  return validateWatchDir(compilerOptions);
35
35
  }
36
36
  return validateSourceDirAndFileNames(compilerOptions);
37
37
  };
38
+ export {
39
+ sourceDirAndFileNamesValidMessage,
40
+ validate,
41
+ validateSourceDirAndFileNames,
42
+ validateWatchDir,
43
+ watchDirValidMessage
44
+ };
@@ -1,7 +1,7 @@
1
1
  import { fs, logger } from "@modern-js/utils";
2
2
  import { defaultDistFileExtMap } from "./constants";
3
3
  import { compiler } from "./compiler";
4
- export const build = async (option, babelConfig = {}) => {
4
+ const build = async (option, babelConfig = {}) => {
5
5
  const { rootDir, enableVirtualDist, filenames, clean, distDir, distFileExtMap = defaultDistFileExtMap, verbose = false, quiet = false } = option;
6
6
  const virtualDists = [];
7
7
  if (clean) {
@@ -52,3 +52,6 @@ export const build = async (option, babelConfig = {}) => {
52
52
  virtualDists
53
53
  };
54
54
  };
55
+ export {
56
+ build
57
+ };
@@ -4,12 +4,12 @@ import * as Event from "events";
4
4
  import { logger, watch, WatchChangeType } from "@modern-js/utils";
5
5
  import { build } from "./build";
6
6
  import { CompilerErrorResult } from "./compilerErrorResult";
7
- export const BuildWatchEvent = {
7
+ const BuildWatchEvent = {
8
8
  firstCompiler: "first-compiler",
9
9
  compiling: "compiling",
10
10
  watchingCompiler: "watching-compiler"
11
11
  };
12
- export class BuildWatchEmitter extends Event.EventEmitter {
12
+ class BuildWatchEmitter extends Event.EventEmitter {
13
13
  setInitFn(fn) {
14
14
  this._initFn = fn;
15
15
  }
@@ -24,7 +24,7 @@ export class BuildWatchEmitter extends Event.EventEmitter {
24
24
  _define_property(this, "_initFn", void 0);
25
25
  }
26
26
  }
27
- export const runBuildWatch = async (option, babelConfig = {}, emitter) => {
27
+ const runBuildWatch = async (option, babelConfig = {}, emitter) => {
28
28
  emitter.emit(BuildWatchEvent.compiling);
29
29
  const errorResult = new CompilerErrorResult();
30
30
  const watchDir = option.watchDir;
@@ -81,8 +81,14 @@ export const runBuildWatch = async (option, babelConfig = {}, emitter) => {
81
81
  `${watchDir}/**/*.d.ts`
82
82
  ]);
83
83
  };
84
- export const buildWatch = (option, babelConfig = {}) => {
84
+ const buildWatch = (option, babelConfig = {}) => {
85
85
  const buildWatchEmitter = new BuildWatchEmitter();
86
86
  buildWatchEmitter.setInitFn(runBuildWatch.bind(null, option, babelConfig));
87
87
  return buildWatchEmitter;
88
88
  };
89
+ export {
90
+ BuildWatchEmitter,
91
+ BuildWatchEvent,
92
+ buildWatch,
93
+ runBuildWatch
94
+ };