@sanity/pkg-utils 1.18.0 → 1.20.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.
Files changed (107) hide show
  1. package/browserslist.js +15 -0
  2. package/dist/_chunks/{build-f39a3550.js → build-bcb33ba5.js} +19 -19
  3. package/dist/_chunks/build-bcb33ba5.js.map +1 -0
  4. package/dist/_chunks/{buildAction-8f449d1d.js → buildAction-f240dab8.js} +6 -6
  5. package/dist/_chunks/buildAction-f240dab8.js.map +1 -0
  6. package/dist/_chunks/{check-87cbb6cc.js → check-1ea361f5.js} +26 -26
  7. package/dist/_chunks/check-1ea361f5.js.map +1 -0
  8. package/dist/_chunks/{checkAction-e7e455d4.js → checkAction-16be1201.js} +5 -5
  9. package/dist/_chunks/checkAction-16be1201.js.map +1 -0
  10. package/dist/_chunks/{_handleError-869dec25.js → handleError-65cf3242.js} +3 -3
  11. package/dist/_chunks/handleError-65cf3242.js.map +1 -0
  12. package/dist/_chunks/{index-7a851efa.js → index-79fdb33f.js} +63 -63
  13. package/dist/_chunks/index-79fdb33f.js.map +1 -0
  14. package/dist/_chunks/{_resolveBuildContext-7ca7e64e.js → resolveBuildContext-f2feec19.js} +60 -62
  15. package/dist/_chunks/resolveBuildContext-f2feec19.js.map +1 -0
  16. package/dist/_chunks/{watch-f6cf9246.js → watch-02c85f8a.js} +25 -25
  17. package/dist/_chunks/watch-02c85f8a.js.map +1 -0
  18. package/dist/_chunks/{watchAction-4cf253a0.js → watchAction-9cb9681b.js} +6 -6
  19. package/dist/_chunks/watchAction-9cb9681b.js.map +1 -0
  20. package/dist/cli.js +4 -4
  21. package/dist/index.d.ts +44 -46
  22. package/dist/index.esm.js +165 -167
  23. package/dist/index.esm.js.map +1 -1
  24. package/dist/index.js +22 -22
  25. package/dist/index.js.map +1 -1
  26. package/package.json +49 -1
  27. package/src/cli/buildAction.ts +2 -2
  28. package/src/cli/checkAction.ts +2 -2
  29. package/src/cli/{_handleError.ts → handleError.ts} +1 -1
  30. package/src/cli/watchAction.ts +2 -2
  31. package/src/node/build.ts +11 -11
  32. package/src/node/check.ts +11 -11
  33. package/src/node/{_core → core}/config/defineConfig.ts +0 -0
  34. package/src/node/{_core/config/_findConfigFile.ts → core/config/findConfigFile.ts} +3 -3
  35. package/src/node/core/config/index.ts +4 -0
  36. package/src/node/{_core/config/_loadConfig.ts → core/config/loadConfig.ts} +3 -3
  37. package/src/node/{_core/config/_resolveConfigProperty.ts → core/config/resolveConfigProperty.ts} +1 -1
  38. package/src/node/{_core → core}/config/types.ts +0 -0
  39. package/src/node/{_core/_constants.ts → core/constants.ts} +1 -1
  40. package/src/node/{_core → core}/contexts/buildContext.ts +5 -5
  41. package/src/node/{_core → core}/contexts/index.ts +0 -0
  42. package/src/node/core/defaults.ts +7 -0
  43. package/src/node/core/findCommonPath.test.ts +9 -0
  44. package/src/node/{_core/_findCommonPath.ts → core/findCommonPath.ts} +3 -3
  45. package/src/node/{_core → core}/index.ts +3 -3
  46. package/src/node/{_core/_isRecord.ts → core/isRecord.ts} +1 -1
  47. package/src/node/core/pkg/index.ts +4 -0
  48. package/src/node/{_core/pkg/_loadPkg.ts → core/pkg/loadPkg.ts} +4 -4
  49. package/src/node/{_core/pkg/_loadPkgWithReporting.ts → core/pkg/loadPkgWithReporting.ts} +6 -6
  50. package/src/node/{_core/pkg/_parseExports.ts → core/pkg/parseExports.ts} +7 -7
  51. package/src/node/{_core/pkg/_types.ts → core/pkg/types.ts} +1 -1
  52. package/src/node/{_core/pkg/_validateExports.ts → core/pkg/validateExports.ts} +5 -5
  53. package/src/node/{_core/pkg/_validatePkg.ts → core/pkg/validatePkg.ts} +2 -2
  54. package/src/node/core/ts/index.ts +1 -0
  55. package/src/node/{_core/ts/_loadTSConfig.ts → core/ts/loadTSConfig.ts} +1 -1
  56. package/src/node/{_getFilesize.ts → getFilesize.ts} +1 -1
  57. package/src/node/globFiles.ts +5 -0
  58. package/src/node/index.ts +3 -3
  59. package/src/node/{_printExtractMessages.ts → printExtractMessages.ts} +2 -2
  60. package/src/node/{_printPackageTree.ts → printPackageTree.ts} +17 -17
  61. package/src/node/{_resolveBrowserTarget.ts → resolveBrowserTarget.ts} +2 -2
  62. package/src/node/{_resolveBrowserslistVersions.ts → resolveBrowserslistVersions.ts} +11 -11
  63. package/src/node/{_resolveBuildContext.ts → resolveBuildContext.ts} +28 -28
  64. package/src/node/{_resolveBuildTasks.ts → resolveBuildTasks.ts} +13 -13
  65. package/src/node/{_resolveNodeTarget.ts → resolveNodeTarget.ts} +2 -2
  66. package/src/node/{_resolveWatchTasks.ts → resolveWatchTasks.ts} +11 -11
  67. package/src/node/{_spinner.ts → spinner.ts} +1 -1
  68. package/src/node/{_tasks/dts/_DtsError.ts → tasks/dts/DtsError.ts} +1 -1
  69. package/src/node/{_tasks/dts/_buildTypes.ts → tasks/dts/buildTypes.ts} +1 -1
  70. package/src/node/{_tasks/dts/_createApiExtractorConfig.ts → tasks/dts/createApiExtractorConfig.ts} +1 -1
  71. package/src/node/{_tasks/dts/_createTSDocConfig.ts → tasks/dts/createTSDocConfig.ts} +1 -1
  72. package/src/node/{_tasks/dts/_doExtract.ts → tasks/dts/doExtract.ts} +12 -12
  73. package/src/node/{_tasks/dts/_dtsTask.ts → tasks/dts/dtsTask.ts} +10 -10
  74. package/src/node/{_tasks/dts/_dtsWatchTask.ts → tasks/dts/dtsWatchTask.ts} +10 -10
  75. package/src/node/{_tasks/dts/_extractModuleBlocks.ts → tasks/dts/extractModuleBlocks.ts} +3 -3
  76. package/src/node/{_tasks/dts/_extractTypes.ts → tasks/dts/extractTypes.ts} +11 -11
  77. package/src/node/{_tasks/dts/_getExtractMessagesConfig.ts → tasks/dts/getExtractMessagesConfig.ts} +12 -12
  78. package/src/node/tasks/dts/index.ts +4 -0
  79. package/src/node/{_tasks/dts/_types.ts → tasks/dts/types.ts} +3 -3
  80. package/src/node/tasks/index.ts +19 -0
  81. package/src/node/tasks/rollup/index.ts +2 -0
  82. package/src/node/{_tasks/rollup/_resolveRollupConfig.ts → tasks/rollup/resolveRollupConfig.ts} +16 -11
  83. package/src/node/{_tasks/rollup/_rollupTask.ts → tasks/rollup/rollupTask.ts} +7 -7
  84. package/src/node/{_tasks/rollup/_rollupWatchTask.ts → tasks/rollup/rollupWatchTask.ts} +4 -4
  85. package/src/node/tasks/types.ts +57 -0
  86. package/src/node/watch.ts +13 -13
  87. package/src/node/{_watchConfigFiles.ts → watchConfigFiles.ts} +5 -5
  88. package/src/node/{_watchFiles.ts → watchFiles.ts} +5 -5
  89. package/dist/_chunks/_handleError-869dec25.js.map +0 -1
  90. package/dist/_chunks/_resolveBuildContext-7ca7e64e.js.map +0 -1
  91. package/dist/_chunks/build-f39a3550.js.map +0 -1
  92. package/dist/_chunks/buildAction-8f449d1d.js.map +0 -1
  93. package/dist/_chunks/check-87cbb6cc.js.map +0 -1
  94. package/dist/_chunks/checkAction-e7e455d4.js.map +0 -1
  95. package/dist/_chunks/index-7a851efa.js.map +0 -1
  96. package/dist/_chunks/watch-f6cf9246.js.map +0 -1
  97. package/dist/_chunks/watchAction-4cf253a0.js.map +0 -1
  98. package/src/node/_core/_defaults.ts +0 -9
  99. package/src/node/_core/_findCommonPath.test.ts +0 -9
  100. package/src/node/_core/config/index.ts +0 -4
  101. package/src/node/_core/pkg/index.ts +0 -4
  102. package/src/node/_core/ts/index.ts +0 -1
  103. package/src/node/_globFiles.ts +0 -5
  104. package/src/node/_tasks/_types.ts +0 -57
  105. package/src/node/_tasks/dts/index.ts +0 -4
  106. package/src/node/_tasks/index.ts +0 -19
  107. package/src/node/_tasks/rollup/index.ts +0 -2
package/dist/index.esm.js CHANGED
@@ -39,7 +39,7 @@ import prettyBytes from 'pretty-bytes';
39
39
  import { scan, startWith, distinctUntilChanged } from 'rxjs/operators';
40
40
  import globby from 'globby';
41
41
  import chokidar from 'chokidar';
42
- const _MODULE_EXT = {
42
+ const MODULE_EXT = {
43
43
  commonjs: {
44
44
  commonjs: ".js",
45
45
  esm: ".esm.js"
@@ -49,14 +49,12 @@ const _MODULE_EXT = {
49
49
  esm: ".js"
50
50
  }
51
51
  };
52
- const _DEFAULTS = {
53
- browserslist: ["> 0.2% and supports es6-module and supports es6-module-dynamic-import", "not dead", "not IE 11", "maintained node versions"]
54
- };
55
- function _isRecord(value) {
52
+ const DEFAULT_BROWSERSLIST_QUERY = ["> 0.2% and supports es6-module and supports es6-module-dynamic-import", "not dead", "not IE 11", "maintained node versions"];
53
+ function isRecord(value) {
56
54
  return Boolean(value) && !Array.isArray(value) && typeof value === "object";
57
55
  }
58
56
  const CONFIG_FILE_NAMES = ["package.config.ts", "package.config.js", "package.config.cjs", "package.config.mjs"];
59
- async function _findConfigFile(cwd) {
57
+ async function findConfigFile(cwd) {
60
58
  const pkgJsonPath = findConfig("package.json", {
61
59
  cwd
62
60
  });
@@ -64,14 +62,14 @@ async function _findConfigFile(cwd) {
64
62
  const pkgPath = path.dirname(pkgJsonPath);
65
63
  for (const fileName of CONFIG_FILE_NAMES) {
66
64
  const configPath = path.resolve(pkgPath, fileName);
67
- const exists = await _fileExists$1(configPath);
65
+ const exists = await fileExists$1(configPath);
68
66
  if (exists) {
69
67
  return configPath;
70
68
  }
71
69
  }
72
70
  return void 0;
73
71
  }
74
- async function _fileExists$1(filePath) {
72
+ async function fileExists$1(filePath) {
75
73
  try {
76
74
  await stat(filePath);
77
75
  return true;
@@ -79,7 +77,7 @@ async function _fileExists$1(filePath) {
79
77
  return false;
80
78
  }
81
79
  }
82
- async function _loadConfig(options) {
80
+ async function loadConfig(options) {
83
81
  const {
84
82
  cwd
85
83
  } = options;
@@ -88,7 +86,7 @@ async function _loadConfig(options) {
88
86
  });
89
87
  if (!pkgPath) return void 0;
90
88
  const root = path.dirname(pkgPath);
91
- const configFile = await _findConfigFile(root);
89
+ const configFile = await findConfigFile(root);
92
90
  if (!configFile) {
93
91
  return void 0;
94
92
  }
@@ -108,7 +106,7 @@ async function _loadConfig(options) {
108
106
  return void 0;
109
107
  }
110
108
  }
111
- function _resolveConfigProperty(prop, initialValue) {
109
+ function resolveConfigProperty(prop, initialValue) {
112
110
  if (!prop) return initialValue;
113
111
  if (typeof prop === "function") {
114
112
  return prop(initialValue);
@@ -151,13 +149,13 @@ const pkgSchema = z.object({
151
149
  })]))),
152
150
  browserslist: z.optional(z.array(z.string()))
153
151
  });
154
- function _validatePkg(input) {
152
+ function validatePkg(input) {
155
153
  const pkg = pkgSchema.parse(input);
156
154
  return _objectSpread(_objectSpread({}, pkg), {}, {
157
155
  type: pkg.type || "commonjs"
158
156
  });
159
157
  }
160
- async function _loadPkg(options) {
158
+ async function loadPkg(options) {
161
159
  const {
162
160
  cwd
163
161
  } = options;
@@ -166,16 +164,16 @@ async function _loadPkg(options) {
166
164
  });
167
165
  if (!pkgPath) throw new Error("no package.json found");
168
166
  const buf = await fs.readFile(pkgPath);
169
- return _validatePkg(JSON.parse(buf.toString()));
167
+ return validatePkg(JSON.parse(buf.toString()));
170
168
  }
171
- async function _loadPkgWithReporting(options) {
169
+ async function loadPkgWithReporting(options) {
172
170
  try {
173
- return await _loadPkg(options);
171
+ return await loadPkg(options);
174
172
  } catch (err) {
175
173
  if (err instanceof ZodError) {
176
174
  for (const issue of err.issues) {
177
175
  if (issue.code === "invalid_type") {
178
- console.log(["".concat(chalk.red("fail"), " `").concat(_formatPath(issue.path), "` "), "in ./package.json must be of type ".concat(chalk.magenta(issue.expected), " "), "(received ".concat(chalk.magenta(issue.received), ")")].join(""));
176
+ console.log(["".concat(chalk.red("fail"), " `").concat(formatPath(issue.path), "` "), "in ./package.json must be of type ".concat(chalk.magenta(issue.expected), " "), "(received ".concat(chalk.magenta(issue.received), ")")].join(""));
179
177
  }
180
178
  }
181
179
  } else {
@@ -184,7 +182,7 @@ async function _loadPkgWithReporting(options) {
184
182
  process.exit(1);
185
183
  }
186
184
  }
187
- function _formatPath(segments) {
185
+ function formatPath(segments) {
188
186
  return segments.map((s, idx) => {
189
187
  if (idx === 0) return s;
190
188
  if (typeof s === "number") {
@@ -196,11 +194,11 @@ function _formatPath(segments) {
196
194
  return ".".concat(s);
197
195
  }).join("");
198
196
  }
199
- function _validateExports(_exports, options) {
197
+ function validateExports(_exports, options) {
200
198
  const {
201
199
  pkg
202
200
  } = options;
203
- const ext = _MODULE_EXT[pkg.type];
201
+ const ext = MODULE_EXT[pkg.type];
204
202
  const errors = [];
205
203
  for (const exp of _exports) {
206
204
  if (exp.require && !exp.require.endsWith(ext.commonjs)) {
@@ -212,7 +210,7 @@ function _validateExports(_exports, options) {
212
210
  }
213
211
  return errors;
214
212
  }
215
- function _parseExports(options) {
213
+ function parseExports(options) {
216
214
  const {
217
215
  pkg,
218
216
  strict
@@ -244,7 +242,7 @@ function _parseExports(options) {
244
242
  errors.push('package.json: `exports["./package.json"] must be "./package.json".');
245
243
  }
246
244
  }
247
- } else if (_isRecord(exportEntry)) {
245
+ } else if (isRecord(exportEntry)) {
248
246
  if (exportPath === ".") {
249
247
  if (exportEntry.require && rootExport.require && exportEntry.require !== rootExport.require) {
250
248
  errors.push('package.json: mismatch between "main" and "exports.require". These must be equal.');
@@ -272,7 +270,7 @@ function _parseExports(options) {
272
270
  }
273
271
  }
274
272
  const _exports = [rootExport, ...extraExports];
275
- errors.push(..._validateExports(_exports, {
273
+ errors.push(...validateExports(_exports, {
276
274
  pkg
277
275
  }));
278
276
  if (errors.length) {
@@ -280,7 +278,7 @@ function _parseExports(options) {
280
278
  }
281
279
  return _exports;
282
280
  }
283
- async function _loadTSConfig(options) {
281
+ async function loadTSConfig(options) {
284
282
  const {
285
283
  cwd,
286
284
  tsconfigPath
@@ -292,7 +290,7 @@ async function _loadTSConfig(options) {
292
290
  const configFile = ts.readConfigFile(configPath, ts.sys.readFile);
293
291
  return ts.parseJsonConfigFileContent(configFile.config, ts.sys, cwd);
294
292
  }
295
- function _resolveBuildTasks(ctx) {
293
+ function resolveBuildTasks(ctx) {
296
294
  var _a, _b, _c, _d, _e;
297
295
  const {
298
296
  config,
@@ -313,7 +311,7 @@ function _resolveBuildTasks(ctx) {
313
311
  entries: []
314
312
  };
315
313
  const rollupTasks = {};
316
- function _addRollupTaskEntry(format, runtime, entry) {
314
+ function addRollupTaskEntry(format, runtime, entry) {
317
315
  const buildId = "".concat(format, ":").concat(runtime);
318
316
  if (rollupTasks[buildId]) {
319
317
  rollupTasks[buildId].entries.push(entry);
@@ -346,7 +344,7 @@ function _resolveBuildTasks(ctx) {
346
344
  for (const exp of exports) {
347
345
  const output = exp.require;
348
346
  if (!output) continue;
349
- _addRollupTaskEntry("commonjs", ctx.runtime, {
347
+ addRollupTaskEntry("commonjs", ctx.runtime, {
350
348
  path: exp._path,
351
349
  source: exp.source,
352
350
  output
@@ -355,7 +353,7 @@ function _resolveBuildTasks(ctx) {
355
353
  for (const exp of exports) {
356
354
  const output = exp.import;
357
355
  if (!output) continue;
358
- _addRollupTaskEntry("esm", ctx.runtime, {
356
+ addRollupTaskEntry("esm", ctx.runtime, {
359
357
  path: exp._path,
360
358
  source: exp.source,
361
359
  output
@@ -364,7 +362,7 @@ function _resolveBuildTasks(ctx) {
364
362
  for (const exp of exports) {
365
363
  const output = (_a = exp.browser) == null ? void 0 : _a.require;
366
364
  if (!output) continue;
367
- _addRollupTaskEntry("commonjs", "browser", {
365
+ addRollupTaskEntry("commonjs", "browser", {
368
366
  path: exp._path,
369
367
  source: ((_b = exp.browser) == null ? void 0 : _b.source) || exp.source,
370
368
  output
@@ -373,7 +371,7 @@ function _resolveBuildTasks(ctx) {
373
371
  for (const exp of exports) {
374
372
  const output = (_c = exp.browser) == null ? void 0 : _c.import;
375
373
  if (!output) continue;
376
- _addRollupTaskEntry("esm", "browser", {
374
+ addRollupTaskEntry("esm", "browser", {
377
375
  path: exp._path,
378
376
  source: ((_d = exp.browser) == null ? void 0 : _d.source) || exp.source,
379
377
  output
@@ -381,14 +379,14 @@ function _resolveBuildTasks(ctx) {
381
379
  }
382
380
  for (const bundle of bundles) {
383
381
  if (bundle.require) {
384
- _addRollupTaskEntry("commonjs", bundle.runtime || ctx.runtime, {
382
+ addRollupTaskEntry("commonjs", bundle.runtime || ctx.runtime, {
385
383
  path: "__bundle__",
386
384
  source: bundle.source,
387
385
  output: bundle.require
388
386
  });
389
387
  }
390
388
  if (bundle.import) {
391
- _addRollupTaskEntry("commonjs", bundle.runtime || ctx.runtime, {
389
+ addRollupTaskEntry("commonjs", bundle.runtime || ctx.runtime, {
392
390
  path: "__bundle__",
393
391
  source: bundle.source,
394
392
  output: bundle.import
@@ -409,7 +407,7 @@ function _resolveBuildTasks(ctx) {
409
407
  }
410
408
  return tasks;
411
409
  }
412
- function _printExtractMessages(ctx, messages) {
410
+ function printExtractMessages(ctx, messages) {
413
411
  const {
414
412
  cwd,
415
413
  logger
@@ -442,7 +440,7 @@ const formatHost = {
442
440
  getNewLine: () => ts.sys.newLine,
443
441
  getCanonicalFileName: ts.sys.useCaseSensitiveFileNames ? f => f : f => f.toLowerCase()
444
442
  };
445
- async function _buildTypes(options) {
443
+ async function buildTypes(options) {
446
444
  const {
447
445
  outDir,
448
446
  tsconfig,
@@ -480,13 +478,13 @@ async function _buildTypes(options) {
480
478
  }
481
479
  }
482
480
  }
483
- class _DtsError extends Error {
481
+ class DtsError extends Error {
484
482
  constructor(message, messages) {
485
483
  super(message);
486
484
  this.messages = messages;
487
485
  }
488
486
  }
489
- function _createApiExtractorConfig(options) {
487
+ function createApiExtractorConfig(options) {
490
488
  const {
491
489
  distPath,
492
490
  exportPath,
@@ -520,7 +518,7 @@ function _createApiExtractorConfig(options) {
520
518
  projectFolder
521
519
  };
522
520
  }
523
- async function _createTSDocConfig(opts) {
521
+ async function createTSDocConfig(opts) {
524
522
  const {
525
523
  customTags
526
524
  } = opts;
@@ -544,7 +542,7 @@ async function _createTSDocConfig(opts) {
544
542
  supportForTags
545
543
  }));
546
544
  }
547
- async function _extractModuleBlocksFromTypes(_ref2) {
545
+ async function extractModuleBlocksFromTypes(_ref2) {
548
546
  let {
549
547
  tsOutDir,
550
548
  extractResult
@@ -555,30 +553,30 @@ async function _extractModuleBlocksFromTypes(_ref2) {
555
553
  const sourceFiles = allProgramFiles.filter(sourceFile => sourceFile.fileName.includes(tsOutDir));
556
554
  for (const sourceFile of sourceFiles) {
557
555
  if (sourceFile.text.includes("declare module")) {
558
- moduleBlocks.push(..._extractModuleBlocks(sourceFile.text));
556
+ moduleBlocks.push(...extractModuleBlocks(sourceFile.text));
559
557
  }
560
558
  }
561
559
  return moduleBlocks;
562
560
  }
563
- function _extractModuleBlocks(fileContent) {
561
+ function extractModuleBlocks(fileContent) {
564
562
  const ast = parse$1(fileContent, {
565
563
  parser: typeScriptParser
566
564
  });
567
565
  return ast.program.body.filter(node => node.type === "TSModuleDeclaration").map(node => print(node).code);
568
566
  }
569
- const _LOG_LEVELS = {
567
+ const LOG_LEVELS = {
570
568
  error: "error",
571
569
  info: "info",
572
570
  off: "none",
573
571
  warn: "warning"
574
572
  };
575
- function _getExtractMessagesConfig(options) {
573
+ function getExtractMessagesConfig(options) {
576
574
  const {
577
575
  rules
578
576
  } = options;
579
- function _ruleToLogLevel(key, defaultLevel) {
577
+ function ruleToLogLevel(key, defaultLevel) {
580
578
  const r = rules == null ? void 0 : rules[key];
581
- return r ? _LOG_LEVELS[r] : defaultLevel || "warning";
579
+ return r ? LOG_LEVELS[r] : defaultLevel || "warning";
582
580
  }
583
581
  return {
584
582
  compilerMessageReporting: {
@@ -592,19 +590,19 @@ function _getExtractMessagesConfig(options) {
592
590
  addToApiReportFile: false
593
591
  },
594
592
  "ae-forgotten-export": {
595
- logLevel: _ruleToLogLevel("ae-forgotten-export", "error"),
593
+ logLevel: ruleToLogLevel("ae-forgotten-export", "error"),
596
594
  addToApiReportFile: false
597
595
  },
598
596
  "ae-incompatible-release-tags": {
599
- logLevel: _ruleToLogLevel("ae-incompatible-release-tags", "error"),
597
+ logLevel: ruleToLogLevel("ae-incompatible-release-tags", "error"),
600
598
  addToApiReportFile: false
601
599
  },
602
600
  "ae-internal-missing-underscore": {
603
- logLevel: _ruleToLogLevel("ae-internal-missing-underscore"),
601
+ logLevel: ruleToLogLevel("ae-internal-missing-underscore"),
604
602
  addToApiReportFile: false
605
603
  },
606
604
  "ae-missing-release-tag": {
607
- logLevel: _ruleToLogLevel("ae-missing-release-tag", "error"),
605
+ logLevel: ruleToLogLevel("ae-missing-release-tag", "error"),
608
606
  addToApiReportFile: false
609
607
  },
610
608
  "ae-wrong-input-file-type": {
@@ -618,21 +616,21 @@ function _getExtractMessagesConfig(options) {
618
616
  addToApiReportFile: false
619
617
  },
620
618
  "tsdoc-link-tag-unescaped-text": {
621
- logLevel: _ruleToLogLevel("tsdoc-link-tag-unescaped-text", "warning"),
619
+ logLevel: ruleToLogLevel("tsdoc-link-tag-unescaped-text", "warning"),
622
620
  addToApiReportFile: false
623
621
  },
624
622
  "tsdoc-undefined-tag": {
625
- logLevel: _ruleToLogLevel("tsdoc-undefined-tag", "error"),
623
+ logLevel: ruleToLogLevel("tsdoc-undefined-tag", "error"),
626
624
  addToApiReportFile: false
627
625
  },
628
626
  "tsdoc-unsupported-tag": {
629
- logLevel: _ruleToLogLevel("tsdoc-unsupported-tag", "none"),
627
+ logLevel: ruleToLogLevel("tsdoc-unsupported-tag", "none"),
630
628
  addToApiReportFile: false
631
629
  }
632
630
  }
633
631
  };
634
632
  }
635
- async function _extractTypes(options) {
633
+ async function extractTypes(options) {
636
634
  const {
637
635
  customTags,
638
636
  distPath,
@@ -645,15 +643,15 @@ async function _extractTypes(options) {
645
643
  tmpPath,
646
644
  tsconfigPath
647
645
  } = options;
648
- const tsdocConfigFile = await _createTSDocConfig({
646
+ const tsdocConfigFile = await createTSDocConfig({
649
647
  customTags: customTags || []
650
648
  });
651
649
  const extractorConfig = ExtractorConfig.prepare({
652
- configObject: _createApiExtractorConfig({
650
+ configObject: createApiExtractorConfig({
653
651
  distPath,
654
652
  exportPath,
655
653
  filePath,
656
- messages: _getExtractMessagesConfig({
654
+ messages: getExtractMessagesConfig({
657
655
  rules
658
656
  }),
659
657
  projectFolder: projectPath,
@@ -677,7 +675,7 @@ async function _extractTypes(options) {
677
675
  const typesBuf = await fs.readFile(typesPath);
678
676
  const prettierConfig = await prettier.resolveConfig(typesPath);
679
677
  await mkdirp(path.dirname(typesPath));
680
- const moduleBlocks = await _extractModuleBlocksFromTypes({
678
+ const moduleBlocks = await extractModuleBlocksFromTypes({
681
679
  extractResult: extractorResult,
682
680
  tsOutDir: tmpPath
683
681
  });
@@ -695,7 +693,7 @@ async function _extractTypes(options) {
695
693
  };
696
694
  }
697
695
  const rimraf = promisify(rimrafCallback);
698
- async function _doExtract(ctx, task) {
696
+ async function doExtract(ctx, task) {
699
697
  var _a, _b;
700
698
  const {
701
699
  config,
@@ -719,7 +717,7 @@ async function _doExtract(ctx, task) {
719
717
  throw new Error("tsconfig.json is missing `compilerOptions.outDir`");
720
718
  }
721
719
  const tmpPath = path.resolve(outDir, "__tmp__");
722
- await _buildTypes({
720
+ await buildTypes({
723
721
  cwd,
724
722
  outDir: tmpPath,
725
723
  strict,
@@ -732,7 +730,7 @@ async function _doExtract(ctx, task) {
732
730
  const sourceTypesPath = path.resolve(tmpPath, path.relative(rootDir, path.resolve(cwd, entry.sourcePath)).replace(/\.ts$/, ".d.ts"));
733
731
  const targetPath = path.resolve(cwd, entry.targetPath);
734
732
  const filePath = path.relative(outDir, targetPath);
735
- const result = await _extractTypes({
733
+ const result = await extractTypes({
736
734
  customTags: (_a = config == null ? void 0 : config.extract) == null ? void 0 : _a.customTags,
737
735
  cwd,
738
736
  distPath: outDir,
@@ -748,7 +746,7 @@ async function _doExtract(ctx, task) {
748
746
  messages.push(...result.messages);
749
747
  if (result.messages.some(msg => msg.logLevel === "error")) {
750
748
  await rimraf(tmpPath);
751
- throw new _DtsError("encountered errors when extracting types", result.messages);
749
+ throw new DtsError("encountered errors when extracting types", result.messages);
752
750
  }
753
751
  results.push({
754
752
  sourcePath: path.resolve(cwd, entry.sourcePath),
@@ -762,11 +760,11 @@ async function _doExtract(ctx, task) {
762
760
  results
763
761
  };
764
762
  }
765
- const _dtsTask = {
763
+ const dtsTask = {
766
764
  name: (_ctx, task) => ["build type definitions", ...task.entries.map(entry => " ".concat(chalk.blue(entry.importId), ": ").concat(entry.sourcePath, " -> ").concat(entry.targetPath))].join("\n"),
767
765
  exec: (ctx, task) => {
768
766
  return new Observable(observer => {
769
- _doExtract(ctx, task).then(result => {
767
+ doExtract(ctx, task).then(result => {
770
768
  observer.next(result);
771
769
  observer.complete();
772
770
  }).catch(err => {
@@ -775,24 +773,24 @@ const _dtsTask = {
775
773
  });
776
774
  },
777
775
  complete: (ctx, _task, result) => {
778
- _printExtractMessages(ctx, result.messages);
776
+ printExtractMessages(ctx, result.messages);
779
777
  },
780
778
  error: (ctx, _task, err) => {
781
779
  const {
782
780
  logger
783
781
  } = ctx;
784
- if (err instanceof _DtsError) {
785
- _printExtractMessages(ctx, err.messages);
782
+ if (err instanceof DtsError) {
783
+ printExtractMessages(ctx, err.messages);
786
784
  } else if (err instanceof Error) {
787
785
  logger.error(err);
788
786
  }
789
787
  }
790
788
  };
791
- const _dtsWatchTask = {
789
+ const dtsWatchTask = {
792
790
  name: (_ctx, task) => ["build type definitions", ...task.entries.map(entry => " ".concat(chalk.blue(entry.importId), ": ").concat(entry.sourcePath, " -> ").concat(entry.targetPath))].join("\n"),
793
791
  exec: (ctx, task) => {
794
792
  return new Observable(observer => {
795
- _doExtract(ctx, task).then(result => {
793
+ doExtract(ctx, task).then(result => {
796
794
  observer.next(result);
797
795
  observer.complete();
798
796
  }).catch(err => observer.error(err));
@@ -802,7 +800,7 @@ const _dtsWatchTask = {
802
800
  const {
803
801
  logger
804
802
  } = ctx;
805
- _printExtractMessages(ctx, result.messages);
803
+ printExtractMessages(ctx, result.messages);
806
804
  logger.warn("watching typescript definitions is currently not supported");
807
805
  logger.log();
808
806
  },
@@ -810,14 +808,14 @@ const _dtsWatchTask = {
810
808
  const {
811
809
  logger
812
810
  } = ctx;
813
- if (err instanceof _DtsError) {
814
- _printExtractMessages(ctx, err.messages);
811
+ if (err instanceof DtsError) {
812
+ printExtractMessages(ctx, err.messages);
815
813
  } else if (err instanceof Error) {
816
814
  logger.error(err);
817
815
  }
818
816
  }
819
817
  };
820
- function _resolveRollupConfig(ctx, buildTask) {
818
+ function resolveRollupConfig(ctx, buildTask) {
821
819
  var _ref3, _ref6, _ref7, _ref8, _ref9, _ref10;
822
820
  var _a, _b, _c;
823
821
  const {
@@ -835,7 +833,7 @@ function _resolveRollupConfig(ctx, buildTask) {
835
833
  pkg,
836
834
  ts
837
835
  } = ctx;
838
- const outputExt = _MODULE_EXT[pkg.type][format];
836
+ const outputExt = MODULE_EXT[pkg.type][format];
839
837
  const minify = (_ref3 = config == null ? void 0 : config.minify) !== null && _ref3 !== void 0 ? _ref3 : true;
840
838
  const outDir = path.relative(cwd, distPath);
841
839
  const pathAliases = Object.fromEntries(Object.entries(((_a = ts.config) == null ? void 0 : _a.options.paths) || {}).map(_ref4 => {
@@ -890,7 +888,7 @@ function _resolveRollupConfig(ctx, buildTask) {
890
888
  babelrc: false,
891
889
  plugins: ["@babel/plugin-proposal-object-rest-spread"],
892
890
  presets: [["@babel/preset-env", {
893
- targets: pkg.browserslist || _DEFAULTS.browserslist
891
+ targets: pkg.browserslist || DEFAULT_BROWSERSLIST_QUERY
894
892
  }]]
895
893
  }), minify && terser({
896
894
  output: {
@@ -905,7 +903,7 @@ function _resolveRollupConfig(ctx, buildTask) {
905
903
  }
906
904
  })].filter(Boolean);
907
905
  const userPlugins = (_b = config == null ? void 0 : config.rollup) == null ? void 0 : _b.plugins;
908
- const plugins = Array.isArray(userPlugins) ? defaultPlugins.concat(userPlugins) : _resolveConfigProperty((_c = config == null ? void 0 : config.rollup) == null ? void 0 : _c.plugins, defaultPlugins);
906
+ const plugins = Array.isArray(userPlugins) ? defaultPlugins.concat(userPlugins) : resolveConfigProperty((_c = config == null ? void 0 : config.rollup) == null ? void 0 : _c.plugins, defaultPlugins);
909
907
  return {
910
908
  inputOptions: {
911
909
  context: cwd,
@@ -952,11 +950,11 @@ function _resolveRollupConfig(ctx, buildTask) {
952
950
  }
953
951
  };
954
952
  }
955
- const _rollupTask = {
953
+ const rollupTask = {
956
954
  name: (ctx, task) => "build javascript files (target ".concat(task.target.join(" + "), ", format ").concat(task.format, ")\n ").concat(task.entries.map(e => "".concat(chalk.blue(path.join(ctx.pkg.name, e.path)), ": ").concat(e.source, " -> ").concat(e.output)).join("\n ")),
957
955
  exec: (ctx, task) => {
958
956
  return new Observable(observer => {
959
- _execPromise(ctx, task).then(result => {
957
+ execPromise(ctx, task).then(result => {
960
958
  observer.next(result);
961
959
  observer.complete();
962
960
  }).catch(err => observer.error(err));
@@ -969,7 +967,7 @@ const _rollupTask = {
969
967
  }
970
968
  }
971
969
  };
972
- async function _execPromise(ctx, task) {
970
+ async function execPromise(ctx, task) {
973
971
  const {
974
972
  files,
975
973
  distPath
@@ -978,7 +976,7 @@ async function _execPromise(ctx, task) {
978
976
  const {
979
977
  inputOptions,
980
978
  outputOptions
981
- } = _resolveRollupConfig(ctx, task);
979
+ } = resolveRollupConfig(ctx, task);
982
980
  const bundle = await rollup(inputOptions);
983
981
  const {
984
982
  output
@@ -999,13 +997,13 @@ async function _execPromise(ctx, task) {
999
997
  await bundle.write(outputOptions);
1000
998
  await bundle.close();
1001
999
  }
1002
- const _rollupWatchTask = {
1000
+ const rollupWatchTask = {
1003
1001
  name: (ctx, task) => "build javascript files (target ".concat(task.target.join(" + "), ", format ").concat(task.format, ")\n ").concat(task.entries.map(e => "".concat(chalk.blue(path.join(ctx.pkg.name, e.path)), ": ").concat(e.source, " -> ").concat(e.output)).join("\n ")),
1004
1002
  exec: (ctx, task) => {
1005
1003
  const {
1006
1004
  inputOptions,
1007
1005
  outputOptions
1008
- } = _resolveRollupConfig(ctx, task);
1006
+ } = resolveRollupConfig(ctx, task);
1009
1007
  return new Observable(observer => {
1010
1008
  const watchOptions = _objectSpread(_objectSpread({}, inputOptions), {}, {
1011
1009
  output: outputOptions
@@ -1051,18 +1049,18 @@ const _rollupWatchTask = {
1051
1049
  }
1052
1050
  }
1053
1051
  };
1054
- const _buildTaskHandlers = {
1055
- "build:dts": _dtsTask,
1056
- "build:js": _rollupTask
1052
+ const buildTaskHandlers = {
1053
+ "build:dts": dtsTask,
1054
+ "build:js": rollupTask
1057
1055
  };
1058
- const _watchTaskHandlers = {
1059
- "watch:dts": _dtsWatchTask,
1060
- "watch:js": _rollupWatchTask
1056
+ const watchTaskHandlers = {
1057
+ "watch:dts": dtsWatchTask,
1058
+ "watch:js": rollupWatchTask
1061
1059
  };
1062
- function _pathContains(containerPath, itemPath) {
1060
+ function pathContains(containerPath, itemPath) {
1063
1061
  return !path.relative(containerPath, itemPath).startsWith("..");
1064
1062
  }
1065
- function _findCommonDirPath(filePaths) {
1063
+ function findCommonDirPath(filePaths) {
1066
1064
  let ret = void 0;
1067
1065
  for (const filePath of filePaths) {
1068
1066
  let dirPath = path.dirname(filePath);
@@ -1075,7 +1073,7 @@ function _findCommonDirPath(filePaths) {
1075
1073
  if (dirPath === ret) {
1076
1074
  break;
1077
1075
  }
1078
- if (_pathContains(dirPath, ret)) {
1076
+ if (pathContains(dirPath, ret)) {
1079
1077
  ret = dirPath;
1080
1078
  break;
1081
1079
  }
@@ -1084,12 +1082,12 @@ function _findCommonDirPath(filePaths) {
1084
1082
  }
1085
1083
  return ret;
1086
1084
  }
1087
- function _sortAsNumber(a, b) {
1085
+ function sortAsNumber(a, b) {
1088
1086
  const aVersion = Number(a);
1089
1087
  const bVersion = Number(b);
1090
1088
  return aVersion - bVersion;
1091
1089
  }
1092
- function _resolveBrowserslistVersions(query) {
1090
+ function resolveBrowserslistVersions(query) {
1093
1091
  const result = browserslist(query);
1094
1092
  const entries = result.map(key => {
1095
1093
  const [name, version] = key.split(" ");
@@ -1116,16 +1114,16 @@ function _resolveBrowserslistVersions(query) {
1116
1114
  opera: opera.map(b => b.version),
1117
1115
  node: node.map(b => b.version)
1118
1116
  };
1119
- versions.chrome.sort(_sortAsNumber);
1120
- versions.ff.sort(_sortAsNumber);
1121
- versions.edge.sort(_sortAsNumber);
1122
- versions.iosSaf.sort(_sortAsNumber);
1123
- versions.saf.sort(_sortAsNumber);
1124
- versions.opera.sort(_sortAsNumber);
1125
- versions.node.sort(_sortAsNumber);
1117
+ versions.chrome.sort(sortAsNumber);
1118
+ versions.ff.sort(sortAsNumber);
1119
+ versions.edge.sort(sortAsNumber);
1120
+ versions.iosSaf.sort(sortAsNumber);
1121
+ versions.saf.sort(sortAsNumber);
1122
+ versions.opera.sort(sortAsNumber);
1123
+ versions.node.sort(sortAsNumber);
1126
1124
  return versions;
1127
1125
  }
1128
- function _resolveBrowserTarget(versions) {
1126
+ function resolveBrowserTarget(versions) {
1129
1127
  const target = [];
1130
1128
  if (versions.chrome.length) {
1131
1129
  target.push("chrome".concat(versions.chrome[0]));
@@ -1150,7 +1148,7 @@ function _resolveBrowserTarget(versions) {
1150
1148
  }
1151
1149
  return target;
1152
1150
  }
1153
- function _resolveNodeTarget(versions) {
1151
+ function resolveNodeTarget(versions) {
1154
1152
  const target = [];
1155
1153
  if (versions.node.length) {
1156
1154
  target.push("node".concat(versions.node[0]));
@@ -1160,7 +1158,7 @@ function _resolveNodeTarget(versions) {
1160
1158
  }
1161
1159
  return target;
1162
1160
  }
1163
- function _createLogger() {
1161
+ function createLogger() {
1164
1162
  return {
1165
1163
  log: function () {
1166
1164
  console.log(...arguments);
@@ -1191,7 +1189,7 @@ function _createLogger() {
1191
1189
  }
1192
1190
  };
1193
1191
  }
1194
- async function _resolveBuildContext(options) {
1192
+ async function resolveBuildContext(options) {
1195
1193
  var _ref11;
1196
1194
  const {
1197
1195
  config,
@@ -1201,14 +1199,14 @@ async function _resolveBuildContext(options) {
1201
1199
  strict,
1202
1200
  tsconfig: tsconfigPath
1203
1201
  } = options;
1204
- const logger = _createLogger();
1205
- const tsconfig = await _loadTSConfig({
1202
+ const logger = createLogger();
1203
+ const tsconfig = await loadTSConfig({
1206
1204
  cwd,
1207
1205
  tsconfigPath
1208
1206
  });
1209
- const targetVersions = _resolveBrowserslistVersions(pkg.browserslist || _DEFAULTS.browserslist);
1210
- const nodeTarget = _resolveNodeTarget(targetVersions);
1211
- const webTarget = _resolveBrowserTarget(targetVersions);
1207
+ const targetVersions = resolveBrowserslistVersions(pkg.browserslist || DEFAULT_BROWSERSLIST_QUERY);
1208
+ const nodeTarget = resolveNodeTarget(targetVersions);
1209
+ const webTarget = resolveBrowserTarget(targetVersions);
1212
1210
  if (!nodeTarget) {
1213
1211
  throw new Error("no matching `node` target");
1214
1212
  }
@@ -1220,7 +1218,7 @@ async function _resolveBuildContext(options) {
1220
1218
  browser: webTarget,
1221
1219
  node: nodeTarget
1222
1220
  };
1223
- const parsedExports = _parseExports({
1221
+ const parsedExports = parseExports({
1224
1222
  pkg,
1225
1223
  strict
1226
1224
  }).reduce((acc, x) => {
@@ -1232,22 +1230,22 @@ async function _resolveBuildContext(options) {
1232
1230
  [exportPath]: exportEntry
1233
1231
  });
1234
1232
  }, {});
1235
- const exports = _resolveConfigProperty(config == null ? void 0 : config.exports, parsedExports);
1233
+ const exports = resolveConfigProperty(config == null ? void 0 : config.exports, parsedExports);
1236
1234
  const parsedExternal = [...(pkg.dependencies ? Object.keys(pkg.dependencies) : []), ...(pkg.peerDependencies ? Object.keys(pkg.peerDependencies) : [])];
1237
- const external = config && Array.isArray(config.external) ? [...parsedExternal, ...config.external] : _resolveConfigProperty(config == null ? void 0 : config.external, parsedExternal);
1235
+ const external = config && Array.isArray(config.external) ? [...parsedExternal, ...config.external] : resolveConfigProperty(config == null ? void 0 : config.external, parsedExternal);
1238
1236
  const outputPaths = Object.values(exports).flatMap(exportEntry => {
1239
1237
  var _a, _b, _c, _d;
1240
1238
  return [exportEntry.import, exportEntry.require, (_a = exportEntry.browser) == null ? void 0 : _a.import, (_b = exportEntry.browser) == null ? void 0 : _b.require, (_c = exportEntry.node) == null ? void 0 : _c.import, (_d = exportEntry.node) == null ? void 0 : _d.require].filter(Boolean);
1241
1239
  }).map(p => path.resolve(cwd, p));
1242
- const commonDistPath = _findCommonDirPath(outputPaths);
1240
+ const commonDistPath = findCommonDirPath(outputPaths);
1243
1241
  if (commonDistPath === cwd) {
1244
1242
  throw new Error("all output files must share a common parent directory which is not the root package directory");
1245
1243
  }
1246
- if (commonDistPath && !_pathContains(cwd, commonDistPath)) {
1244
+ if (commonDistPath && !pathContains(cwd, commonDistPath)) {
1247
1245
  throw new Error("all output files must be located within the package");
1248
1246
  }
1249
1247
  const configDistPath = (config == null ? void 0 : config.dist) ? path.resolve(cwd, config.dist) : void 0;
1250
- if (configDistPath && commonDistPath && configDistPath !== commonDistPath && !_pathContains(configDistPath, commonDistPath)) {
1248
+ if (configDistPath && commonDistPath && configDistPath !== commonDistPath && !pathContains(configDistPath, commonDistPath)) {
1251
1249
  logger.log("did you mean to configure `dist: './".concat(path.relative(cwd, commonDistPath), "'`?"));
1252
1250
  throw new Error("all output files must be located with the configured `dist` path");
1253
1251
  }
@@ -1275,7 +1273,7 @@ async function _resolveBuildContext(options) {
1275
1273
  };
1276
1274
  return ctx;
1277
1275
  }
1278
- function _spinner(msg) {
1276
+ function createSpinner(msg) {
1279
1277
  const startTime = Date.now();
1280
1278
  console.log("".concat(chalk.yellow("run "), " ").concat(msg));
1281
1279
  return {
@@ -1294,14 +1292,14 @@ async function build(options) {
1294
1292
  strict = false,
1295
1293
  tsconfig: tsconfigOption
1296
1294
  } = options;
1297
- const pkg = await _loadPkgWithReporting({
1295
+ const pkg = await loadPkgWithReporting({
1298
1296
  cwd
1299
1297
  });
1300
- const config = await _loadConfig({
1298
+ const config = await loadConfig({
1301
1299
  cwd
1302
1300
  });
1303
1301
  const tsconfig = tsconfigOption || (config == null ? void 0 : config.tsconfig) || "tsconfig.json";
1304
- const ctx = await _resolveBuildContext({
1302
+ const ctx = await resolveBuildContext({
1305
1303
  config,
1306
1304
  cwd,
1307
1305
  emitDeclarationOnly,
@@ -1309,11 +1307,11 @@ async function build(options) {
1309
1307
  strict,
1310
1308
  tsconfig
1311
1309
  });
1312
- const buildTasks = _resolveBuildTasks(ctx);
1310
+ const buildTasks = resolveBuildTasks(ctx);
1313
1311
  for (const task of buildTasks) {
1314
- const handler = _buildTaskHandlers[task.type];
1312
+ const handler = buildTaskHandlers[task.type];
1315
1313
  const taskName = handler.name(ctx, task);
1316
- const spinner = _spinner(taskName);
1314
+ const spinner = createSpinner(taskName);
1317
1315
  try {
1318
1316
  const result = await handler.exec(ctx, task).toPromise();
1319
1317
  spinner.complete();
@@ -1331,11 +1329,11 @@ async function build(options) {
1331
1329
  }
1332
1330
  }
1333
1331
  }
1334
- function _getFilesize(file) {
1332
+ function getFilesize(file) {
1335
1333
  const stats = statSync(file);
1336
1334
  return prettyBytes(stats.size);
1337
1335
  }
1338
- function _fileExists(file) {
1336
+ function fileExists(file) {
1339
1337
  try {
1340
1338
  fs$1.accessSync(file);
1341
1339
  return true;
@@ -1343,16 +1341,16 @@ function _fileExists(file) {
1343
1341
  return false;
1344
1342
  }
1345
1343
  }
1346
- function _getFileInfo(cwd, filePath) {
1344
+ function getFileInfo(cwd, filePath) {
1347
1345
  const p = path.resolve(cwd, filePath);
1348
- const exists = _fileExists(p);
1349
- const size = exists ? _getFilesize(p) : void 0;
1346
+ const exists = fileExists(p);
1347
+ const size = exists ? getFilesize(p) : void 0;
1350
1348
  return {
1351
1349
  exists,
1352
1350
  size
1353
1351
  };
1354
1352
  }
1355
- function _printPackageTree(ctx) {
1353
+ function printPackageTree(ctx) {
1356
1354
  const {
1357
1355
  cwd,
1358
1356
  exports,
@@ -1365,8 +1363,8 @@ function _printPackageTree(ctx) {
1365
1363
  if (pkg.bin) {
1366
1364
  tree.bin = pkg.bin;
1367
1365
  }
1368
- function _fileInfo(file) {
1369
- const info = _getFileInfo(cwd, file);
1366
+ function fileInfo(file) {
1367
+ const info = getFileInfo(cwd, file);
1370
1368
  if (!info.size) {
1371
1369
  return "".concat(chalk.gray(file), " ").concat(chalk.red("does not exist"));
1372
1370
  }
@@ -1387,7 +1385,7 @@ function _printPackageTree(ctx) {
1387
1385
  default: entry.default
1388
1386
  };
1389
1387
  if (entry.types) {
1390
- exp.types = _fileInfo(entry.types);
1388
+ exp.types = fileInfo(entry.types);
1391
1389
  } else {
1392
1390
  delete exp.types;
1393
1391
  }
@@ -1395,8 +1393,8 @@ function _printPackageTree(ctx) {
1395
1393
  exp.browser = {
1396
1394
  source: entry.browser.source
1397
1395
  };
1398
- if (entry.browser.import) exp.browser.import = _fileInfo(entry.browser.import);
1399
- if (entry.browser.require) exp.browser.require = _fileInfo(entry.browser.require);
1396
+ if (entry.browser.import) exp.browser.import = fileInfo(entry.browser.import);
1397
+ if (entry.browser.require) exp.browser.require = fileInfo(entry.browser.require);
1400
1398
  } else {
1401
1399
  delete exp.browser;
1402
1400
  }
@@ -1404,22 +1402,22 @@ function _printPackageTree(ctx) {
1404
1402
  exp.node = {
1405
1403
  source: entry.node.source
1406
1404
  };
1407
- if (entry.node.import) exp.node.import = _fileInfo(entry.node.import);
1408
- if (entry.node.require) exp.node.require = _fileInfo(entry.node.require);
1405
+ if (entry.node.import) exp.node.import = fileInfo(entry.node.import);
1406
+ if (entry.node.require) exp.node.require = fileInfo(entry.node.require);
1409
1407
  } else {
1410
1408
  delete exp.node;
1411
1409
  }
1412
1410
  if (entry.import) {
1413
- exp.import = _fileInfo(entry.import);
1411
+ exp.import = fileInfo(entry.import);
1414
1412
  } else {
1415
1413
  delete exp.import;
1416
1414
  }
1417
1415
  if (entry.require) {
1418
- exp.require = _fileInfo(entry.require);
1416
+ exp.require = fileInfo(entry.require);
1419
1417
  } else {
1420
1418
  delete exp.require;
1421
1419
  }
1422
- exp.default = _fileInfo(entry.default);
1420
+ exp.default = fileInfo(entry.default);
1423
1421
  return [chalk.green(path.join(pkg.name, exportPath)), exp];
1424
1422
  }));
1425
1423
  logger.log(treeify.asTree(tree, true, true));
@@ -1430,14 +1428,14 @@ async function check(options) {
1430
1428
  strict = false,
1431
1429
  tsconfig: tsconfigOption
1432
1430
  } = options;
1433
- const pkg = await _loadPkgWithReporting({
1431
+ const pkg = await loadPkgWithReporting({
1434
1432
  cwd
1435
1433
  });
1436
- const config = await _loadConfig({
1434
+ const config = await loadConfig({
1437
1435
  cwd
1438
1436
  });
1439
1437
  const tsconfig = tsconfigOption || (config == null ? void 0 : config.tsconfig) || "tsconfig.json";
1440
- const ctx = await _resolveBuildContext({
1438
+ const ctx = await resolveBuildContext({
1441
1439
  config,
1442
1440
  cwd,
1443
1441
  pkg,
@@ -1447,20 +1445,20 @@ async function check(options) {
1447
1445
  const {
1448
1446
  logger
1449
1447
  } = ctx;
1450
- _printPackageTree(ctx);
1448
+ printPackageTree(ctx);
1451
1449
  if (strict) {
1452
1450
  const missingFiles = [];
1453
1451
  for (const [, exp] of Object.entries(ctx.exports || {})) {
1454
- if (exp.source && !_fileExists(path.resolve(cwd, exp.source))) {
1452
+ if (exp.source && !fileExists(path.resolve(cwd, exp.source))) {
1455
1453
  missingFiles.push(exp.source);
1456
1454
  }
1457
- if (exp.require && !_fileExists(path.resolve(cwd, exp.require))) {
1455
+ if (exp.require && !fileExists(path.resolve(cwd, exp.require))) {
1458
1456
  missingFiles.push(exp.require);
1459
1457
  }
1460
- if (exp.import && !_fileExists(path.resolve(cwd, exp.import))) {
1458
+ if (exp.import && !fileExists(path.resolve(cwd, exp.import))) {
1461
1459
  missingFiles.push(exp.import);
1462
1460
  }
1463
- if (exp.types && !_fileExists(path.resolve(cwd, exp.types))) {
1461
+ if (exp.types && !fileExists(path.resolve(cwd, exp.types))) {
1464
1462
  missingFiles.push(exp.types);
1465
1463
  }
1466
1464
  }
@@ -1538,7 +1536,7 @@ async function check(options) {
1538
1536
  }
1539
1537
  }
1540
1538
  }
1541
- function _resolveWatchTasks(ctx) {
1539
+ function resolveWatchTasks(ctx) {
1542
1540
  var _a, _b, _c, _d, _e;
1543
1541
  const {
1544
1542
  config,
@@ -1558,7 +1556,7 @@ function _resolveWatchTasks(ctx) {
1558
1556
  entries: []
1559
1557
  };
1560
1558
  const rollupTasks = {};
1561
- function _addRollupTaskEntry(format, runtime, entry) {
1559
+ function addRollupTaskEntry(format, runtime, entry) {
1562
1560
  const buildId = "".concat(format, ":").concat(runtime);
1563
1561
  if (rollupTasks[buildId]) {
1564
1562
  rollupTasks[buildId].entries.push(entry);
@@ -1587,7 +1585,7 @@ function _resolveWatchTasks(ctx) {
1587
1585
  for (const exp of exports) {
1588
1586
  const output = exp.require;
1589
1587
  if (!output) continue;
1590
- _addRollupTaskEntry("commonjs", ctx.runtime, {
1588
+ addRollupTaskEntry("commonjs", ctx.runtime, {
1591
1589
  path: exp._path,
1592
1590
  source: exp.source,
1593
1591
  output
@@ -1596,7 +1594,7 @@ function _resolveWatchTasks(ctx) {
1596
1594
  for (const exp of exports) {
1597
1595
  const output = (_a = exp.browser) == null ? void 0 : _a.require;
1598
1596
  if (!output) continue;
1599
- _addRollupTaskEntry("commonjs", "browser", {
1597
+ addRollupTaskEntry("commonjs", "browser", {
1600
1598
  path: exp._path,
1601
1599
  source: ((_b = exp.browser) == null ? void 0 : _b.source) || exp.source,
1602
1600
  output
@@ -1605,7 +1603,7 @@ function _resolveWatchTasks(ctx) {
1605
1603
  for (const exp of exports) {
1606
1604
  const output = exp.import;
1607
1605
  if (!output) continue;
1608
- _addRollupTaskEntry("esm", ctx.runtime, {
1606
+ addRollupTaskEntry("esm", ctx.runtime, {
1609
1607
  path: exp._path,
1610
1608
  source: exp.source,
1611
1609
  output
@@ -1614,7 +1612,7 @@ function _resolveWatchTasks(ctx) {
1614
1612
  for (const exp of exports) {
1615
1613
  const output = (_c = exp.browser) == null ? void 0 : _c.import;
1616
1614
  if (!output) continue;
1617
- _addRollupTaskEntry("esm", "browser", {
1615
+ addRollupTaskEntry("esm", "browser", {
1618
1616
  path: exp._path,
1619
1617
  source: ((_d = exp.browser) == null ? void 0 : _d.source) || exp.source,
1620
1618
  output
@@ -1636,33 +1634,33 @@ function _resolveWatchTasks(ctx) {
1636
1634
  }
1637
1635
  return tasks;
1638
1636
  }
1639
- function _globFiles(patterns) {
1637
+ function globFiles(patterns) {
1640
1638
  return globby(patterns);
1641
1639
  }
1642
- function _watchFiles(patterns) {
1640
+ function watchFiles(patterns) {
1643
1641
  return new Observable(observer => {
1644
1642
  const watcher = chokidar.watch(patterns, {
1645
1643
  ignoreInitial: true
1646
1644
  });
1647
- function _handleFileEvent(type, file) {
1645
+ function handleFileEvent(type, file) {
1648
1646
  observer.next({
1649
1647
  type,
1650
1648
  file
1651
1649
  });
1652
1650
  }
1653
- watcher.on("all", _handleFileEvent);
1651
+ watcher.on("all", handleFileEvent);
1654
1652
  return () => {
1655
- watcher.off("all", _handleFileEvent);
1653
+ watcher.off("all", handleFileEvent);
1656
1654
  watcher.close();
1657
1655
  };
1658
1656
  });
1659
1657
  }
1660
- async function _watchConfigFiles(options) {
1658
+ async function watchConfigFiles(options) {
1661
1659
  const {
1662
1660
  cwd
1663
1661
  } = options;
1664
- const initialFiles = await _globFiles([path.resolve(cwd, "package.json"), path.resolve(cwd, "package.config.cjs"), path.resolve(cwd, "package.config.js"), path.resolve(cwd, "package.config.ts")]);
1665
- const fileEvent$ = _watchFiles([path.resolve(cwd, "package.json"), path.resolve(cwd, "package.config.cjs"), path.resolve(cwd, "package.config.js"), path.resolve(cwd, "package.config.ts")]);
1662
+ const initialFiles = await globFiles([path.resolve(cwd, "package.json"), path.resolve(cwd, "package.config.cjs"), path.resolve(cwd, "package.config.js"), path.resolve(cwd, "package.config.ts")]);
1663
+ const fileEvent$ = watchFiles([path.resolve(cwd, "package.json"), path.resolve(cwd, "package.config.cjs"), path.resolve(cwd, "package.config.js"), path.resolve(cwd, "package.config.ts")]);
1666
1664
  return fileEvent$.pipe(scan((files, fileEvent) => {
1667
1665
  if (fileEvent.type === "add") {
1668
1666
  return files.concat(fileEvent.file);
@@ -1685,23 +1683,23 @@ async function watch(options) {
1685
1683
  strict = false,
1686
1684
  tsconfig: tsconfigOption
1687
1685
  } = options;
1688
- const configFiles$ = await _watchConfigFiles({
1686
+ const configFiles$ = await watchConfigFiles({
1689
1687
  cwd
1690
1688
  });
1691
1689
  const ctx$ = configFiles$.pipe(switchMap(async configFiles => {
1692
- const _files = configFiles.map(f => path.relative(cwd, f));
1693
- const packageJsonPath = _files.find(f => f === "package.json");
1690
+ const files = configFiles.map(f => path.relative(cwd, f));
1691
+ const packageJsonPath = files.find(f => f === "package.json");
1694
1692
  if (!packageJsonPath) {
1695
1693
  throw new Error("missing package.json");
1696
1694
  }
1697
- const pkg = await _loadPkgWithReporting({
1695
+ const pkg = await loadPkgWithReporting({
1698
1696
  cwd
1699
1697
  });
1700
- const config = await _loadConfig({
1698
+ const config = await loadConfig({
1701
1699
  cwd
1702
1700
  });
1703
1701
  const tsconfig = tsconfigOption || (config == null ? void 0 : config.tsconfig) || "tsconfig.json";
1704
- return _resolveBuildContext({
1702
+ return resolveBuildContext({
1705
1703
  config,
1706
1704
  cwd,
1707
1705
  pkg,
@@ -1710,9 +1708,9 @@ async function watch(options) {
1710
1708
  });
1711
1709
  }));
1712
1710
  ctx$.subscribe(async ctx => {
1713
- const watchTasks = _resolveWatchTasks(ctx);
1711
+ const watchTasks = resolveWatchTasks(ctx);
1714
1712
  for (const task of watchTasks) {
1715
- const handler = _watchTaskHandlers[task.type];
1713
+ const handler = watchTaskHandlers[task.type];
1716
1714
  const result$ = handler.exec(ctx, task);
1717
1715
  result$.subscribe({
1718
1716
  error: err => {
@@ -1731,5 +1729,5 @@ async function watch(options) {
1731
1729
  }
1732
1730
  });
1733
1731
  }
1734
- export { _DEFAULTS, _MODULE_EXT, _buildTaskHandlers, _dtsTask, _dtsWatchTask, _getExtractMessagesConfig, _isRecord, _loadConfig, _loadPkg, _loadPkgWithReporting, _loadTSConfig, _parseExports, _resolveBuildTasks, _resolveConfigProperty, _rollupTask, _rollupWatchTask, _watchTaskHandlers, build, check, defineConfig, watch };
1732
+ export { DEFAULT_BROWSERSLIST_QUERY, MODULE_EXT, build, buildTaskHandlers, check, defineConfig, dtsTask, dtsWatchTask, getExtractMessagesConfig, isRecord, loadConfig, loadPkg, loadPkgWithReporting, loadTSConfig, parseExports, resolveBuildTasks, resolveConfigProperty, rollupTask, rollupWatchTask, watch, watchTaskHandlers };
1735
1733
  //# sourceMappingURL=index.esm.js.map