@sanity/pkg-utils 1.17.2 → 1.18.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 (30) hide show
  1. package/dist/_chunks/_handleError-869dec25.js +0 -5
  2. package/dist/_chunks/_handleError-869dec25.js.map +1 -1
  3. package/dist/_chunks/_resolveBuildContext-7ca7e64e.js +3 -122
  4. package/dist/_chunks/_resolveBuildContext-7ca7e64e.js.map +1 -1
  5. package/dist/_chunks/{build-072e58ec.js → build-f39a3550.js} +2 -46
  6. package/dist/_chunks/{build-072e58ec.js.map → build-f39a3550.js.map} +1 -1
  7. package/dist/_chunks/{buildAction-35aab706.js → buildAction-8f449d1d.js} +5 -35
  8. package/dist/_chunks/{buildAction-35aab706.js.map → buildAction-8f449d1d.js.map} +1 -1
  9. package/dist/_chunks/check-87cbb6cc.js +0 -55
  10. package/dist/_chunks/check-87cbb6cc.js.map +1 -1
  11. package/dist/_chunks/checkAction-e7e455d4.js +0 -17
  12. package/dist/_chunks/checkAction-e7e455d4.js.map +1 -1
  13. package/dist/_chunks/{index-68bcc7e2.js → index-7a851efa.js} +47 -223
  14. package/dist/_chunks/index-7a851efa.js.map +1 -0
  15. package/dist/_chunks/{watch-e09a4a66.js → watch-f6cf9246.js} +2 -57
  16. package/dist/_chunks/{watch-e09a4a66.js.map → watch-f6cf9246.js.map} +1 -1
  17. package/dist/_chunks/{watchAction-c64a95c7.js → watchAction-4cf253a0.js} +5 -38
  18. package/dist/_chunks/{watchAction-c64a95c7.js.map → watchAction-4cf253a0.js.map} +1 -1
  19. package/dist/cli.js +3 -6
  20. package/dist/cli.js.map +1 -1
  21. package/dist/index.esm.js +56 -396
  22. package/dist/index.esm.js.map +1 -1
  23. package/dist/index.js +5 -43
  24. package/dist/index.js.map +1 -1
  25. package/package.json +3 -1
  26. package/src/node/_tasks/dts/_doExtract.ts +2 -8
  27. package/src/node/_tasks/dts/_extractModuleBlocks.ts +45 -0
  28. package/src/node/_tasks/dts/_extractTypes.ts +11 -1
  29. package/dist/_chunks/index-68bcc7e2.js.map +0 -1
  30. package/src/node/_tasks/dts/_declareModuleFix.ts +0 -98
@@ -1,143 +1,93 @@
1
1
  'use strict';
2
2
 
3
3
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
-
5
4
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
-
7
5
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
8
-
9
6
  var chalk = require('chalk');
10
-
11
7
  var rxjs = require('rxjs');
12
-
13
8
  var path = require('path');
14
-
15
9
  var util = require('util');
16
-
17
10
  var rimrafCallback = require('rimraf');
18
-
19
11
  var ts = require('typescript');
20
-
21
12
  var fs = require('fs/promises');
22
-
23
13
  var apiExtractor = require('@microsoft/api-extractor');
24
-
25
14
  var mkdirp = require('mkdirp');
26
-
27
15
  var prettier = require('prettier');
28
-
29
16
  var tsdocConfig = require('@microsoft/tsdoc-config');
30
-
31
17
  var jsoncParser = require('jsonc-parser');
32
-
18
+ var recast = require('recast');
19
+ var typeScriptParser = require('recast/parsers/typescript');
33
20
  var rollup = require('rollup');
34
-
35
21
  var alias = require('@rollup/plugin-alias');
36
-
37
22
  var pluginBabel = require('@rollup/plugin-babel');
38
-
39
23
  var commonjs = require('@rollup/plugin-commonjs');
40
-
41
24
  var json = require('@rollup/plugin-json');
42
-
43
25
  var pluginNodeResolve = require('@rollup/plugin-node-resolve');
44
-
45
26
  var replace = require('@rollup/plugin-replace');
46
-
47
27
  var esbuild = require('rollup-plugin-esbuild');
48
-
49
28
  var rollupPluginTerser = require('rollup-plugin-terser');
50
-
51
29
  var _resolveBuildContext = require('./_resolveBuildContext-7ca7e64e.js');
52
-
53
30
  require('esbuild-register/dist/node');
54
-
55
31
  require('pkg-up');
56
-
57
32
  require('find-config');
58
-
59
33
  require('zod');
60
-
61
34
  function _interopDefaultLegacy(e) {
62
35
  return e && typeof e === 'object' && 'default' in e ? e : {
63
36
  'default': e
64
37
  };
65
38
  }
66
-
67
39
  var chalk__default = /*#__PURE__*/_interopDefaultLegacy(chalk);
68
-
69
40
  var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
70
-
71
41
  var rimrafCallback__default = /*#__PURE__*/_interopDefaultLegacy(rimrafCallback);
72
-
73
42
  var ts__default = /*#__PURE__*/_interopDefaultLegacy(ts);
74
-
75
43
  var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
76
-
77
44
  var mkdirp__default = /*#__PURE__*/_interopDefaultLegacy(mkdirp);
78
-
79
45
  var prettier__default = /*#__PURE__*/_interopDefaultLegacy(prettier);
80
-
46
+ var typeScriptParser__default = /*#__PURE__*/_interopDefaultLegacy(typeScriptParser);
81
47
  var alias__default = /*#__PURE__*/_interopDefaultLegacy(alias);
82
-
83
48
  var commonjs__default = /*#__PURE__*/_interopDefaultLegacy(commonjs);
84
-
85
49
  var json__default = /*#__PURE__*/_interopDefaultLegacy(json);
86
-
87
50
  var replace__default = /*#__PURE__*/_interopDefaultLegacy(replace);
88
-
89
51
  var esbuild__default = /*#__PURE__*/_interopDefaultLegacy(esbuild);
90
-
91
52
  function _printExtractMessages(ctx, messages) {
92
53
  const {
93
54
  cwd,
94
55
  logger
95
56
  } = ctx;
96
57
  const warnings = messages.filter(msg => msg.logLevel === "warning");
97
-
98
58
  if (warnings.length) {
99
59
  logger.log();
100
60
  }
101
-
102
61
  for (const msg of warnings) {
103
62
  const sourceFilePath = msg.sourceFilePath && path__default["default"].relative(cwd, msg.sourceFilePath);
104
-
105
63
  if (msg.messageId === "TS6307") {
106
64
  continue;
107
65
  }
108
-
109
66
  logger.log(["".concat(chalk__default["default"].cyan(sourceFilePath || "?")), ":".concat(chalk__default["default"].yellow(msg.sourceFileLine), ":").concat(chalk__default["default"].yellow(msg.sourceFileColumn)), " - ".concat(chalk__default["default"].yellow("warning"), " ").concat(chalk__default["default"].gray(msg.messageId), "\n"), msg.text, "\n"].join(""));
110
67
  }
111
-
112
68
  const errors = messages.filter(msg => msg.logLevel === "error");
113
-
114
69
  if (!warnings.length && errors.length) {
115
70
  logger.log("");
116
71
  }
117
-
118
72
  for (const msg of errors) {
119
73
  const sourceFilePath = msg.sourceFilePath && path__default["default"].relative(cwd, msg.sourceFilePath);
120
74
  logger.log(["".concat(chalk__default["default"].cyan(sourceFilePath || "?")), ":".concat(chalk__default["default"].yellow(msg.sourceFileLine), ":").concat(chalk__default["default"].yellow(msg.sourceFileColumn)), " - ".concat(chalk__default["default"].red("error"), " ").concat(chalk__default["default"].gray(msg.messageId), "\n"), msg.text, "\n"].join(""));
121
75
  }
122
-
123
76
  if (errors.length) {
124
77
  process.exit(1);
125
78
  }
126
79
  }
127
-
128
80
  const formatHost = {
129
81
  getCurrentDirectory: () => ts__default["default"].sys.getCurrentDirectory(),
130
82
  getNewLine: () => ts__default["default"].sys.newLine,
131
83
  getCanonicalFileName: ts__default["default"].sys.useCaseSensitiveFileNames ? f => f : f => f.toLowerCase()
132
84
  };
133
-
134
85
  async function _buildTypes(options) {
135
86
  const {
136
87
  outDir,
137
88
  tsconfig,
138
89
  strict = false
139
90
  } = options;
140
-
141
91
  const compilerOptions = _objectSpread(_objectSpread({}, tsconfig.options), {}, {
142
92
  declaration: true,
143
93
  declarationDir: outDir,
@@ -145,7 +95,6 @@ async function _buildTypes(options) {
145
95
  noEmit: false,
146
96
  outDir
147
97
  });
148
-
149
98
  const program = ts__default["default"].createProgram(tsconfig.fileNames, compilerOptions);
150
99
  const emitResult = program.emit();
151
100
  const allDiagnostics = ts__default["default"].getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
@@ -161,108 +110,22 @@ async function _buildTypes(options) {
161
110
  console.log(ts__default["default"].flattenDiagnosticMessageText(diagnostic.messageText, "\n"));
162
111
  }
163
112
  });
164
-
165
113
  if (emitResult.emitSkipped) {
166
114
  const errors = allDiagnostics.filter(diag => diag.category === ts__default["default"].DiagnosticCategory.Error);
167
-
168
115
  if (errors.length) {
169
116
  console.error(ts__default["default"].formatDiagnostics(errors, formatHost));
170
-
171
117
  if (strict) {
172
118
  throw new Error("failed to compile TypeScript definitions");
173
119
  }
174
120
  }
175
121
  }
176
122
  }
177
-
178
- async function _appendModuleBlocks(_ref) {
179
- let {
180
- tsOutDir,
181
- extractResult,
182
- extractTypesOutFile
183
- } = _ref;
184
- const moduleBlocks = await _extractModuleBlocksFromTypes({
185
- tsOutDir,
186
- extractResult
187
- });
188
-
189
- if (moduleBlocks.length) {
190
- await fs__default["default"].appendFile(extractTypesOutFile, "\n" + moduleBlocks.join("\n\n"));
191
- }
192
- }
193
-
194
- async function _extractModuleBlocksFromTypes(_ref2) {
195
- let {
196
- tsOutDir,
197
- extractResult
198
- } = _ref2;
199
- const moduleBlocks = [];
200
- const program = extractResult.compilerState.program;
201
- const allProgramFiles = [...program.getSourceFiles()];
202
- const sourceFiles = allProgramFiles.filter(sourceFile => sourceFile.fileName.includes(tsOutDir));
203
-
204
- for (const sourceFile of sourceFiles) {
205
- if (sourceFile.text.includes("declare module")) {
206
- moduleBlocks.push(..._extractModuleBlocks(sourceFile.text));
207
- }
208
- }
209
-
210
- return moduleBlocks;
211
- }
212
-
213
- function _extractModuleBlocks(fileContent) {
214
- var _a;
215
-
216
- const moduleBlocks = [];
217
- let moduleIndentLevel = 0;
218
- let insideComment = false;
219
- let moduleLines = [];
220
- const lines = fileContent.split("\n");
221
-
222
- for (const line of lines) {
223
- if (insideComment && line.includes("*/")) {
224
- insideComment = false;
225
- } else if (!insideComment && line.includes("/*") && line.includes("*/")) {
226
- continue;
227
- } else if (!insideComment && line.includes("/*")) {
228
- insideComment = true;
229
- }
230
-
231
- if (insideComment) {
232
- continue;
233
- }
234
-
235
- if (!moduleLines.length) {
236
- const isModuleDeclaration = (_a = line.match(/^\s*declare module.+$/)) == null ? void 0 : _a.length;
237
- const moduleIndex = line.indexOf("declare module");
238
- const isModuleStart = isModuleDeclaration && moduleIndex > -1;
239
-
240
- if (isModuleStart) {
241
- moduleIndentLevel = moduleIndex;
242
- moduleLines = [line];
243
- }
244
- } else {
245
- moduleLines.push(line);
246
- const blockEndIndex = line.indexOf("}");
247
-
248
- if (blockEndIndex === moduleIndentLevel) {
249
- moduleBlocks.push(moduleLines.map(l => l.substring(moduleIndentLevel, l.length)).join("\n"));
250
- moduleLines = [];
251
- }
252
- }
253
- }
254
-
255
- return moduleBlocks;
256
- }
257
-
258
123
  class _DtsError extends Error {
259
124
  constructor(message, messages) {
260
125
  super(message);
261
126
  this.messages = messages;
262
127
  }
263
-
264
128
  }
265
-
266
129
  function _createApiExtractorConfig(options) {
267
130
  const {
268
131
  distPath,
@@ -297,16 +160,13 @@ function _createApiExtractorConfig(options) {
297
160
  projectFolder
298
161
  };
299
162
  }
300
-
301
163
  async function _createTSDocConfig(opts) {
302
164
  const {
303
165
  customTags
304
166
  } = opts;
305
-
306
167
  if (customTags.length === 0) {
307
168
  return void 0;
308
169
  }
309
-
310
170
  const tsDocBaseBuf = await fs.readFile(require.resolve("@microsoft/api-extractor/extends/tsdoc-base.json"));
311
171
  const tsDocBaseConfig = jsoncParser.parse(tsDocBaseBuf.toString());
312
172
  const tagDefinitions = (tsDocBaseConfig.tagDefinitions || []).concat(customTags.map(t => ({
@@ -314,37 +174,52 @@ async function _createTSDocConfig(opts) {
314
174
  syntaxKind: t.syntaxKind,
315
175
  allowMultiple: t.allowMultiple
316
176
  })));
317
-
318
177
  const supportForTags = _objectSpread({}, tsDocBaseConfig.supportForTags);
319
-
320
178
  for (const customTag of customTags) {
321
179
  supportForTags["@".concat(customTag.name)] = true;
322
180
  }
323
-
324
181
  return tsdocConfig.TSDocConfigFile.loadFromObject(_objectSpread(_objectSpread({}, tsDocBaseConfig), {}, {
325
182
  noStandardTags: false,
326
183
  tagDefinitions,
327
184
  supportForTags
328
185
  }));
329
186
  }
330
-
187
+ async function _extractModuleBlocksFromTypes(_ref) {
188
+ let {
189
+ tsOutDir,
190
+ extractResult
191
+ } = _ref;
192
+ const program = extractResult.compilerState.program;
193
+ const moduleBlocks = [];
194
+ const allProgramFiles = [...program.getSourceFiles()];
195
+ const sourceFiles = allProgramFiles.filter(sourceFile => sourceFile.fileName.includes(tsOutDir));
196
+ for (const sourceFile of sourceFiles) {
197
+ if (sourceFile.text.includes("declare module")) {
198
+ moduleBlocks.push(..._extractModuleBlocks(sourceFile.text));
199
+ }
200
+ }
201
+ return moduleBlocks;
202
+ }
203
+ function _extractModuleBlocks(fileContent) {
204
+ const ast = recast.parse(fileContent, {
205
+ parser: typeScriptParser__default["default"]
206
+ });
207
+ return ast.program.body.filter(node => node.type === "TSModuleDeclaration").map(node => recast.print(node).code);
208
+ }
331
209
  const _LOG_LEVELS = {
332
210
  error: "error",
333
211
  info: "info",
334
212
  off: "none",
335
213
  warn: "warning"
336
214
  };
337
-
338
215
  function _getExtractMessagesConfig(options) {
339
216
  const {
340
217
  rules
341
218
  } = options;
342
-
343
219
  function _ruleToLogLevel(key, defaultLevel) {
344
220
  const r = rules == null ? void 0 : rules[key];
345
221
  return r ? _LOG_LEVELS[r] : defaultLevel || "warning";
346
222
  }
347
-
348
223
  return {
349
224
  compilerMessageReporting: {
350
225
  default: {
@@ -397,7 +272,6 @@ function _getExtractMessagesConfig(options) {
397
272
  }
398
273
  };
399
274
  }
400
-
401
275
  async function _extractTypes(options) {
402
276
  const {
403
277
  customTags,
@@ -408,6 +282,7 @@ async function _extractTypes(options) {
408
282
  projectPath,
409
283
  rules,
410
284
  sourceTypesPath,
285
+ tmpPath,
411
286
  tsconfigPath
412
287
  } = options;
413
288
  const tsdocConfigFile = await _createTSDocConfig({
@@ -433,18 +308,21 @@ async function _extractTypes(options) {
433
308
  const extractorResult = apiExtractor.Extractor.invoke(extractorConfig, {
434
309
  localBuild: true,
435
310
  showVerboseMessages: true,
436
-
437
311
  messageCallback(message) {
438
312
  messages.push(message);
439
313
  message.handled = true;
440
314
  }
441
-
442
315
  });
443
316
  const typesPath = path__default["default"].resolve(distPath, filePath);
444
317
  const typesBuf = await fs__default["default"].readFile(typesPath);
445
318
  const prettierConfig = await prettier__default["default"].resolveConfig(typesPath);
446
319
  await mkdirp__default["default"](path__default["default"].dirname(typesPath));
447
- await fs__default["default"].writeFile(typesPath, prettier__default["default"].format(typesBuf.toString(), _objectSpread(_objectSpread({}, prettierConfig), {}, {
320
+ const moduleBlocks = await _extractModuleBlocksFromTypes({
321
+ extractResult: extractorResult,
322
+ tsOutDir: tmpPath
323
+ });
324
+ const code = [typesBuf.toString(), ...moduleBlocks].join("\n\n");
325
+ await fs__default["default"].writeFile(typesPath, prettier__default["default"].format(code, _objectSpread(_objectSpread({}, prettierConfig), {}, {
448
326
  filepath: typesPath
449
327
  })));
450
328
  files.push({
@@ -456,12 +334,9 @@ async function _extractTypes(options) {
456
334
  messages
457
335
  };
458
336
  }
459
-
460
337
  const rimraf = util.promisify(rimrafCallback__default["default"]);
461
-
462
338
  async function _doExtract(ctx, task) {
463
339
  var _a, _b;
464
-
465
340
  const {
466
341
  config,
467
342
  cwd,
@@ -469,7 +344,6 @@ async function _doExtract(ctx, task) {
469
344
  strict,
470
345
  ts
471
346
  } = ctx;
472
-
473
347
  if (!ts.config || !ts.configPath) {
474
348
  return {
475
349
  type: "dts",
@@ -477,16 +351,13 @@ async function _doExtract(ctx, task) {
477
351
  results: []
478
352
  };
479
353
  }
480
-
481
354
  const {
482
355
  outDir,
483
356
  rootDir = cwd
484
357
  } = ts.config.options;
485
-
486
358
  if (!outDir) {
487
359
  throw new Error("tsconfig.json is missing `compilerOptions.outDir`");
488
360
  }
489
-
490
361
  const tmpPath = path__default["default"].resolve(outDir, "__tmp__");
491
362
  await _buildTypes({
492
363
  cwd,
@@ -496,7 +367,6 @@ async function _doExtract(ctx, task) {
496
367
  });
497
368
  const messages = [];
498
369
  const results = [];
499
-
500
370
  for (const entry of task.entries) {
501
371
  const exportPath = entry.exportPath === "." ? "./index" : entry.exportPath;
502
372
  const sourceTypesPath = path__default["default"].resolve(tmpPath, path__default["default"].relative(rootDir, path__default["default"].resolve(cwd, entry.sourcePath)).replace(/\.ts$/, ".d.ts"));
@@ -505,33 +375,26 @@ async function _doExtract(ctx, task) {
505
375
  const result = await _extractTypes({
506
376
  customTags: (_a = config == null ? void 0 : config.extract) == null ? void 0 : _a.customTags,
507
377
  cwd,
378
+ distPath: outDir,
508
379
  exportPath,
509
380
  files,
510
381
  filePath,
511
382
  projectPath: cwd,
512
383
  rules: (_b = config == null ? void 0 : config.extract) == null ? void 0 : _b.rules,
513
384
  sourceTypesPath,
514
- tsconfigPath: path__default["default"].resolve(cwd, ts.configPath || "tsconfig.json"),
515
- distPath: outDir
516
- });
517
- await _appendModuleBlocks({
518
- tsOutDir: tmpPath,
519
- extractResult: result.extractorResult,
520
- extractTypesOutFile: path__default["default"].resolve(outDir, targetPath)
385
+ tmpPath,
386
+ tsconfigPath: path__default["default"].resolve(cwd, ts.configPath || "tsconfig.json")
521
387
  });
522
388
  messages.push(...result.messages);
523
-
524
389
  if (result.messages.some(msg => msg.logLevel === "error")) {
525
390
  await rimraf(tmpPath);
526
391
  throw new _DtsError("encountered errors when extracting types", result.messages);
527
392
  }
528
-
529
393
  results.push({
530
394
  sourcePath: path__default["default"].resolve(cwd, entry.sourcePath),
531
395
  filePath: targetPath
532
396
  });
533
397
  }
534
-
535
398
  await rimraf(tmpPath);
536
399
  return {
537
400
  type: "dts",
@@ -539,7 +402,6 @@ async function _doExtract(ctx, task) {
539
402
  results
540
403
  };
541
404
  }
542
-
543
405
  const _dtsTask = {
544
406
  name: (_ctx, task) => ["build type definitions", ...task.entries.map(entry => " ".concat(chalk__default["default"].blue(entry.importId), ": ").concat(entry.sourcePath, " -> ").concat(entry.targetPath))].join("\n"),
545
407
  exec: (ctx, task) => {
@@ -559,7 +421,6 @@ const _dtsTask = {
559
421
  const {
560
422
  logger
561
423
  } = ctx;
562
-
563
424
  if (err instanceof _DtsError) {
564
425
  _printExtractMessages(ctx, err.messages);
565
426
  } else if (err instanceof Error) {
@@ -581,9 +442,7 @@ const _dtsWatchTask = {
581
442
  const {
582
443
  logger
583
444
  } = ctx;
584
-
585
445
  _printExtractMessages(ctx, result.messages);
586
-
587
446
  logger.warn("watching typescript definitions is currently not supported");
588
447
  logger.log();
589
448
  },
@@ -591,7 +450,6 @@ const _dtsWatchTask = {
591
450
  const {
592
451
  logger
593
452
  } = ctx;
594
-
595
453
  if (err instanceof _DtsError) {
596
454
  _printExtractMessages(ctx, err.messages);
597
455
  } else if (err instanceof Error) {
@@ -599,12 +457,9 @@ const _dtsWatchTask = {
599
457
  }
600
458
  }
601
459
  };
602
-
603
460
  function _resolveRollupConfig(ctx, buildTask) {
604
- var _ref3, _ref6, _ref7, _ref8, _ref9, _ref10;
605
-
461
+ var _ref2, _ref5, _ref6, _ref7, _ref8, _ref9;
606
462
  var _a, _b, _c;
607
-
608
463
  const {
609
464
  format,
610
465
  runtime,
@@ -621,13 +476,11 @@ function _resolveRollupConfig(ctx, buildTask) {
621
476
  ts
622
477
  } = ctx;
623
478
  const outputExt = _resolveBuildContext._MODULE_EXT[pkg.type][format];
624
- const minify = (_ref3 = config == null ? void 0 : config.minify) !== null && _ref3 !== void 0 ? _ref3 : true;
479
+ const minify = (_ref2 = config == null ? void 0 : config.minify) !== null && _ref2 !== void 0 ? _ref2 : true;
625
480
  const outDir = path__default["default"].relative(cwd, distPath);
626
- const pathAliases = Object.fromEntries(Object.entries(((_a = ts.config) == null ? void 0 : _a.options.paths) || {}).map(_ref4 => {
627
- let [key, val] = _ref4;
628
-
481
+ const pathAliases = Object.fromEntries(Object.entries(((_a = ts.config) == null ? void 0 : _a.options.paths) || {}).map(_ref3 => {
482
+ let [key, val] = _ref3;
629
483
  var _a2;
630
-
631
484
  return [key, path__default["default"].resolve(cwd, ((_a2 = ts.config) == null ? void 0 : _a2.options.baseUrl) || ".", val[0])];
632
485
  }));
633
486
  const entries = buildTask.entries.map(entry => {
@@ -635,13 +488,10 @@ function _resolveRollupConfig(ctx, buildTask) {
635
488
  name: path__default["default"].relative(outDir, entry.output).replace(/\.[^/.]+$/, "")
636
489
  });
637
490
  }, {});
638
-
639
491
  const exportIds = _exports && Object.keys(_exports).map(exportPath => path__default["default"].join(pkg.name, exportPath));
640
-
641
492
  const sourcePaths = _exports && Object.values(_exports).map(e => path__default["default"].resolve(cwd, e.source));
642
-
643
- const replacements = Object.fromEntries(Object.entries((config == null ? void 0 : config.define) || {}).map(_ref5 => {
644
- let [key, val] = _ref5;
493
+ const replacements = Object.fromEntries(Object.entries((config == null ? void 0 : config.define) || {}).map(_ref4 => {
494
+ let [key, val] = _ref4;
645
495
  return [key, JSON.stringify(val)];
646
496
  }));
647
497
  const defaultPlugins = [replace__default["default"]({
@@ -650,12 +500,10 @@ function _resolveRollupConfig(ctx, buildTask) {
650
500
  "process.env.PKG_FILE_PATH": arg => {
651
501
  const sourcePath = "./" + path__default["default"].relative(cwd, arg);
652
502
  const entry = entries.find(e => e.source === sourcePath);
653
-
654
503
  if (!entry) {
655
504
  console.error("could not find source entry: ".concat(sourcePath));
656
505
  return "null";
657
506
  }
658
-
659
507
  return JSON.stringify(path__default["default"].relative(cwd, path__default["default"].resolve(outDir, entry.name + outputExt)));
660
508
  },
661
509
  "process.env.PKG_FORMAT": JSON.stringify(format),
@@ -672,10 +520,10 @@ function _resolveRollupConfig(ctx, buildTask) {
672
520
  esmExternals: false,
673
521
  extensions: [".js"]
674
522
  }), json__default["default"](), esbuild__default["default"]({
675
- jsx: (_ref6 = config == null ? void 0 : config.jsx) !== null && _ref6 !== void 0 ? _ref6 : "automatic",
676
- jsxFactory: (_ref7 = config == null ? void 0 : config.jsxFactory) !== null && _ref7 !== void 0 ? _ref7 : "createElement",
677
- jsxFragment: (_ref8 = config == null ? void 0 : config.jsxFragment) !== null && _ref8 !== void 0 ? _ref8 : "Fragment",
678
- jsxImportSource: (_ref9 = config == null ? void 0 : config.jsxImportSource) !== null && _ref9 !== void 0 ? _ref9 : "react",
523
+ jsx: (_ref5 = config == null ? void 0 : config.jsx) !== null && _ref5 !== void 0 ? _ref5 : "automatic",
524
+ jsxFactory: (_ref6 = config == null ? void 0 : config.jsxFactory) !== null && _ref6 !== void 0 ? _ref6 : "createElement",
525
+ jsxFragment: (_ref7 = config == null ? void 0 : config.jsxFragment) !== null && _ref7 !== void 0 ? _ref7 : "Fragment",
526
+ jsxImportSource: (_ref8 = config == null ? void 0 : config.jsxImportSource) !== null && _ref8 !== void 0 ? _ref8 : "react",
679
527
  target,
680
528
  tsconfig: ctx.ts.configPath || "tsconfig.json"
681
529
  }), pluginBabel.getBabelOutputPlugin({
@@ -689,11 +537,9 @@ function _resolveRollupConfig(ctx, buildTask) {
689
537
  comments: (_node, comment) => {
690
538
  const text = comment.value;
691
539
  const type = comment.type;
692
-
693
540
  if (type == "comment2") {
694
541
  return /@preserve|@license|@cc_on/i.test(text);
695
542
  }
696
-
697
543
  return false;
698
544
  }
699
545
  }
@@ -707,23 +553,18 @@ function _resolveRollupConfig(ctx, buildTask) {
707
553
  if (exportIds == null ? void 0 : exportIds.includes(id)) {
708
554
  return true;
709
555
  }
710
-
711
556
  if (importer && (id.startsWith(".") || id.startsWith("/"))) {
712
557
  const idPath = path__default["default"].resolve(path__default["default"].dirname(importer), id);
713
-
714
558
  if (sourcePaths == null ? void 0 : sourcePaths.includes(idPath)) {
715
559
  logger.warn("detected self-referencing import \u2013 treating as external: ".concat(path__default["default"].relative(cwd, idPath)));
716
560
  return true;
717
561
  }
718
562
  }
719
-
720
563
  const idParts = id.split("/");
721
564
  const name = idParts[0].startsWith("@") ? "".concat(idParts[0], "/").concat(idParts[1]) : idParts[0];
722
-
723
565
  if (name && external.includes(name)) {
724
566
  return true;
725
567
  }
726
-
727
568
  return false;
728
569
  },
729
570
  input: entries.reduce((acc, entry) => {
@@ -731,13 +572,11 @@ function _resolveRollupConfig(ctx, buildTask) {
731
572
  [entry.name]: entry.source
732
573
  });
733
574
  }, {}),
734
-
735
575
  onwarn(warning, rollupWarn) {
736
576
  if (!warning.code || !["CIRCULAR_DEPENDENCY"].includes(warning.code)) {
737
577
  rollupWarn(warning);
738
578
  }
739
579
  },
740
-
741
580
  plugins,
742
581
  treeshake: {
743
582
  propertyReadSideEffects: false
@@ -749,11 +588,10 @@ function _resolveRollupConfig(ctx, buildTask) {
749
588
  entryFileNames: () => outputExt === ".esm.js" ? "[name].js" : "[name]".concat(outputExt),
750
589
  format,
751
590
  exports: "auto",
752
- sourcemap: (_ref10 = config == null ? void 0 : config.sourcemap) !== null && _ref10 !== void 0 ? _ref10 : true
591
+ sourcemap: (_ref9 = config == null ? void 0 : config.sourcemap) !== null && _ref9 !== void 0 ? _ref9 : true
753
592
  }
754
593
  };
755
594
  }
756
-
757
595
  const _rollupTask = {
758
596
  name: (ctx, task) => "build javascript files (target ".concat(task.target.join(" + "), ", format ").concat(task.format, ")\n ").concat(task.entries.map(e => "".concat(chalk__default["default"].blue(path__default["default"].join(ctx.pkg.name, e.path)), ": ").concat(e.source, " -> ").concat(e.output)).join("\n ")),
759
597
  exec: (ctx, task) => {
@@ -771,24 +609,20 @@ const _rollupTask = {
771
609
  }
772
610
  }
773
611
  };
774
-
775
612
  async function _execPromise(ctx, task) {
776
613
  const {
777
614
  files,
778
615
  distPath
779
616
  } = ctx;
780
617
  const outDir = path__default["default"].relative(ctx.cwd, distPath);
781
-
782
618
  const {
783
619
  inputOptions,
784
620
  outputOptions
785
621
  } = _resolveRollupConfig(ctx, task);
786
-
787
622
  const bundle = await rollup.rollup(inputOptions);
788
623
  const {
789
624
  output
790
625
  } = await bundle.generate(outputOptions);
791
-
792
626
  for (const chunkOrAsset of output) {
793
627
  if (chunkOrAsset.type === "asset") {
794
628
  files.push({
@@ -802,11 +636,9 @@ async function _execPromise(ctx, task) {
802
636
  });
803
637
  }
804
638
  }
805
-
806
639
  await bundle.write(outputOptions);
807
640
  await bundle.close();
808
641
  }
809
-
810
642
  const _rollupWatchTask = {
811
643
  name: (ctx, task) => "build javascript files (target ".concat(task.target.join(" + "), ", format ").concat(task.format, ")\n ").concat(task.entries.map(e => "".concat(chalk__default["default"].blue(path__default["default"].join(ctx.pkg.name, e.path)), ": ").concat(e.source, " -> ").concat(e.output)).join("\n ")),
812
644
  exec: (ctx, task) => {
@@ -814,12 +646,10 @@ const _rollupWatchTask = {
814
646
  inputOptions,
815
647
  outputOptions
816
648
  } = _resolveRollupConfig(ctx, task);
817
-
818
649
  return new rxjs.Observable(observer => {
819
650
  const watchOptions = _objectSpread(_objectSpread({}, inputOptions), {}, {
820
651
  output: outputOptions
821
652
  });
822
-
823
653
  const watcher = rollup.watch(watchOptions);
824
654
  watcher.on("event", event => {
825
655
  observer.next(event);
@@ -833,26 +663,21 @@ const _rollupWatchTask = {
833
663
  const {
834
664
  logger
835
665
  } = ctx;
836
-
837
666
  if (event.code === "BUNDLE_END") {
838
667
  logger.success("build javascript files (target ".concat(task.target.join(" + "), ", format ").concat(task.format, ")\n ").concat(task.entries.map(e => "".concat(chalk__default["default"].blue(path__default["default"].join(ctx.pkg.name, e.path)), ": ").concat(e.source, " -> ").concat(e.output)).join("\n ")));
839
668
  logger.log("");
840
669
  return;
841
670
  }
842
-
843
671
  if (event.code === "BUNDLE_START") {
844
672
  return;
845
673
  }
846
-
847
674
  if (event.code === "END") {
848
675
  return;
849
676
  }
850
-
851
677
  if (event.code === "ERROR") {
852
678
  logger.error(event.code, event);
853
679
  return;
854
680
  }
855
-
856
681
  if (event.code === "START") {
857
682
  return;
858
683
  }
@@ -861,7 +686,6 @@ const _rollupWatchTask = {
861
686
  const {
862
687
  logger
863
688
  } = ctx;
864
-
865
689
  if (err instanceof Error) {
866
690
  logger.log(err);
867
691
  }
@@ -882,4 +706,4 @@ exports._getExtractMessagesConfig = _getExtractMessagesConfig;
882
706
  exports._rollupTask = _rollupTask;
883
707
  exports._rollupWatchTask = _rollupWatchTask;
884
708
  exports._watchTaskHandlers = _watchTaskHandlers;
885
- //# sourceMappingURL=index-68bcc7e2.js.map
709
+ //# sourceMappingURL=index-7a851efa.js.map