@sanity/pkg-utils 4.4.1 → 5.0.1

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.
@@ -45,12 +45,10 @@ const pkgSchema = zod.z.object({
45
45
  node: zod.z.optional(
46
46
  zod.z.object({
47
47
  source: zod.z.optional(zod.z.string()),
48
- module: zod.z.optional(zod.z.string()),
49
48
  import: zod.z.optional(zod.z.string()),
50
49
  require: zod.z.optional(zod.z.string())
51
50
  })
52
51
  ),
53
- module: zod.z.optional(zod.z.string()),
54
52
  import: zod.z.optional(zod.z.string()),
55
53
  require: zod.z.optional(zod.z.string()),
56
54
  default: zod.z.string()
@@ -1 +1 @@
1
- {"version":3,"file":"logger.cjs","sources":["../../src/node/fileExists.ts","../../src/node/core/isRecord.ts","../../src/node/core/pkg/validatePkg.ts","../../src/node/logger.ts"],"sourcesContent":["import {statSync} from 'fs'\n\n/** @internal */\nexport function fileExists(filePath: string): boolean {\n try {\n statSync(filePath)\n\n return true\n } catch (_) {\n return false\n }\n}\n","/** @internal */\nexport function isRecord(value: unknown): value is Record<string, unknown> {\n return Boolean(value) && !Array.isArray(value) && typeof value === 'object'\n}\n","import {z} from 'zod'\n\nimport {PackageJSON} from './types'\n\nconst pkgSchema = z.object({\n type: z.optional(z.enum(['commonjs', 'module'])),\n name: z.string(),\n version: z.string(),\n license: z.string(),\n bin: z.optional(z.record(z.string())),\n dependencies: z.optional(z.record(z.string())),\n devDependencies: z.optional(z.record(z.string())),\n peerDependencies: z.optional(z.record(z.string())),\n source: z.optional(z.string()),\n main: z.optional(z.string()),\n browser: z.optional(z.record(z.string())),\n module: z.optional(z.string()),\n types: z.optional(z.string()),\n exports: z.optional(\n z.record(\n z.union([\n z.custom<`./${string}.json`>((val) => /^\\.\\/.*\\.json$/.test(val as string)),\n z.object({\n types: z.optional(z.string()),\n source: z.string(),\n browser: z.optional(\n z.object({\n source: z.string(),\n import: z.optional(z.string()),\n require: z.optional(z.string()),\n }),\n ),\n node: z.optional(\n z.object({\n source: z.optional(z.string()),\n module: z.optional(z.string()),\n import: z.optional(z.string()),\n require: z.optional(z.string()),\n }),\n ),\n module: z.optional(z.string()),\n import: z.optional(z.string()),\n require: z.optional(z.string()),\n default: z.string(),\n }),\n z.object({\n types: z.optional(z.string()),\n svelte: z.string(),\n default: z.optional(z.string()),\n }),\n ]),\n ),\n ),\n browserslist: z.optional(z.union([z.string(), z.array(z.string())])),\n sideEffects: z.optional(z.union([z.boolean(), z.array(z.string())])),\n})\n\nexport function validatePkg(input: unknown): PackageJSON {\n return pkgSchema.parse(input)\n}\n","import chalk from 'chalk'\n\n/** @internal */\nexport interface Logger {\n log: (...args: unknown[]) => void\n info: (...args: unknown[]) => void\n warn: (...args: unknown[]) => void\n error: (...args: unknown[]) => void\n success: (...args: unknown[]) => void\n}\n\n/** @internal */\nexport function createLogger(): Logger {\n return {\n /* eslint-disable no-console */\n log: (...args) => {\n console.log(...args)\n },\n info: (...args) => {\n console.log(chalk.blue('[info]'), ...args)\n },\n warn: (...args) => {\n console.log(chalk.yellow('[warning]'), ...args)\n },\n error: (...args) => {\n console.log(chalk.red('[error]'), ...args)\n },\n success: (...args) => {\n console.log(chalk.green('[success]'), ...args)\n },\n /* eslint-enable no-console */\n }\n}\n"],"names":["statSync","z","chalk"],"mappings":";;;;;;AAGO,SAAS,WAAW,UAA2B;AAChD,MAAA;AACF,WAAAA,YAAS,QAAQ,GAEV;AAAA,EAAA,QACG;AACH,WAAA;AAAA,EACT;AACF;ACVO,SAAS,SAAS,OAAkD;AAClE,SAAA,CAAA,CAAQ,SAAU,CAAC,MAAM,QAAQ,KAAK,KAAK,OAAO,SAAU;AACrE;ACCA,MAAM,YAAYC,MAAE,OAAO;AAAA,EACzB,MAAMA,IAAAA,EAAE,SAASA,IAAA,EAAE,KAAK,CAAC,YAAY,QAAQ,CAAC,CAAC;AAAA,EAC/C,MAAMA,MAAE,OAAO;AAAA,EACf,SAASA,MAAE,OAAO;AAAA,EACl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A,IACA,MAAM,IAAI,SAAS;AACjB,cAAQ,IAAIC,uBAAM,KAAK,QAAQ,GAAG,GAAG,IAAI;AAAA,IAC3C;AAAA,IACA,MAAM,IAAI,SAAS;AACjB,cAAQ,IAAIA,uBAAM,OAAO,WAAW,GAAG,GAAG,IAAI;AAAA,IAChD;AAAA,IACA,OAAO,IAAI,SAAS;AAClB,cAAQ,IAAIA,uBAAM,IAAI,SAAS,GAAG,GAAG,IAAI;AAAA,IAC3C;AAAA,IACA,SAAS,IAAI,SAAS;AACpB,cAAQ,IAAIA,uBAAM,MAAM,WAAW,GAAG,GAAG,IAAI;AAAA,IAC/C;AAAA;AAAA,EAAA;AAGJ;;;;;"}
1
+ {"version":3,"file":"logger.cjs","sources":["../../src/node/fileExists.ts","../../src/node/core/isRecord.ts","../../src/node/core/pkg/validatePkg.ts","../../src/node/logger.ts"],"sourcesContent":["import {statSync} from 'fs'\n\n/** @internal */\nexport function fileExists(filePath: string): boolean {\n try {\n statSync(filePath)\n\n return true\n } catch (_) {\n return false\n }\n}\n","/** @internal */\nexport function isRecord(value: unknown): value is Record<string, unknown> {\n return Boolean(value) && !Array.isArray(value) && typeof value === 'object'\n}\n","import {z} from 'zod'\n\nimport {PackageJSON} from './types'\n\nconst pkgSchema = z.object({\n type: z.optional(z.enum(['commonjs', 'module'])),\n name: z.string(),\n version: z.string(),\n license: z.string(),\n bin: z.optional(z.record(z.string())),\n dependencies: z.optional(z.record(z.string())),\n devDependencies: z.optional(z.record(z.string())),\n peerDependencies: z.optional(z.record(z.string())),\n source: z.optional(z.string()),\n main: z.optional(z.string()),\n browser: z.optional(z.record(z.string())),\n module: z.optional(z.string()),\n types: z.optional(z.string()),\n exports: z.optional(\n z.record(\n z.union([\n z.custom<`./${string}.json`>((val) => /^\\.\\/.*\\.json$/.test(val as string)),\n z.object({\n types: z.optional(z.string()),\n source: z.string(),\n browser: z.optional(\n z.object({\n source: z.string(),\n import: z.optional(z.string()),\n require: z.optional(z.string()),\n }),\n ),\n node: z.optional(\n z.object({\n source: z.optional(z.string()),\n import: z.optional(z.string()),\n require: z.optional(z.string()),\n }),\n ),\n import: z.optional(z.string()),\n require: z.optional(z.string()),\n default: z.string(),\n }),\n z.object({\n types: z.optional(z.string()),\n svelte: z.string(),\n default: z.optional(z.string()),\n }),\n ]),\n ),\n ),\n browserslist: z.optional(z.union([z.string(), z.array(z.string())])),\n sideEffects: z.optional(z.union([z.boolean(), z.array(z.string())])),\n})\n\nexport function validatePkg(input: unknown): PackageJSON {\n return pkgSchema.parse(input)\n}\n","import chalk from 'chalk'\n\n/** @internal */\nexport interface Logger {\n log: (...args: unknown[]) => void\n info: (...args: unknown[]) => void\n warn: (...args: unknown[]) => void\n error: (...args: unknown[]) => void\n success: (...args: unknown[]) => void\n}\n\n/** @internal */\nexport function createLogger(): Logger {\n return {\n /* eslint-disable no-console */\n log: (...args) => {\n console.log(...args)\n },\n info: (...args) => {\n console.log(chalk.blue('[info]'), ...args)\n },\n warn: (...args) => {\n console.log(chalk.yellow('[warning]'), ...args)\n },\n error: (...args) => {\n console.log(chalk.red('[error]'), ...args)\n },\n success: (...args) => {\n console.log(chalk.green('[success]'), ...args)\n },\n /* eslint-enable no-console */\n }\n}\n"],"names":["statSync","z","chalk"],"mappings":";;;;;;AAGO,SAAS,WAAW,UAA2B;AAChD,MAAA;AACF,WAAAA,YAAS,QAAQ,GAEV;AAAA,EAAA,QACG;AACH,WAAA;AAAA,EACT;AACF;ACVO,SAAS,SAAS,OAAkD;AAClE,SAAA,CAAA,CAAQ,SAAU,CAAC,MAAM,QAAQ,KAAK,KAAK,OAAO,SAAU;AACrE;ACCA,MAAM,YAAYC,MAAE,OAAO;AAAA,EACzB,MAAMA,IAAAA,EAAE,SAASA,IAAA,EAAE,KAAK,CAAC,YAAY,QAAQ,CAAC,CAAC;AAAA,EAC/C,MAAMA,MAAE,OAAO;AAAA,EACf,SAASA,MAAE,OAAO;AAAA,EAClB,SAASA,MAAE,OAAO;AAAA,EAClB,KAAK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AAO,WAAW,GAAG,GAAG,IAAI;AAAA,IAChD;AAAA,IACA,OAAO,IAAI,SAAS;AAClB,cAAQ,IAAIA,uBAAM,IAAI,SAAS,GAAG,GAAG,IAAI;AAAA,IAC3C;AAAA,IACA,SAAS,IAAI,SAAS;AACpB,cAAQ,IAAIA,uBAAM,MAAM,WAAW,GAAG,GAAG,IAAI;AAAA,IAC/C;AAAA;AAAA,EAAA;AAGJ;;;;;"}
package/dist/cli.cjs CHANGED
@@ -3,7 +3,7 @@ var cac = require("cac");
3
3
  function _interopDefaultCompat(e) {
4
4
  return e && typeof e == "object" && "default" in e ? e : { default: e };
5
5
  }
6
- var cac__default = /* @__PURE__ */ _interopDefaultCompat(cac), version = "4.4.1";
6
+ var cac__default = /* @__PURE__ */ _interopDefaultCompat(cac), version = "5.0.1";
7
7
  const cli = cac__default.default();
8
8
  cli.command("", "Check").alias("check").option("--strict", "Strict mode").option("--tsconfig [tsconfig]", "[string] tsconfig.json").action(async (options) => {
9
9
  const { checkAction } = await Promise.resolve().then(function() {
package/dist/index.d.ts CHANGED
@@ -62,13 +62,12 @@ export declare interface BuildFile {
62
62
  }
63
63
 
64
64
  /** @internal */
65
- export declare type BuildTask = DtsTask | RollupTask | NodeReExportFromCJSTask
65
+ export declare type BuildTask = DtsTask | RollupTask
66
66
 
67
67
  /** @internal */
68
68
  export declare interface BuildTaskHandlers {
69
69
  'build:dts': TaskHandler<DtsTask, DtsResult>
70
70
  'build:js': TaskHandler<RollupTask>
71
- 'node:reexport-cjs': TaskHandler<NodeReExportFromCJSTask>
72
71
  }
73
72
 
74
73
  /** @internal */
@@ -183,16 +182,6 @@ export declare interface Logger {
183
182
  success: (...args: unknown[]) => void
184
183
  }
185
184
 
186
- /** @internal */
187
- export declare interface NodeReExportFromCJSTask {
188
- type: 'node:reexport-cjs'
189
- entries: {
190
- importId: string
191
- import: string
192
- require: string
193
- }[]
194
- }
195
-
196
185
  /** @internal */
197
186
  export declare interface PackageJSON {
198
187
  type?: 'commonjs' | 'module'
package/dist/index.js CHANGED
@@ -11,7 +11,7 @@ import { mkdirp } from "mkdirp";
11
11
  import prompts from "prompts";
12
12
  import ts from "typescript";
13
13
  import browserslist from "browserslist";
14
- import { Observable, from, switchMap } from "rxjs";
14
+ import { Observable, switchMap } from "rxjs";
15
15
  import rimraf from "rimraf";
16
16
  import { ExtractorConfig, Extractor } from "@microsoft/api-extractor";
17
17
  import prettier from "prettier";
@@ -113,12 +113,10 @@ const pkgSchema = z.object({
113
113
  node: z.optional(
114
114
  z.object({
115
115
  source: z.optional(z.string()),
116
- module: z.optional(z.string()),
117
116
  import: z.optional(z.string()),
118
117
  require: z.optional(z.string())
119
118
  })
120
119
  ),
121
- module: z.optional(z.string()),
122
120
  import: z.optional(z.string()),
123
121
  require: z.optional(z.string()),
124
122
  default: z.string()
@@ -167,32 +165,21 @@ async function loadPkgWithReporting(options2) {
167
165
  if (typeof exp == "string" || "svelte" in exp)
168
166
  continue;
169
167
  const keys = Object.keys(exp);
170
- if (assertFirst("types", keys) || (shouldError = !0, logger.error(`exports["${expPath}"]: the \`types\` property should be the first property`)), exp.node) {
171
- const nodeKeys = Object.keys(exp.node);
172
- assertOrder("module", "import", nodeKeys) || (shouldError = !0, logger.error(
173
- `exports["${expPath}"]: the \`node.module\` property should come before the \`node.import\` property`
174
- )), assertOrder("import", "require", nodeKeys) || logger.warn(
175
- `exports["${expPath}"]: the \`node.import\` property should come before the \`node.require\` property`
176
- ), assertOrder("module", "require", nodeKeys) || logger.warn(
177
- `exports["${expPath}"]: the \`node.module\` property should come before \`node.require\` property`
178
- ), exp.import && exp.node.import && !assertOrder("node", "import", keys) && (shouldError = !0, logger.error(
179
- `exports["${expPath}"]: the \`node\` property should come before the \`import\` property`
180
- )), exp.module && exp.node.module && !assertOrder("node", "module", keys) && (shouldError = !0, logger.error(
181
- `exports["${expPath}"]: the \`node\` property should come before the \`module\` property`
182
- )), exp.node.import && !exp.node.require && exp.node.module && exp.import && exp.node.module !== exp.import && (shouldError = !0, logger.error(
183
- `exports["${expPath}"]: the \`node.module\` property should match \`import\``
184
- )), exp.require && exp.node.require && exp.require === exp.node.require ? (shouldError = !0, logger.error(
185
- `exports["${expPath}"]: the \`node.require\` property isn't necessary as it's identical to \`require\``
186
- )) : exp.require && exp.node.require && !assertOrder("node", "require", keys) && (shouldError = !0, logger.error(
187
- `exports["${expPath}"]: the \`node\` property should come before the \`require\` property`
188
- ));
189
- } else
190
- assertOrder("import", "require", keys) || logger.warn(
191
- `exports["${expPath}"]: the \`import\` property should come before the \`require\` property`
192
- ), assertOrder("module", "import", keys) || logger.warn(
193
- `exports["${expPath}"]: the \`module\` property should come before \`import\` property`
194
- );
195
- assertLast("default", keys) || (shouldError = !0, logger.error(
168
+ assertFirst("types", keys) || (shouldError = !0, logger.error(`exports["${expPath}"]: the \`types\` property should be the first property`)), exp.module && (shouldError = !0, logger.error(
169
+ `exports["${expPath}"]: the \`module\` condition shouldn't be used as it's not well supported in all bundlers.`
170
+ )), exp.node ? (exp.import && exp.node.import && !assertOrder("node", "import", keys) && (shouldError = !0, logger.error(
171
+ `exports["${expPath}"]: the \`node\` property should come before the \`import\` property`
172
+ )), exp.node.module && (shouldError = !0, logger.error(
173
+ `exports["${expPath}"]: the \`node.module\` condition shouldn't be used as it's not well supported in all bundlers. A better strategy is to refactor the codebase to no longer be vulnerable to the "dual package hazard"`
174
+ )), !exp.node.source && exp.node.import && (exp.node.require || exp.require) && (exp.node.import.endsWith(".cjs.js") || exp.node.import.endsWith(".cjs.mjs")) && (shouldError = !0, logger.error(
175
+ `exports["${expPath}"]: the \`node.import\` re-export pattern shouldn't be used as it's not well supported in all bundlers. A better strategy is to refactor the codebase to no longer be vulnerable to the "dual package hazard"`
176
+ )), exp.require && exp.node.require && exp.require === exp.node.require ? (shouldError = !0, logger.error(
177
+ `exports["${expPath}"]: the \`node.require\` property isn't necessary as it's identical to \`require\``
178
+ )) : exp.require && exp.node.require && !assertOrder("node", "require", keys) && (shouldError = !0, logger.error(
179
+ `exports["${expPath}"]: the \`node\` property should come before the \`require\` property`
180
+ ))) : assertOrder("import", "require", keys) || logger.warn(
181
+ `exports["${expPath}"]: the \`import\` property should come before the \`require\` property`
182
+ ), assertLast("default", keys) || (shouldError = !0, logger.error(
196
183
  `exports["${expPath}"]: the \`default\` property should be the last property`
197
184
  ));
198
185
  }
@@ -593,20 +580,7 @@ function resolveBuildTasks(ctx) {
593
580
  }
594
581
  }
595
582
  }
596
- const nodeReexportCjsEntries = [];
597
- for (const exp of exports)
598
- if (exp.node && !exp.node.source && exp.node.import && (exp.node.require || exp.require) && (exp.node.import.endsWith(".cjs.js") || exp.node.import.endsWith(".cjs.mjs"))) {
599
- const importId = path$1.join(pkg.name, exp._path);
600
- nodeReexportCjsEntries.push({
601
- importId,
602
- import: exp.node.import,
603
- require: exp.node.require || exp.require
604
- });
605
- }
606
- return nodeReexportCjsEntries.length && tasks.push({
607
- type: "node:reexport-cjs",
608
- entries: nodeReexportCjsEntries
609
- }), tasks;
583
+ return tasks;
610
584
  }
611
585
  function createSpinner(msg) {
612
586
  const startTime = Date.now();
@@ -1012,11 +986,11 @@ function __spreadArrays() {
1012
986
  r[k] = a[j];
1013
987
  return r;
1014
988
  }
1015
- function __spreadArray(to, from2, pack) {
989
+ function __spreadArray(to, from, pack) {
1016
990
  if (pack || arguments.length === 2)
1017
- for (var i = 0, l = from2.length, ar; i < l; i++)
1018
- (ar || !(i in from2)) && (ar || (ar = Array.prototype.slice.call(from2, 0, i)), ar[i] = from2[i]);
1019
- return to.concat(ar || Array.prototype.slice.call(from2));
991
+ for (var i = 0, l = from.length, ar; i < l; i++)
992
+ (ar || !(i in from)) && (ar || (ar = Array.prototype.slice.call(from, 0, i)), ar[i] = from[i]);
993
+ return to.concat(ar || Array.prototype.slice.call(from));
1020
994
  }
1021
995
  function __await(v) {
1022
996
  return this instanceof __await ? (this.v = v, this) : new __await(v);
@@ -1736,13 +1710,13 @@ function requireTypes() {
1736
1710
  throw new Error("");
1737
1711
  hasOwn.call(lastSeen, typeName) && delete list[lastSeen[typeName]], lastSeen[typeName] = pos, list.push.apply(list, d.baseNames);
1738
1712
  }
1739
- for (var to = 0, from2 = to, len = list.length; from2 < len; ++from2)
1740
- hasOwn.call(list, from2) && (list[to++] = list[from2]);
1713
+ for (var to = 0, from = to, len = list.length; from < len; ++from)
1714
+ hasOwn.call(list, from) && (list[to++] = list[from]);
1741
1715
  list.length = to;
1742
1716
  }
1743
- function extend(into, from2) {
1744
- return Object.keys(from2).forEach(function(name) {
1745
- into[name] = from2[name];
1717
+ function extend(into, from) {
1718
+ return Object.keys(from).forEach(function(name) {
1719
+ into[name] = from[name];
1746
1720
  }), into;
1747
1721
  }
1748
1722
  function finalize() {
@@ -9343,8 +9317,8 @@ function requirePatcher() {
9343
9317
  end: { line: lines2.length, column: lines2.getLineLength(lines2.length) }
9344
9318
  };
9345
9319
  var sliceFrom = loc.start, toConcat = [];
9346
- function pushSlice(from2, to) {
9347
- (0, tiny_invariant_1.default)((0, util_1.comparePos)(from2, to) <= 0), toConcat.push(lines2.slice(from2, to));
9320
+ function pushSlice(from, to) {
9321
+ (0, tiny_invariant_1.default)((0, util_1.comparePos)(from, to) <= 0), toConcat.push(lines2.slice(from, to));
9348
9322
  }
9349
9323
  return replacements.sort(function(a, b) {
9350
9324
  return (0, util_1.comparePos)(a.start, b.start);
@@ -10743,11 +10717,11 @@ while`), parts.push(" (", path2.call(print, "test"), ");"), (0, lines_1.concat)(
10743
10717
  parts.push("*");
10744
10718
  else if (decl.specifiers.length === 0)
10745
10719
  parts.push("{}");
10746
- else if (decl.specifiers[0].type === "ExportDefaultSpecifier") {
10720
+ else if (decl.specifiers[0].type === "ExportDefaultSpecifier" || decl.specifiers[0].type === "ExportNamespaceSpecifier") {
10747
10721
  var unbracedSpecifiers_2 = [], bracedSpecifiers_2 = [];
10748
10722
  if (path2.each(function(specifierPath) {
10749
10723
  var spec = specifierPath.getValue();
10750
- spec.type === "ExportDefaultSpecifier" ? unbracedSpecifiers_2.push(print(specifierPath)) : bracedSpecifiers_2.push(print(specifierPath));
10724
+ spec.type === "ExportDefaultSpecifier" || spec.type === "ExportNamespaceSpecifier" ? unbracedSpecifiers_2.push(print(specifierPath)) : bracedSpecifiers_2.push(print(specifierPath));
10751
10725
  }, "specifiers"), unbracedSpecifiers_2.forEach(function(lines3, i) {
10752
10726
  i > 0 && parts.push(", "), parts.push(lines3);
10753
10727
  }), bracedSpecifiers_2.length > 0) {
@@ -20315,48 +20289,7 @@ const dtsTask = {
20315
20289
  const { logger } = ctx;
20316
20290
  err instanceof DtsError ? printExtractMessages(ctx, err.messages) : err instanceof Error && logger.error(err);
20317
20291
  }
20318
- }, nodeReexportCjsTask = {
20319
- name: (_ctx, task) => [
20320
- "Re-export CommonJS module in ESM wrapper\u2026",
20321
- " entries:",
20322
- ...task.entries.map(
20323
- (entry) => [
20324
- ` - ${chalk.cyan(entry.importId)}: `,
20325
- `${chalk.yellow(entry.require)} ${chalk.gray("\u2192")} ${chalk.yellow(entry.import)}`
20326
- ].join("")
20327
- )
20328
- ].join(`
20329
- `),
20330
- exec: (ctx, task) => from(exec(ctx, task)),
20331
- complete: () => {
20332
- },
20333
- error: (_ctx, _task, err) => {
20334
- console.error(err);
20335
- }
20336
20292
  };
20337
- async function exec(ctx, task) {
20338
- const { cwd } = ctx;
20339
- for (const entry of task.entries) {
20340
- const sourcePath = path$1.resolve(cwd, entry.require), targetPath = path$1.resolve(cwd, entry.import), targetDir = path$1.dirname(targetPath);
20341
- await mkdirp(targetDir);
20342
- const mod = require(sourcePath);
20343
- let relativeImport = `./${path$1.relative(targetDir, sourcePath)}`;
20344
- relativeImport.startsWith("./.") && (relativeImport = relativeImport.slice(2));
20345
- const code = compileESMWrapper(mod, relativeImport);
20346
- await writeFile(targetPath, code, "utf8");
20347
- }
20348
- }
20349
- function compileESMWrapper(mod, relativeImport) {
20350
- const keys = Object.keys(mod).filter((k) => k !== "__esModule");
20351
- let code = `import cjs from '${relativeImport}';
20352
- `;
20353
- return keys.length && (code += `
20354
- `, code += keys.filter((k) => mod.__esModule ? k !== "default" : !0).map((k) => `export const ${k} = cjs.${k};
20355
- `).join("")), code += `
20356
- `, mod.__esModule ? "default" in mod && (code += `export default cjs.default;
20357
- `) : code += `export default cjs;
20358
- `, code;
20359
- }
20360
20293
  function createConsoleSpy(options2) {
20361
20294
  const { onRestored } = options2 || {}, original = {
20362
20295
  log: console.log,
@@ -20601,8 +20534,7 @@ const rollupWatchTask = {
20601
20534
  }
20602
20535
  }, buildTaskHandlers = {
20603
20536
  "build:dts": dtsTask,
20604
- "build:js": rollupTask,
20605
- "node:reexport-cjs": nodeReexportCjsTask
20537
+ "build:js": rollupTask
20606
20538
  }, watchTaskHandlers = {
20607
20539
  "watch:dts": dtsWatchTask,
20608
20540
  "watch:js": rollupWatchTask