@modern-js/babel-compiler 2.35.1 → 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/build.js CHANGED
@@ -1,27 +1,40 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "build", {
6
- enumerable: true,
7
- get: function() {
8
- return build;
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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var build_exports = {};
20
+ __export(build_exports, {
21
+ build: () => build
10
22
  });
11
- const _utils = require("@modern-js/utils");
12
- const _constants = require("./constants");
13
- const _compiler = require("./compiler");
23
+ module.exports = __toCommonJS(build_exports);
24
+ var import_utils = require("@modern-js/utils");
25
+ var import_constants = require("./constants");
26
+ var import_compiler = require("./compiler");
14
27
  const build = async (option, babelConfig = {}) => {
15
- const { rootDir, enableVirtualDist, filenames, clean, distDir, distFileExtMap = _constants.defaultDistFileExtMap, verbose = false, quiet = false } = option;
28
+ const { rootDir, enableVirtualDist, filenames, clean, distDir, distFileExtMap = import_constants.defaultDistFileExtMap, verbose = false, quiet = false } = option;
16
29
  const virtualDists = [];
17
30
  if (clean) {
18
- await _utils.fs.remove(distDir);
31
+ await import_utils.fs.remove(distDir);
19
32
  }
20
- _utils.fs.ensureDir(distDir);
33
+ import_utils.fs.ensureDir(distDir);
21
34
  const messageDetails = [];
22
35
  for (const filename of filenames) {
23
36
  try {
24
- const dist = (0, _compiler.compiler)({
37
+ const dist = (0, import_compiler.compiler)({
25
38
  rootDir,
26
39
  enableVirtualDist,
27
40
  filepath: filename,
@@ -44,9 +57,9 @@ const build = async (option, babelConfig = {}) => {
44
57
  const happenError = messageDetails.length > 0;
45
58
  if (!quiet) {
46
59
  if (happenError) {
47
- _utils.logger.error(`Compilation failure ${messageDetails.length} ${messageDetails.length !== 1 ? "files" : "file"} with Babel.`);
60
+ import_utils.logger.error(`Compilation failure ${messageDetails.length} ${messageDetails.length !== 1 ? "files" : "file"} with Babel.`);
48
61
  } else {
49
- _utils.logger.info(`Successfully compiled ${filenames.length} ${filenames.length !== 1 ? "files" : "file"} with Babel.`);
62
+ import_utils.logger.info(`Successfully compiled ${filenames.length} ${filenames.length !== 1 ? "files" : "file"} with Babel.`);
50
63
  }
51
64
  }
52
65
  if (happenError) {
@@ -62,3 +75,7 @@ const build = async (option, babelConfig = {}) => {
62
75
  virtualDists
63
76
  };
64
77
  };
78
+ // Annotate the CommonJS export names for ESM import in node:
79
+ 0 && (module.exports = {
80
+ build
81
+ });
@@ -1,41 +1,51 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
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) => {
6
9
  for (var name in all)
7
- Object.defineProperty(target, name, {
8
- enumerable: true,
9
- get: all[name]
10
- });
11
- }
12
- _export(exports, {
13
- BuildWatchEvent: function() {
14
- return BuildWatchEvent;
15
- },
16
- BuildWatchEmitter: function() {
17
- return BuildWatchEmitter;
18
- },
19
- runBuildWatch: function() {
20
- return runBuildWatch;
21
- },
22
- buildWatch: function() {
23
- return buildWatch;
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 });
24
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 buildWatch_exports = {};
30
+ __export(buildWatch_exports, {
31
+ BuildWatchEmitter: () => BuildWatchEmitter,
32
+ BuildWatchEvent: () => BuildWatchEvent,
33
+ buildWatch: () => buildWatch,
34
+ runBuildWatch: () => runBuildWatch
25
35
  });
26
- const _define_property = require("@swc/helpers/_/_define_property");
27
- const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
28
- const _path = /* @__PURE__ */ _interop_require_wildcard._(require("path"));
29
- const _events = /* @__PURE__ */ _interop_require_wildcard._(require("events"));
30
- const _utils = require("@modern-js/utils");
31
- const _build = require("./build");
32
- const _compilerErrorResult = require("./compilerErrorResult");
36
+ module.exports = __toCommonJS(buildWatch_exports);
37
+ var import_define_property = require("@swc/helpers/_/_define_property");
38
+ var path = __toESM(require("path"));
39
+ var Event = __toESM(require("events"));
40
+ var import_utils = require("@modern-js/utils");
41
+ var import_build = require("./build");
42
+ var import_compilerErrorResult = require("./compilerErrorResult");
33
43
  const BuildWatchEvent = {
34
44
  firstCompiler: "first-compiler",
35
45
  compiling: "compiling",
36
46
  watchingCompiler: "watching-compiler"
37
47
  };
38
- class BuildWatchEmitter extends _events.EventEmitter {
48
+ class BuildWatchEmitter extends Event.EventEmitter {
39
49
  setInitFn(fn) {
40
50
  this._initFn = fn;
41
51
  }
@@ -47,15 +57,15 @@ class BuildWatchEmitter extends _events.EventEmitter {
47
57
  }
48
58
  constructor(...args) {
49
59
  super(...args);
50
- _define_property._(this, "_initFn", void 0);
60
+ (0, import_define_property._)(this, "_initFn", void 0);
51
61
  }
52
62
  }
53
63
  const runBuildWatch = async (option, babelConfig = {}, emitter) => {
54
64
  emitter.emit(BuildWatchEvent.compiling);
55
- const errorResult = new _compilerErrorResult.CompilerErrorResult();
65
+ const errorResult = new import_compilerErrorResult.CompilerErrorResult();
56
66
  const watchDir = option.watchDir;
57
67
  const { distDir, quiet } = option;
58
- const firstBuildResult = await (0, _build.build)(option, babelConfig);
68
+ const firstBuildResult = await (0, import_build.build)(option, babelConfig);
59
69
  const { code } = firstBuildResult;
60
70
  if (code === 1) {
61
71
  errorResult.init(firstBuildResult);
@@ -63,14 +73,14 @@ const runBuildWatch = async (option, babelConfig = {}, emitter) => {
63
73
  } else {
64
74
  emitter.emit(BuildWatchEvent.firstCompiler, firstBuildResult);
65
75
  }
66
- return (0, _utils.watch)(`${watchDir}/**/*.{js,jsx,ts,tsx}`, async ({ changeType, changedFilePath }) => {
76
+ return (0, import_utils.watch)(`${watchDir}/**/*.{js,jsx,ts,tsx}`, async ({ changeType, changedFilePath }) => {
67
77
  emitter.emit(BuildWatchEvent.compiling);
68
- if (changeType === _utils.WatchChangeType.UNLINK) {
78
+ if (changeType === import_utils.WatchChangeType.UNLINK) {
69
79
  const removeFiles = [
70
- _path.normalize(`./${distDir}/${_path.relative(watchDir, changedFilePath)}`)
80
+ path.normalize(`./${distDir}/${path.relative(watchDir, changedFilePath)}`)
71
81
  ];
72
82
  if (!quiet) {
73
- _utils.logger.info(`remove file: ${removeFiles.join(",")}`);
83
+ import_utils.logger.info(`remove file: ${removeFiles.join(",")}`);
74
84
  }
75
85
  const result2 = {
76
86
  code: 0,
@@ -80,7 +90,7 @@ const runBuildWatch = async (option, babelConfig = {}, emitter) => {
80
90
  emitter.emit(BuildWatchEvent.watchingCompiler, result2);
81
91
  return;
82
92
  }
83
- const result = await (0, _build.build)({
93
+ const result = await (0, import_build.build)({
84
94
  ...option,
85
95
  filenames: [
86
96
  changedFilePath
@@ -89,7 +99,7 @@ const runBuildWatch = async (option, babelConfig = {}, emitter) => {
89
99
  if (result.code === 1) {
90
100
  errorResult.update(result.messageDetails || []);
91
101
  emitter.emit(BuildWatchEvent.watchingCompiler, errorResult.value);
92
- !quiet && _utils.logger.info(errorResult.value.message);
102
+ !quiet && import_utils.logger.info(errorResult.value.message);
93
103
  } else {
94
104
  errorResult.removeByFileName(changedFilePath);
95
105
  if (errorResult.checkExistError()) {
@@ -97,10 +107,10 @@ const runBuildWatch = async (option, babelConfig = {}, emitter) => {
97
107
  ...errorResult.value,
98
108
  virtualDists: result.virtualDists
99
109
  });
100
- !quiet && _utils.logger.info(errorResult.value.message);
110
+ !quiet && import_utils.logger.info(errorResult.value.message);
101
111
  } else {
102
112
  emitter.emit(BuildWatchEvent.watchingCompiler, result);
103
- !quiet && _utils.logger.info(result.message);
113
+ !quiet && import_utils.logger.info(result.message);
104
114
  }
105
115
  }
106
116
  }, [
@@ -112,3 +122,10 @@ const buildWatch = (option, babelConfig = {}) => {
112
122
  buildWatchEmitter.setInitFn(runBuildWatch.bind(null, option, babelConfig));
113
123
  return buildWatchEmitter;
114
124
  };
125
+ // Annotate the CommonJS export names for ESM import in node:
126
+ 0 && (module.exports = {
127
+ BuildWatchEmitter,
128
+ BuildWatchEvent,
129
+ buildWatch,
130
+ runBuildWatch
131
+ });
@@ -1,49 +1,59 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
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) => {
6
9
  for (var name in all)
7
- Object.defineProperty(target, name, {
8
- enumerable: true,
9
- get: all[name]
10
- });
11
- }
12
- _export(exports, {
13
- isRes: function() {
14
- return isRes;
15
- },
16
- getDistFilePath: function() {
17
- return getDistFilePath;
18
- },
19
- resolveSourceMap: function() {
20
- return resolveSourceMap;
21
- },
22
- compiler: function() {
23
- return compiler;
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 });
24
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 compiler_exports = {};
30
+ __export(compiler_exports, {
31
+ compiler: () => compiler,
32
+ getDistFilePath: () => getDistFilePath,
33
+ isRes: () => isRes,
34
+ resolveSourceMap: () => resolveSourceMap
25
35
  });
26
- const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
27
- const _path = /* @__PURE__ */ _interop_require_wildcard._(require("path"));
28
- const _core = /* @__PURE__ */ _interop_require_wildcard._(require("@babel/core"));
29
- const _utils = require("@modern-js/utils");
30
- const _utils1 = /* @__PURE__ */ _interop_require_wildcard._(require("./utils"));
31
- const _constants = require("./constants");
36
+ module.exports = __toCommonJS(compiler_exports);
37
+ var path = __toESM(require("path"));
38
+ var babel = __toESM(require("@babel/core"));
39
+ var import_utils = require("@modern-js/utils");
40
+ var utils = __toESM(require("./utils"));
41
+ var import_constants = require("./constants");
32
42
  const defaultDistDir = "dist";
33
43
  const isRes = (r) => Boolean(r);
34
44
  const getDistFilePath = (option) => {
35
45
  const { filepath, rootDir, distDir, extMap } = option;
36
- const ext = _path.extname(filepath);
37
- return _path.join(distDir, _path.relative(rootDir, filepath).replace(ext, extMap[ext]));
46
+ const ext = path.extname(filepath);
47
+ return path.join(distDir, path.relative(rootDir, filepath).replace(ext, extMap[ext]));
38
48
  };
39
49
  const resolveSourceMap = (option) => {
40
50
  const { babelRes, sourceFilePath, distFilePath, enableVirtualDist = false } = option;
41
51
  const mapLoc = `${distFilePath}.map`;
42
- babelRes.code = _utils1.addSourceMappingUrl(babelRes.code, mapLoc);
52
+ babelRes.code = utils.addSourceMappingUrl(babelRes.code, mapLoc);
43
53
  if (babelRes.map) {
44
- babelRes.map.file = _path.basename(distFilePath);
54
+ babelRes.map.file = path.basename(distFilePath);
45
55
  babelRes.map.sources = [
46
- _path.relative(_path.dirname(distFilePath), sourceFilePath)
56
+ path.relative(path.dirname(distFilePath), sourceFilePath)
47
57
  ];
48
58
  }
49
59
  const sourceMapVirtualDist = {
@@ -53,13 +63,13 @@ const resolveSourceMap = (option) => {
53
63
  if (enableVirtualDist) {
54
64
  return sourceMapVirtualDist;
55
65
  }
56
- _utils.fs.ensureDirSync(_path.dirname(mapLoc));
57
- _utils.fs.writeFileSync(mapLoc, JSON.stringify(babelRes.map));
66
+ import_utils.fs.ensureDirSync(path.dirname(mapLoc));
67
+ import_utils.fs.writeFileSync(mapLoc, JSON.stringify(babelRes.map));
58
68
  return sourceMapVirtualDist;
59
69
  };
60
70
  const compiler = (option) => {
61
- const { filepath, rootDir, enableVirtualDist = false, distDir = _path.join(_path.dirname(rootDir), defaultDistDir), verbose = false, babelConfig = {}, distFileExtMap = _constants.defaultDistFileExtMap, quiet = false } = option;
62
- const babelRes = _core.transformFileSync(filepath, babelConfig);
71
+ const { filepath, rootDir, enableVirtualDist = false, distDir = path.join(path.dirname(rootDir), defaultDistDir), verbose = false, babelConfig = {}, distFileExtMap = import_constants.defaultDistFileExtMap, quiet = false } = option;
72
+ const babelRes = babel.transformFileSync(filepath, babelConfig);
63
73
  let virtualDist = null;
64
74
  if (!isRes(babelRes)) {
65
75
  throw new Error(`${filepath} happen error`);
@@ -105,11 +115,18 @@ const compiler = (option) => {
105
115
  code: babelRes.code
106
116
  };
107
117
  } else {
108
- _utils.fs.ensureDirSync(_path.dirname(distFilePath));
109
- _utils.fs.writeFileSync(distFilePath, babelRes.code);
118
+ import_utils.fs.ensureDirSync(path.dirname(distFilePath));
119
+ import_utils.fs.writeFileSync(distFilePath, babelRes.code);
110
120
  }
111
121
  if (verbose && !quiet) {
112
- _utils.logger.info(`${filepath} => ${distFilePath}`);
122
+ import_utils.logger.info(`${filepath} => ${distFilePath}`);
113
123
  }
114
124
  return virtualDist;
115
125
  };
126
+ // Annotate the CommonJS export names for ESM import in node:
127
+ 0 && (module.exports = {
128
+ compiler,
129
+ getDistFilePath,
130
+ isRes,
131
+ resolveSourceMap
132
+ });
@@ -1,14 +1,27 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "CompilerErrorResult", {
6
- enumerable: true,
7
- get: function() {
8
- return CompilerErrorResult;
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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var compilerErrorResult_exports = {};
20
+ __export(compilerErrorResult_exports, {
21
+ CompilerErrorResult: () => CompilerErrorResult
10
22
  });
11
- const _define_property = require("@swc/helpers/_/_define_property");
23
+ module.exports = __toCommonJS(compilerErrorResult_exports);
24
+ var import_define_property = require("@swc/helpers/_/_define_property");
12
25
  class CompilerErrorResult {
13
26
  init(initErrorResult) {
14
27
  this._messageDetails = (initErrorResult === null || initErrorResult === void 0 ? void 0 : initErrorResult.messageDetails) || [];
@@ -42,7 +55,11 @@ class CompilerErrorResult {
42
55
  return this._messageDetails.length > 0;
43
56
  }
44
57
  constructor(initErrorResult) {
45
- _define_property._(this, "_messageDetails", void 0);
58
+ (0, import_define_property._)(this, "_messageDetails", void 0);
46
59
  this.init(initErrorResult);
47
60
  }
48
61
  }
62
+ // Annotate the CommonJS export names for ESM import in node:
63
+ 0 && (module.exports = {
64
+ CompilerErrorResult
65
+ });
@@ -1,16 +1,33 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "defaultDistFileExtMap", {
6
- enumerable: true,
7
- get: function() {
8
- return defaultDistFileExtMap;
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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var constants_exports = {};
20
+ __export(constants_exports, {
21
+ defaultDistFileExtMap: () => defaultDistFileExtMap
10
22
  });
23
+ module.exports = __toCommonJS(constants_exports);
11
24
  const defaultDistFileExtMap = {
12
25
  ".js": ".js",
13
26
  ".jsx": ".js",
14
27
  ".ts": ".js",
15
28
  ".tsx": ".js"
16
29
  };
30
+ // Annotate the CommonJS export names for ESM import in node:
31
+ 0 && (module.exports = {
32
+ defaultDistFileExtMap
33
+ });
@@ -1,20 +1,33 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "mergeDefaultOption", {
6
- enumerable: true,
7
- get: function() {
8
- return mergeDefaultOption;
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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var defaults_exports = {};
20
+ __export(defaults_exports, {
21
+ mergeDefaultOption: () => mergeDefaultOption
10
22
  });
11
- const _constants = require("./constants");
23
+ module.exports = __toCommonJS(defaults_exports);
24
+ var import_constants = require("./constants");
12
25
  const defaultOptions = {
13
26
  enableWatch: false,
14
27
  enableVirtualDist: false,
15
28
  extensions: [],
16
29
  filenames: [],
17
- distFileExtMap: _constants.defaultDistFileExtMap,
30
+ distFileExtMap: import_constants.defaultDistFileExtMap,
18
31
  ignore: [],
19
32
  quiet: false,
20
33
  verbose: false,
@@ -24,3 +37,7 @@ const mergeDefaultOption = (compilerOptions) => ({
24
37
  ...defaultOptions,
25
38
  ...compilerOptions
26
39
  });
40
+ // Annotate the CommonJS export names for ESM import in node:
41
+ 0 && (module.exports = {
42
+ mergeDefaultOption
43
+ });
@@ -1,31 +1,32 @@
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
- getGlobPattern: function() {
14
- return getGlobPattern;
15
- },
16
- getFinalExtensions: function() {
17
- return getFinalExtensions;
18
- },
19
- getFilesFromDir: function() {
20
- return getFilesFromDir;
21
- },
22
- getFinalCompilerOption: function() {
23
- return getFinalCompilerOption;
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 });
24
15
  }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var getFinalOption_exports = {};
20
+ __export(getFinalOption_exports, {
21
+ getFilesFromDir: () => getFilesFromDir,
22
+ getFinalCompilerOption: () => getFinalCompilerOption,
23
+ getFinalExtensions: () => getFinalExtensions,
24
+ getGlobPattern: () => getGlobPattern
25
25
  });
26
- const _utils = require("@modern-js/utils");
27
- const _core = require("@babel/core");
28
- const _defaults = require("./defaults");
26
+ module.exports = __toCommonJS(getFinalOption_exports);
27
+ var import_utils = require("@modern-js/utils");
28
+ var import_core = require("@babel/core");
29
+ var import_defaults = require("./defaults");
29
30
  const getGlobPattern = (dir, extensions) => {
30
31
  if (extensions.length > 1) {
31
32
  return `${dir}/**/*{${extensions.join(",")}}`;
@@ -41,25 +42,25 @@ const getFinalExtensions = (extensions) => {
41
42
  if (isExtensions(extensions)) {
42
43
  return [
43
44
  ...extensions,
44
- ..._core.DEFAULT_EXTENSIONS
45
+ ...import_core.DEFAULT_EXTENSIONS
45
46
  ];
46
47
  } else if (isExtensionsFunc(extensions)) {
47
- return extensions(_core.DEFAULT_EXTENSIONS);
48
+ return extensions(import_core.DEFAULT_EXTENSIONS);
48
49
  } else {
49
- return _core.DEFAULT_EXTENSIONS;
50
+ return import_core.DEFAULT_EXTENSIONS;
50
51
  }
51
52
  };
52
53
  const getFilesFromDir = ({ dir, finalExt = [], ignore = [] }) => {
53
54
  let globFindFilenames = [];
54
55
  const globPattern = getGlobPattern(dir, finalExt);
55
- globFindFilenames = _utils.glob.sync(globPattern, {
56
+ globFindFilenames = import_utils.glob.sync(globPattern, {
56
57
  ignore
57
58
  });
58
59
  return globFindFilenames;
59
60
  };
60
61
  const getFinalCompilerOption = (option) => {
61
- const optionWithDefault = (0, _defaults.mergeDefaultOption)(option);
62
- const { sourceDir, ignore, enableWatch = false, watchDir, extensions = _core.DEFAULT_EXTENSIONS } = option;
62
+ const optionWithDefault = (0, import_defaults.mergeDefaultOption)(option);
63
+ const { sourceDir, ignore, enableWatch = false, watchDir, extensions = import_core.DEFAULT_EXTENSIONS } = option;
63
64
  let globFindFilenames = [];
64
65
  const finalExt = getFinalExtensions(extensions);
65
66
  if (sourceDir) {
@@ -84,3 +85,10 @@ const getFinalCompilerOption = (option) => {
84
85
  ]
85
86
  };
86
87
  };
88
+ // Annotate the CommonJS export names for ESM import in node:
89
+ 0 && (module.exports = {
90
+ getFilesFromDir,
91
+ getFinalCompilerOption,
92
+ getFinalExtensions,
93
+ getGlobPattern
94
+ });