@sanity/pkg-utils 7.2.10-canary.4 → 7.4.0-canary.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 (57) hide show
  1. package/bin/pkg-utils.js +2 -0
  2. package/dist/_chunks-cjs/index.cjs +1510 -45
  3. package/dist/_chunks-cjs/index.cjs.map +1 -1
  4. package/dist/_chunks-cjs/resolveRolldownConfig.cjs +2 -2
  5. package/dist/_chunks-cjs/resolveRolldownConfig.cjs.map +1 -1
  6. package/dist/{_chunks-cjs/build.cjs → _chunks-es/build.js} +28 -26
  7. package/dist/_chunks-es/build.js.map +1 -0
  8. package/dist/{_chunks-cjs/buildAction.cjs → _chunks-es/buildAction.js} +8 -6
  9. package/dist/_chunks-es/buildAction.js.map +1 -0
  10. package/dist/{_chunks-cjs/check.cjs → _chunks-es/check.js} +30 -26
  11. package/dist/_chunks-es/check.js.map +1 -0
  12. package/dist/_chunks-es/checkAction.js +17 -0
  13. package/dist/_chunks-es/checkAction.js.map +1 -0
  14. package/dist/{_chunks-cjs/consoleSpy.cjs → _chunks-es/consoleSpy.js} +105 -96
  15. package/dist/_chunks-es/consoleSpy.js.map +1 -0
  16. package/dist/_chunks-es/handleError.js +8 -0
  17. package/dist/_chunks-es/handleError.js.map +1 -0
  18. package/dist/_chunks-es/index.js +54 -1518
  19. package/dist/_chunks-es/index.js.map +1 -1
  20. package/dist/{_chunks-cjs/init.cjs → _chunks-es/init.js} +53 -47
  21. package/dist/_chunks-es/init.js.map +1 -0
  22. package/dist/_chunks-es/initAction.js +16 -0
  23. package/dist/_chunks-es/initAction.js.map +1 -0
  24. package/dist/_chunks-es/isRecord.js +37 -0
  25. package/dist/_chunks-es/isRecord.js.map +1 -0
  26. package/dist/_chunks-es/resolveRolldownConfig.js +1 -1
  27. package/dist/_chunks-es/watch.js +146 -0
  28. package/dist/_chunks-es/watch.js.map +1 -0
  29. package/dist/_chunks-es/watchAction.js +17 -0
  30. package/dist/_chunks-es/watchAction.js.map +1 -0
  31. package/dist/{cli.cjs → cli.js} +9 -19
  32. package/dist/cli.js.map +1 -0
  33. package/dist/index.cjs +16 -19
  34. package/dist/index.cjs.map +1 -1
  35. package/dist/index.js +10 -1
  36. package/dist/index.js.map +1 -1
  37. package/package.json +5 -5
  38. package/bin/pkg-utils.cjs +0 -2
  39. package/dist/_chunks-cjs/build.cjs.map +0 -1
  40. package/dist/_chunks-cjs/buildAction.cjs.map +0 -1
  41. package/dist/_chunks-cjs/check.cjs.map +0 -1
  42. package/dist/_chunks-cjs/checkAction.cjs +0 -15
  43. package/dist/_chunks-cjs/checkAction.cjs.map +0 -1
  44. package/dist/_chunks-cjs/consoleSpy.cjs.map +0 -1
  45. package/dist/_chunks-cjs/handleError.cjs +0 -11
  46. package/dist/_chunks-cjs/handleError.cjs.map +0 -1
  47. package/dist/_chunks-cjs/init.cjs.map +0 -1
  48. package/dist/_chunks-cjs/initAction.cjs +0 -14
  49. package/dist/_chunks-cjs/initAction.cjs.map +0 -1
  50. package/dist/_chunks-cjs/isRecord.cjs +0 -39
  51. package/dist/_chunks-cjs/isRecord.cjs.map +0 -1
  52. package/dist/_chunks-cjs/watch.cjs +0 -157
  53. package/dist/_chunks-cjs/watch.cjs.map +0 -1
  54. package/dist/_chunks-cjs/watchAction.cjs +0 -15
  55. package/dist/_chunks-cjs/watchAction.cjs.map +0 -1
  56. package/dist/cli.cjs.map +0 -1
  57. /package/dist/{cli.d.cts → cli.d.ts} +0 -0
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
- var path = require("node:path"), rolldownPluginDts = require("rolldown-plugin-dts"), consoleSpy = require("./consoleSpy.cjs");
2
+ var path = require("node:path"), rolldownPluginDts = require("rolldown-plugin-dts"), index = require("./index.cjs");
3
3
  function _interopDefaultCompat(e) {
4
4
  return e && typeof e == "object" && "default" in e ? e : { default: e };
5
5
  }
6
6
  var path__default = /* @__PURE__ */ _interopDefaultCompat(path);
7
7
  function resolveRolldownConfig(ctx, buildTask) {
8
- const { format, runtime, target } = buildTask, { config, cwd, exports: _exports, external, distPath, logger, pkg, ts } = ctx, outputExt = consoleSpy.pkgExtMap[pkg.type || "commonjs"][format], outDir = path__default.default.relative(cwd, distPath), pathAliases = Object.fromEntries(
8
+ const { format, runtime, target } = buildTask, { config, cwd, exports: _exports, external, distPath, logger, pkg, ts } = ctx, outputExt = index.pkgExtMap[pkg.type || "commonjs"][format], outDir = path__default.default.relative(cwd, distPath), pathAliases = Object.fromEntries(
9
9
  Object.entries(ts.config?.options.paths || {}).map(([key, val]) => [key, path__default.default.resolve(cwd, ts.config?.options.baseUrl || ".", val[0])])
10
10
  ), entries = buildTask.entries.map((entry) => ({
11
11
  ...entry,
@@ -1 +1 @@
1
- {"version":3,"file":"resolveRolldownConfig.cjs","sources":["../../src/node/tasks/rolldown/resolveRolldownConfig.ts"],"sourcesContent":["import path from 'node:path'\nimport type {InputOptions, OutputOptions} from 'rolldown'\nimport {dts as dtsPlugin} from 'rolldown-plugin-dts'\nimport type {BuildContext} from '../../core/contexts/buildContext'\nimport {pkgExtMap as extMap} from '../../core/pkg/pkgExt'\nimport type {RolldownDtsTask} from '../types'\n\nexport interface RolldownConfig {\n inputOptions: InputOptions\n outputOptions: OutputOptions\n}\n\nexport function resolveRolldownConfig(\n ctx: BuildContext,\n buildTask: RolldownDtsTask,\n): RolldownConfig {\n const {format, runtime, target} = buildTask\n const {config, cwd, exports: _exports, external, distPath, logger, pkg, ts} = ctx\n const outputExt = extMap[pkg.type || 'commonjs'][format]\n const outDir = path.relative(cwd, distPath)\n\n const pathAliases = Object.fromEntries(\n Object.entries(ts.config?.options.paths || {}).map(([key, val]) => {\n return [key, path.resolve(cwd, ts.config?.options.baseUrl || '.', val[0])]\n }),\n )\n\n const entries = buildTask.entries.map((entry) => {\n return {\n ...entry,\n name: path.relative(outDir, entry.output).replace(/\\.[^/.]+$/, ''),\n }\n }, {})\n\n const exportIds =\n _exports && Object.keys(_exports).map((exportPath) => path.join(pkg.name, exportPath))\n\n const sourcePaths = _exports && Object.values(_exports).map((e) => path.resolve(cwd, e.source))\n\n const replacements = Object.fromEntries(\n Object.entries(config?.define || {}).map(([key, val]) => [key, JSON.stringify(val)]),\n )\n\n const hashChunkFileNames = config?.rollup?.hashChunkFileNames ?? false\n const chunksFolder = hashChunkFileNames ? '_chunks' : '_chunks-[format]'\n const chunkFileNames = `${chunksFolder}/${hashChunkFileNames ? '[name]-[hash]' : '[name]'}${outputExt}`\n const entryFileNames = `[name]${outputExt}`\n\n const inputOptions = {\n cwd,\n jsx: {\n mode:\n config?.jsx === 'automatic'\n ? 'automatic'\n : config?.jsx === 'preserve'\n ? 'preserve'\n : config?.jsx === 'transform'\n ? 'classic'\n : 'automatic',\n factory: config?.jsxFactory,\n fragment: config?.jsxFragment,\n importSource: config?.jsxImportSource,\n },\n define:\n pkg.name === '@sanity/pkg-utils'\n ? {...replacements}\n : {\n 'process.env.PKG_FORMAT': JSON.stringify(format),\n 'process.env.PKG_RUNTIME': JSON.stringify(runtime),\n 'process.env.PKG_VERSION': JSON.stringify(process.env['PKG_VERSION'] || pkg.version),\n ...replacements,\n },\n\n platform:\n buildTask.type === 'rolldown:dts'\n ? 'node'\n : runtime === 'node'\n ? 'node'\n : runtime === 'browser'\n ? 'browser'\n : 'neutral',\n\n resolve: {\n alias: pathAliases,\n tsconfigFilename: ctx.ts.configPath || 'tsconfig.json',\n },\n transform: {\n target,\n },\n experimental: {\n attachDebugInfo: 'none',\n },\n\n external: (id, importer) => {\n // Check if the id is a self-referencing import\n if (exportIds?.includes(id)) {\n return true\n }\n\n // Check if the id is a file path that points to an exported source file\n if (importer && (id.startsWith('.') || id.startsWith('/'))) {\n const idPath = path.resolve(path.dirname(importer), id)\n\n if (sourcePaths?.includes(idPath)) {\n logger.warn(\n `detected self-referencing import – treating as external: ${path.relative(\n cwd,\n idPath,\n )}`,\n )\n\n return true\n }\n }\n\n const idParts = id.split('/')\n\n const name = idParts[0].startsWith('@') ? `${idParts[0]}/${idParts[1]}` : idParts[0]\n\n if (name && external.includes(name)) {\n return true\n }\n\n return false\n },\n\n input: entries.reduce<{[entryAlias: string]: string}>(\n (acc, entry) => Object.assign(acc, {[entry.name]: entry.source}),\n {},\n ),\n\n plugins: [\n dtsPlugin({\n emitDtsOnly: true,\n tsconfig: ctx.ts.configPath || 'tsconfig.json',\n tsgo:\n typeof pkg.devDependencies === 'object' &&\n '@typescript/native-preview' in pkg.devDependencies,\n }),\n ],\n\n treeshake: true,\n } satisfies InputOptions\n const outputOptions = {\n chunkFileNames,\n dir: outDir,\n entryFileNames,\n esModule: true,\n format: buildTask.type === 'rolldown:dts' ? 'es' : format,\n sourcemap: buildTask.type === 'rolldown:dts' ? false : (config?.sourcemap ?? true),\n hoistTransitiveImports: false,\n } satisfies OutputOptions\n\n return {inputOptions, outputOptions}\n}\n"],"names":["extMap","path","dtsPlugin"],"mappings":";;;;;;AAYgB,SAAA,sBACd,KACA,WACgB;AAChB,QAAM,EAAC,QAAQ,SAAS,OAAA,IAAU,WAC5B,EAAC,QAAQ,KAAK,SAAS,UAAU,UAAU,UAAU,QAAQ,KAAK,GAAM,IAAA,KACxE,YAAYA,WAAA,UAAO,IAAI,QAAQ,UAAU,EAAE,MAAM,GACjD,SAASC,sBAAK,SAAS,KAAK,QAAQ,GAEpC,cAAc,OAAO;AAAA,IACzB,OAAO,QAAQ,GAAG,QAAQ,QAAQ,SAAS,CAAE,CAAA,EAAE,IAAI,CAAC,CAAC,KAAK,GAAG,MACpD,CAAC,KAAKA,sBAAK,QAAQ,KAAK,GAAG,QAAQ,QAAQ,WAAW,KAAK,IAAI,CAAC,CAAC,CAAC,CAC1E;AAAA,KAGG,UAAU,UAAU,QAAQ,IAAI,CAAC,WAC9B;AAAA,IACL,GAAG;AAAA,IACH,MAAMA,cAAAA,QAAK,SAAS,QAAQ,MAAM,MAAM,EAAE,QAAQ,aAAa,EAAE;AAAA,EAAA,IAElE,CAAE,CAAA,GAEC,YACJ,YAAY,OAAO,KAAK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:path'\nimport type {InputOptions, OutputOptions} from 'rolldown'\nimport {dts as dtsPlugin} from 'rolldown-plugin-dts'\nimport type {BuildContext} from '../../core/contexts/buildContext'\nimport {pkgExtMap as extMap} from '../../core/pkg/pkgExt'\nimport type {RolldownDtsTask} from '../types'\n\nexport interface RolldownConfig {\n inputOptions: InputOptions\n outputOptions: OutputOptions\n}\n\nexport function resolveRolldownConfig(\n ctx: BuildContext,\n buildTask: RolldownDtsTask,\n): RolldownConfig {\n const {format, runtime, target} = buildTask\n const {config, cwd, exports: _exports, external, distPath, logger, pkg, ts} = ctx\n const outputExt = extMap[pkg.type || 'commonjs'][format]\n const outDir = path.relative(cwd, distPath)\n\n const pathAliases = Object.fromEntries(\n Object.entries(ts.config?.options.paths || {}).map(([key, val]) => {\n return [key, path.resolve(cwd, ts.config?.options.baseUrl || '.', val[0])]\n }),\n )\n\n const entries = buildTask.entries.map((entry) => {\n return {\n ...entry,\n name: path.relative(outDir, entry.output).replace(/\\.[^/.]+$/, ''),\n }\n }, {})\n\n const exportIds =\n _exports && Object.keys(_exports).map((exportPath) => path.join(pkg.name, exportPath))\n\n const sourcePaths = _exports && Object.values(_exports).map((e) => path.resolve(cwd, e.source))\n\n const replacements = Object.fromEntries(\n Object.entries(config?.define || {}).map(([key, val]) => [key, JSON.stringify(val)]),\n )\n\n const hashChunkFileNames = config?.rollup?.hashChunkFileNames ?? false\n const chunksFolder = hashChunkFileNames ? '_chunks' : '_chunks-[format]'\n const chunkFileNames = `${chunksFolder}/${hashChunkFileNames ? '[name]-[hash]' : '[name]'}${outputExt}`\n const entryFileNames = `[name]${outputExt}`\n\n const inputOptions = {\n cwd,\n jsx: {\n mode:\n config?.jsx === 'automatic'\n ? 'automatic'\n : config?.jsx === 'preserve'\n ? 'preserve'\n : config?.jsx === 'transform'\n ? 'classic'\n : 'automatic',\n factory: config?.jsxFactory,\n fragment: config?.jsxFragment,\n importSource: config?.jsxImportSource,\n },\n define:\n pkg.name === '@sanity/pkg-utils'\n ? {...replacements}\n : {\n 'process.env.PKG_FORMAT': JSON.stringify(format),\n 'process.env.PKG_RUNTIME': JSON.stringify(runtime),\n 'process.env.PKG_VERSION': JSON.stringify(process.env['PKG_VERSION'] || pkg.version),\n ...replacements,\n },\n\n platform:\n buildTask.type === 'rolldown:dts'\n ? 'node'\n : runtime === 'node'\n ? 'node'\n : runtime === 'browser'\n ? 'browser'\n : 'neutral',\n\n resolve: {\n alias: pathAliases,\n tsconfigFilename: ctx.ts.configPath || 'tsconfig.json',\n },\n transform: {\n target,\n },\n experimental: {\n attachDebugInfo: 'none',\n },\n\n external: (id, importer) => {\n // Check if the id is a self-referencing import\n if (exportIds?.includes(id)) {\n return true\n }\n\n // Check if the id is a file path that points to an exported source file\n if (importer && (id.startsWith('.') || id.startsWith('/'))) {\n const idPath = path.resolve(path.dirname(importer), id)\n\n if (sourcePaths?.includes(idPath)) {\n logger.warn(\n `detected self-referencing import – treating as external: ${path.relative(\n cwd,\n idPath,\n )}`,\n )\n\n return true\n }\n }\n\n const idParts = id.split('/')\n\n const name = idParts[0].startsWith('@') ? `${idParts[0]}/${idParts[1]}` : idParts[0]\n\n if (name && external.includes(name)) {\n return true\n }\n\n return false\n },\n\n input: entries.reduce<{[entryAlias: string]: string}>(\n (acc, entry) => Object.assign(acc, {[entry.name]: entry.source}),\n {},\n ),\n\n plugins: [\n dtsPlugin({\n emitDtsOnly: true,\n tsconfig: ctx.ts.configPath || 'tsconfig.json',\n tsgo:\n typeof pkg.devDependencies === 'object' &&\n '@typescript/native-preview' in pkg.devDependencies,\n }),\n ],\n\n treeshake: true,\n } satisfies InputOptions\n const outputOptions = {\n chunkFileNames,\n dir: outDir,\n entryFileNames,\n esModule: true,\n format: buildTask.type === 'rolldown:dts' ? 'es' : format,\n sourcemap: buildTask.type === 'rolldown:dts' ? false : (config?.sourcemap ?? true),\n hoistTransitiveImports: false,\n } satisfies OutputOptions\n\n return {inputOptions, outputOptions}\n}\n"],"names":["extMap","path","dtsPlugin"],"mapp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,IAEA,OAAO,QAAQ;AAAA,MACb,CAAC,KAAK,UAAU,OAAO,OAAO,KAAK,EAAC,CAAC,MAAM,IAAI,GAAG,MAAM,QAAO;AAAA,MAC/D,CAAA;AAAA,IACF;AAAA,IAEA,SAAS;AAAA,MACPC,sBAAU;AAAA,QACR,aAAa;AAAA,QACb,UAAU,IAAI,GAAG,cAAc;AAAA,QAC/B,MACE,OAAO,IAAI,mBAAoB,YAC/B,gCAAgC,IAAI;AAAA,MACvC,CAAA;AAAA,IACH;AAAA,IAEA,WAAW;AAAA,KAEP,gBAAgB;AAAA,IACpB;AAAA,IACA,KAAK;AAAA,IACL;AAAA,IACA,UAAU;AAAA,IACV,QAAQ,UAAU,SAAS,iBAAiB,OAAO;AAAA,IACnD,WAAW,UAAU,SAAS,iBAAiB,KAAS,QAAQ,aAAa;AAAA,IAC7E,wBAAwB;AAAA,EAC1B;AAEO,SAAA,EAAC,cAAc,cAAa;AACrC;;"}
@@ -1,11 +1,11 @@
1
- "use strict";
2
- var path = require("node:path"), rimraf = require("rimraf"), consoleSpy = require("./consoleSpy.cjs"), isRecord = require("./isRecord.cjs"), chalk = require("chalk"), index = require("./index.cjs");
3
- function _interopDefaultCompat(e) {
4
- return e && typeof e == "object" && "default" in e ? e : { default: e };
5
- }
6
- var path__default = /* @__PURE__ */ _interopDefaultCompat(path), chalk__default = /* @__PURE__ */ _interopDefaultCompat(chalk);
1
+ import path from "node:path";
2
+ import { rimraf } from "rimraf";
3
+ import { getTargetPaths, loadConfig, loadPkgWithReporting, resolveBuildContext } from "./consoleSpy.js";
4
+ import { createLogger } from "./isRecord.js";
5
+ import chalk from "chalk";
6
+ import { buildTaskHandlers } from "./index.js";
7
7
  function resolveBuildTasks(ctx) {
8
- const { config, pkg, target } = ctx, bundles = config?.bundles || [], tasks = [], exports2 = Object.entries(ctx.exports || {}).map(
8
+ const { config, pkg, target } = ctx, bundles = config?.bundles || [], tasks = [], exports = Object.entries(ctx.exports || {}).map(
9
9
  ([_path, exp]) => ({ _path, ...exp })
10
10
  ), dtsTask = {
11
11
  type: "build:dts",
@@ -30,38 +30,38 @@ function resolveBuildTasks(ctx) {
30
30
  });
31
31
  }
32
32
  if (ctx.dts === "api-extractor") {
33
- for (const exp of exports2) {
34
- const importId = path__default.default.join(pkg.name, exp._path);
33
+ for (const exp of exports) {
34
+ const importId = path.join(pkg.name, exp._path);
35
35
  exp.source?.endsWith(".ts") && dtsTask.entries.push({
36
36
  importId,
37
37
  exportPath: exp._path,
38
38
  sourcePath: exp.source,
39
- targetPaths: consoleSpy.getTargetPaths(pkg.type, exp)
39
+ targetPaths: getTargetPaths(pkg.type, exp)
40
40
  }), exp.browser?.source?.endsWith(".ts") && dtsTask.entries.push({
41
41
  importId,
42
42
  exportPath: exp._path,
43
43
  sourcePath: exp.browser.source,
44
- targetPaths: consoleSpy.getTargetPaths(pkg.type, exp.browser)
44
+ targetPaths: getTargetPaths(pkg.type, exp.browser)
45
45
  }), exp.node?.source?.endsWith(".ts") && dtsTask.entries.push({
46
46
  importId,
47
47
  exportPath: exp._path,
48
48
  sourcePath: exp.node.source,
49
- targetPaths: consoleSpy.getTargetPaths(pkg.type, exp.node)
49
+ targetPaths: getTargetPaths(pkg.type, exp.node)
50
50
  });
51
51
  }
52
52
  for (const bundle of bundles)
53
53
  if (bundle.source?.endsWith(".ts")) {
54
- const exportPath = (bundle.import || bundle.require).replace(/\.[mc]?js$/, ""), importId = path__default.default.join(pkg.name, exportPath);
54
+ const exportPath = (bundle.import || bundle.require).replace(/\.[mc]?js$/, ""), importId = path.join(pkg.name, exportPath);
55
55
  dtsTask.entries.push({
56
56
  importId,
57
57
  exportPath,
58
58
  sourcePath: bundle.source,
59
- targetPaths: consoleSpy.getTargetPaths(pkg.type, bundle)
59
+ targetPaths: getTargetPaths(pkg.type, bundle)
60
60
  });
61
61
  }
62
62
  dtsTask.entries.length && tasks.push(dtsTask);
63
63
  }
64
- for (const exp of exports2) {
64
+ for (const exp of exports) {
65
65
  const output = exp.require;
66
66
  output && addRollupTaskEntry("commonjs", ctx.runtime, {
67
67
  path: exp._path,
@@ -69,7 +69,7 @@ function resolveBuildTasks(ctx) {
69
69
  output
70
70
  });
71
71
  }
72
- for (const exp of exports2) {
72
+ for (const exp of exports) {
73
73
  const output = exp.import;
74
74
  output && addRollupTaskEntry("esm", ctx.runtime, {
75
75
  path: exp._path,
@@ -77,7 +77,7 @@ function resolveBuildTasks(ctx) {
77
77
  output
78
78
  });
79
79
  }
80
- for (const exp of exports2) {
80
+ for (const exp of exports) {
81
81
  const output = exp.browser?.require;
82
82
  output && addRollupTaskEntry("commonjs", "browser", {
83
83
  path: exp._path,
@@ -85,7 +85,7 @@ function resolveBuildTasks(ctx) {
85
85
  output
86
86
  });
87
87
  }
88
- for (const exp of exports2) {
88
+ for (const exp of exports) {
89
89
  const output = exp.browser?.import;
90
90
  output && addRollupTaskEntry("esm", "browser", {
91
91
  path: exp._path,
@@ -111,10 +111,10 @@ function createSpinner(msg) {
111
111
  const startTime = Date.now();
112
112
  return console.log(msg), {
113
113
  complete: () => {
114
- console.log(`${chalk__default.default.green("[success]")} ${chalk__default.default.gray(`${Date.now() - startTime}ms`)}`);
114
+ console.log(`${chalk.green("[success]")} ${chalk.gray(`${Date.now() - startTime}ms`)}`);
115
115
  },
116
116
  error: () => {
117
- console.log(`${chalk__default.default.red("[error]")} ${chalk__default.default.gray(`${Date.now() - startTime}ms`)}`);
117
+ console.log(`${chalk.red("[error]")} ${chalk.gray(`${Date.now() - startTime}ms`)}`);
118
118
  }
119
119
  };
120
120
  }
@@ -125,7 +125,7 @@ async function build(options) {
125
125
  strict = !1,
126
126
  tsconfig: tsconfigOption,
127
127
  clean = !1
128
- } = options, logger = isRecord.createLogger(), config = await consoleSpy.loadConfig({ cwd }), pkg = await consoleSpy.loadPkgWithReporting({ cwd, logger, strict }), tsconfig = tsconfigOption || config?.tsconfig || "tsconfig.json", ctx = await consoleSpy.resolveBuildContext({
128
+ } = options, logger = createLogger(), config = await loadConfig({ cwd }), pkg = await loadPkgWithReporting({ cwd, logger, strict }), tsconfig = tsconfigOption || config?.tsconfig || "tsconfig.json", ctx = await resolveBuildContext({
129
129
  config,
130
130
  cwd,
131
131
  emitDeclarationOnly,
@@ -135,11 +135,11 @@ async function build(options) {
135
135
  tsconfig
136
136
  });
137
137
  clean && (logger.log(
138
- `Deleting the \`dist\` folder: './${path__default.default.relative(cwd, ctx.distPath)}' before building...`
139
- ), await rimraf.rimraf(ctx.distPath));
138
+ `Deleting the \`dist\` folder: './${path.relative(cwd, ctx.distPath)}' before building...`
139
+ ), await rimraf(ctx.distPath));
140
140
  const buildTasks = resolveBuildTasks(ctx);
141
141
  for (const task of buildTasks) {
142
- const handler = index.buildTaskHandlers[task.type], taskName = handler.name(ctx, task), spinner = createSpinner(taskName);
142
+ const handler = buildTaskHandlers[task.type], taskName = handler.name(ctx, task), spinner = createSpinner(taskName);
143
143
  try {
144
144
  const result = await handler.exec(ctx, task).toPromise();
145
145
  spinner.complete(), ctx.logger.log(), handler.complete(ctx, task, result);
@@ -152,5 +152,7 @@ async function build(options) {
152
152
  }
153
153
  }
154
154
  }
155
- exports.build = build;
156
- //# sourceMappingURL=build.cjs.map
155
+ export {
156
+ build
157
+ };
158
+ //# sourceMappingURL=build.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build.js","sources":["../../src/node/resolveBuildTasks.ts","../../src/node/spinner.ts","../../src/node/build.ts"],"sourcesContent":["import path from 'node:path'\nimport type {PkgExport, PkgFormat, PkgRuntime} from './core/config/types'\nimport type {BuildContext} from './core/contexts/buildContext'\nimport {getTargetPaths} from './tasks/dts/getTargetPaths'\nimport type {DtsTask} from './tasks/dts/types'\nimport type {BuildTask, RolldownDtsTask, RollupTask, RollupTaskEntry} from './tasks/types'\n\n/** @internal */\nexport function resolveBuildTasks(ctx: BuildContext): BuildTask[] {\n const {config, pkg, target} = ctx\n\n const bundles = config?.bundles || []\n\n const tasks: BuildTask[] = []\n\n const exports = Object.entries(ctx.exports || {}).map(\n ([_path, exp]) => ({_path, ...exp}) as PkgExport & {_path: string},\n )\n\n const dtsTask: DtsTask = {\n type: 'build:dts',\n entries: [],\n }\n\n const rolldownDtsTask: Record<string, RolldownDtsTask> = {}\n const rollupTasks: Record<string, RollupTask> = {}\n\n function addRollupTaskEntry(format: PkgFormat, runtime: PkgRuntime, entry: RollupTaskEntry) {\n const buildId = `${format}:${runtime}`\n\n if (ctx.dts === 'rolldown') {\n if (rolldownDtsTask[buildId]) {\n rolldownDtsTask[buildId].entries.push(entry)\n } else {\n rolldownDtsTask[buildId] = {\n type: 'rolldown:dts',\n buildId,\n entries: [entry],\n runtime,\n format,\n target: target[runtime],\n }\n }\n }\n\n if (!ctx.emitDeclarationOnly) {\n if (rollupTasks[buildId]) {\n rollupTasks[buildId].entries.push(entry)\n } else {\n rollupTasks[buildId] = {\n type: 'build:js',\n buildId,\n entries: [entry],\n runtime,\n format,\n target: target[runtime],\n }\n }\n }\n }\n\n if (ctx.dts === 'api-extractor') {\n // Parse `dts` tasks\n for (const exp of exports) {\n const importId = path.join(pkg.name, exp._path)\n\n if (exp.source?.endsWith('.ts')) {\n dtsTask.entries.push({\n importId,\n exportPath: exp._path,\n sourcePath: exp.source,\n targetPaths: getTargetPaths(pkg.type, exp),\n })\n }\n\n if (exp.browser?.source?.endsWith('.ts')) {\n dtsTask.entries.push({\n importId,\n exportPath: exp._path,\n sourcePath: exp.browser.source,\n targetPaths: getTargetPaths(pkg.type, exp.browser),\n })\n }\n\n if (exp.node?.source?.endsWith('.ts')) {\n dtsTask.entries.push({\n importId,\n exportPath: exp._path,\n sourcePath: exp.node.source,\n targetPaths: getTargetPaths(pkg.type, exp.node),\n })\n }\n }\n\n // Handle dts tasks for bundles\n for (const bundle of bundles) {\n if (bundle.source?.endsWith('.ts')) {\n // importId needs to be how the bundle is used, like `@sanity/pkg-utils/dist/cli`\n // exportPath needs to be the path to the bundle, like `./dist/cli`\n // targetPaths is then: [./dist/cli.d.ts, ./dist/cli.d.cts]\n const exportPath = (bundle.import || bundle.require)!.replace(/\\.[mc]?js$/, '')\n const importId = path.join(pkg.name, exportPath)\n\n dtsTask.entries.push({\n importId,\n exportPath,\n sourcePath: bundle.source,\n targetPaths: getTargetPaths(pkg.type, bundle),\n })\n }\n }\n\n // Add dts task\n if (dtsTask.entries.length) {\n tasks.push(dtsTask)\n }\n }\n\n // Parse rollup:commonjs:* tasks\n for (const exp of exports) {\n const output = exp.require\n\n if (!output) continue\n\n addRollupTaskEntry('commonjs', ctx.runtime, {\n path: exp._path,\n source: exp.source,\n output,\n })\n }\n\n // Parse rollup:esm:* tasks\n for (const exp of exports) {\n const output = exp.import\n\n if (!output) continue\n\n addRollupTaskEntry('esm', ctx.runtime, {\n path: exp._path,\n source: exp.source,\n output,\n })\n }\n\n // Parse rollup:commonjs:browser tasks\n for (const exp of exports) {\n const output = exp.browser?.require\n\n if (!output) continue\n\n addRollupTaskEntry('commonjs', 'browser', {\n path: exp._path,\n source: exp.browser?.source || exp.source,\n output,\n })\n }\n\n // Parse rollup:esm:browser tasks\n for (const exp of exports) {\n const output = exp.browser?.import\n\n if (!output) continue\n\n addRollupTaskEntry('esm', 'browser', {\n path: exp._path,\n source: exp.browser?.source || exp.source,\n output,\n })\n }\n\n for (const bundle of bundles) {\n const idx = bundles.indexOf(bundle)\n\n if (bundle.require) {\n addRollupTaskEntry('commonjs', bundle.runtime || ctx.runtime, {\n path: `__$$bundle_cjs_${idx}$$__`,\n source: bundle.source,\n output: bundle.require,\n })\n }\n\n if (bundle.import) {\n addRollupTaskEntry('esm', bundle.runtime || ctx.runtime, {\n path: `__$$bundle_esm_${idx}$$__`,\n source: bundle.source,\n output: bundle.import,\n })\n }\n }\n\n // Perform rolldown dts tasks first, as they have special logic for removing non .d.ts chunks\n tasks.push(...Object.values(rolldownDtsTask))\n // Then run api-extractor tsdoc release tag checking (if rolldown is used for dts bundling, otherwise api-extractor performs both in the build:dts task)\n // @TODO\n // Then run rollup tasks\n tasks.push(...Object.values(rollupTasks))\n\n return tasks\n}\n","// oxlint-disable no-console\nimport chalk from 'chalk'\n\nexport function createSpinner(msg: string): {complete: () => void; error: () => void} {\n const startTime = Date.now()\n\n console.log(msg)\n\n return {\n complete: () => {\n console.log(`${chalk.green('[success]')} ${chalk.gray(`${Date.now() - startTime}ms`)}`)\n },\n error: () => {\n console.log(`${chalk.red('[error]')} ${chalk.gray(`${Date.now() - startTime}ms`)}`)\n },\n }\n}\n","import path from 'node:path'\nimport {rimraf} from 'rimraf'\nimport {loadConfig} from './core/config/loadConfig'\nimport {loadPkgWithReporting} from './core/pkg/loadPkgWithReporting'\nimport {createLogger} from './logger'\nimport {resolveBuildContext} from './resolveBuildContext'\nimport {resolveBuildTasks} from './resolveBuildTasks'\nimport {createSpinner} from './spinner'\nimport {buildTaskHandlers} from './tasks'\nimport {type BuildTask, type TaskHandler} from './tasks/types'\n\n/**\n * Build the distribution files of a npm package.\n *\n * @example\n * ```ts\n * import {build} from '@sanity/pkg-utils'\n *\n * build({\n * cwd: process.cwd(),\n * tsconfig: 'tsconfig.dist.json,\n * }).then(() => {\n * console.log('successfully built')\n * }).catch((err) => {\n * console.log(`build error: ${err.message}`)\n * })\n * ```\n *\n * @public\n */\nexport async function build(options: {\n cwd: string\n emitDeclarationOnly?: boolean\n strict?: boolean\n tsconfig?: string\n clean?: boolean\n}): Promise<void> {\n const {\n cwd,\n emitDeclarationOnly,\n strict = false,\n tsconfig: tsconfigOption,\n clean = false,\n } = options\n const logger = createLogger()\n\n const config = await loadConfig({cwd})\n\n const pkg = await loadPkgWithReporting({cwd, logger, strict})\n\n const tsconfig = tsconfigOption || config?.tsconfig || 'tsconfig.json'\n\n const ctx = await resolveBuildContext({\n config,\n cwd,\n emitDeclarationOnly,\n logger,\n pkg,\n strict,\n tsconfig,\n })\n\n if (clean) {\n logger.log(\n `Deleting the \\`dist\\` folder: './${path.relative(cwd, ctx.distPath)}' before building...`,\n )\n await rimraf(ctx.distPath)\n }\n\n const buildTasks = resolveBuildTasks(ctx)\n\n for (const task of buildTasks) {\n const handler = buildTaskHandlers[task.type] as TaskHandler<BuildTask>\n const taskName = handler.name(ctx, task)\n\n const spinner = createSpinner(taskName)\n\n try {\n const result = await handler.exec(ctx, task).toPromise()\n\n spinner.complete()\n ctx.logger.log()\n\n handler.complete(ctx, task, result)\n } catch (err) {\n spinner.error()\n\n if (err instanceof Error) {\n const RE_CWD = new RegExp(`${cwd}`, 'g')\n\n ctx.logger.error(err.message.replace(RE_CWD, '.'))\n ctx.logger.log()\n }\n\n handler.error(ctx, task, err)\n\n process.exit(1)\n }\n }\n}\n"],"names":[],"mappings":";;;;;;AAQO,SAAS,kBAAkB,KAAgC;AAC1D,QAAA,EAAC,QAAQ,KAAK,OAAA,IAAU,KAExB,UAAU,QAAQ,WAAW,CAAA,GAE7B,QAAqB,IAErB,UAAU,OAAO,QAAQ,IAAI,WAAW,CAAE,CAAA,EAAE;AAAA,IAChD,CAAC,CAAC,OAAO,GAAG,OAAO,EAAC,OAAO,GAAG,IAAG;AAAA,KAG7B,UAAmB;AAAA,IACvB,MAAM;AAAA,IACN,SAAS,CAAA;AAAA,EAAC,GAGN,kBAAmD,IACnD,cAA0C,CAAC;AAExC,WAAA,mBAAmB,QAAmB,SAAqB,OAAwB;AAC1F,UAAM,UAAU,GAAG,MAAM,IAAI,OAAO;AAEhC,QAAI,QAAQ,eACV,gBAAgB,OAAO,IACzB,gBAAgB,OAAO,EAAE,QAAQ,KAAK,KAAK,IAE3C,gBAAgB,OAAO,IAAI;AAAA,MACzB,MAAM;AAAA,MACN;AAAA,MACA,SAAS,CAAC,KAAK;AAAA,MACf;AAAA,MACA;AAAA,MACA,QAAQ,OAAO,OAAO;AAAA,IAKvB,IAAA,IAAI,wBACH,YAAY,OAAO,IACrB,YAAY,OAAO,EAAE,QAAQ,KAAK,KAAK,IAEvC,YAAY,OAAO,IAAI;AAAA,MACrB,MAAM;AAAA,MACN;AAAA,MACA,SAAS,CAAC,KAAK;AAAA,MACf;A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OAAO,GAAG,GAAG,IAAI,GAAG;AAEnC,YAAA,OAAO,MAAM,IAAI,QAAQ,QAAQ,QAAQ,GAAG,CAAC,GACjD,IAAI,OAAO,IAAI;AAAA,MAAA;AAGjB,cAAQ,MAAM,KAAK,MAAM,GAAG,GAE5B,QAAQ,KAAK,CAAC;AAAA,IAAA;AAAA,EAChB;AAEJ;"}
@@ -1,8 +1,8 @@
1
- "use strict";
2
- var build = require("./build.cjs"), handleError = require("./handleError.cjs");
1
+ import { build } from "./build.js";
2
+ import { handleError } from "./handleError.js";
3
3
  async function buildAction(options) {
4
4
  try {
5
- await build.build({
5
+ await build({
6
6
  cwd: process.cwd(),
7
7
  emitDeclarationOnly: options.emitDeclarationOnly,
8
8
  strict: options.strict,
@@ -10,8 +10,10 @@ async function buildAction(options) {
10
10
  clean: options.clean
11
11
  });
12
12
  } catch (err) {
13
- handleError.handleError(err);
13
+ handleError(err);
14
14
  }
15
15
  }
16
- exports.buildAction = buildAction;
17
- //# sourceMappingURL=buildAction.cjs.map
16
+ export {
17
+ buildAction
18
+ };
19
+ //# sourceMappingURL=buildAction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildAction.js","sources":["../../src/cli/buildAction.ts"],"sourcesContent":["import {build} from '../node/build'\nimport {handleError} from './handleError'\n\nexport async function buildAction(options: {\n emitDeclarationOnly?: boolean\n strict?: boolean\n tsconfig?: string\n clean?: boolean\n}): Promise<void> {\n try {\n await build({\n cwd: process.cwd(),\n emitDeclarationOnly: options.emitDeclarationOnly,\n strict: options.strict,\n tsconfig: options.tsconfig,\n clean: options.clean,\n })\n } catch (err) {\n handleError(err)\n }\n}\n"],"names":[],"mappings":";;AAGA,eAAsB,YAAY,SAKhB;AACZ,MAAA;AACF,UAAM,MAAM;AAAA,MACV,KAAK,QAAQ,IAAI;AAAA,MACjB,qBAAqB,QAAQ;AAAA,MAC7B,QAAQ,QAAQ;AAAA,MAChB,UAAU,QAAQ;AAAA,MAClB,OAAO,QAAQ;AAAA,IAAA,CAChB;AAAA,WACM,KAAK;AACZ,gBAAY,GAAG;AAAA,EAAA;AAEnB;"}
@@ -1,31 +1,33 @@
1
- "use strict";
2
- var path = require("node:path"), esbuild = require("esbuild"), consoleSpy = require("./consoleSpy.cjs"), isRecord = require("./isRecord.cjs"), chalk = require("chalk"), treeify = require("treeify"), node_fs = require("node:fs"), prettyBytes = require("pretty-bytes");
3
- function _interopDefaultCompat(e) {
4
- return e && typeof e == "object" && "default" in e ? e : { default: e };
5
- }
6
- var path__default = /* @__PURE__ */ _interopDefaultCompat(path), esbuild__default = /* @__PURE__ */ _interopDefaultCompat(esbuild), chalk__default = /* @__PURE__ */ _interopDefaultCompat(chalk), treeify__default = /* @__PURE__ */ _interopDefaultCompat(treeify), prettyBytes__default = /* @__PURE__ */ _interopDefaultCompat(prettyBytes);
1
+ import path from "node:path";
2
+ import esbuild from "esbuild";
3
+ import { loadConfig, loadPkgWithReporting, resolveBuildContext, createConsoleSpy } from "./consoleSpy.js";
4
+ import { fileExists, createLogger } from "./isRecord.js";
5
+ import chalk from "chalk";
6
+ import treeify from "treeify";
7
+ import { statSync } from "node:fs";
8
+ import prettyBytes from "pretty-bytes";
7
9
  function getFilesize(file) {
8
- const stats = node_fs.statSync(file);
9
- return prettyBytes__default.default(stats.size);
10
+ const stats = statSync(file);
11
+ return prettyBytes(stats.size);
10
12
  }
11
13
  function getFileInfo(cwd, filePath) {
12
- const p = path__default.default.resolve(cwd, filePath), exists = isRecord.fileExists(p), size = exists ? getFilesize(p) : void 0;
14
+ const p = path.resolve(cwd, filePath), exists = fileExists(p), size = exists ? getFilesize(p) : void 0;
13
15
  return { exists, size };
14
16
  }
15
17
  function printPackageTree(ctx) {
16
- const { cwd, exports: exports2, logger, pkg } = ctx;
17
- if (!exports2) return;
18
- logger.log(`${chalk__default.default.blue(pkg.name)}@${chalk__default.default.green(pkg.version)}`);
18
+ const { cwd, exports, logger, pkg } = ctx;
19
+ if (!exports) return;
20
+ logger.log(`${chalk.blue(pkg.name)}@${chalk.green(pkg.version)}`);
19
21
  const tree = {};
20
- pkg.type && (tree.type = chalk__default.default.yellow(pkg.type)), pkg.bin && (tree.bin = Object.fromEntries(
21
- Object.entries(pkg.bin).map(([name, file]) => [chalk__default.default.cyan(name), fileInfo(file)])
22
+ pkg.type && (tree.type = chalk.yellow(pkg.type)), pkg.bin && (tree.bin = Object.fromEntries(
23
+ Object.entries(pkg.bin).map(([name, file]) => [chalk.cyan(name), fileInfo(file)])
22
24
  ));
23
25
  function fileInfo(file) {
24
26
  const info = getFileInfo(cwd, file);
25
- return info.size ? `${chalk__default.default.yellow(file)} ${chalk__default.default.gray(info.size)}` : `${chalk__default.default.gray(file)} ${chalk__default.default.red("does not exist")}`;
27
+ return info.size ? `${chalk.yellow(file)} ${chalk.gray(info.size)}` : `${chalk.gray(file)} ${chalk.red("does not exist")}`;
26
28
  }
27
29
  tree.exports = Object.fromEntries(
28
- Object.entries(exports2).filter(([, entry]) => entry._exported).map(([exportPath, entry]) => {
30
+ Object.entries(exports).filter(([, entry]) => entry._exported).map(([exportPath, entry]) => {
29
31
  const exp = {
30
32
  source: fileInfo(entry.source),
31
33
  browser: void 0,
@@ -34,17 +36,17 @@ function printPackageTree(ctx) {
34
36
  import: void 0,
35
37
  default: fileInfo(entry.default)
36
38
  };
37
- return entry.browser ? (exp.browser = { source: fileInfo(entry.browser.source) }, entry.browser.import && (exp.browser.import = fileInfo(entry.browser.import)), entry.browser.require && (exp.browser.require = fileInfo(entry.browser.require))) : delete exp.browser, entry.require ? exp.require = fileInfo(entry.require) : delete exp.require, entry.node ? (exp.node = {}, entry.node.source && (exp.node.source = fileInfo(entry.node.source)), entry.node.import && (exp.node.import = fileInfo(entry.node.import)), entry.node.require && (exp.node.require = fileInfo(entry.node.require))) : delete exp.node, entry.import ? exp.import = fileInfo(entry.import) : delete exp.import, [chalk__default.default.cyan(path__default.default.join(pkg.name, exportPath)), exp];
39
+ return entry.browser ? (exp.browser = { source: fileInfo(entry.browser.source) }, entry.browser.import && (exp.browser.import = fileInfo(entry.browser.import)), entry.browser.require && (exp.browser.require = fileInfo(entry.browser.require))) : delete exp.browser, entry.require ? exp.require = fileInfo(entry.require) : delete exp.require, entry.node ? (exp.node = {}, entry.node.source && (exp.node.source = fileInfo(entry.node.source)), entry.node.import && (exp.node.import = fileInfo(entry.node.import)), entry.node.require && (exp.node.require = fileInfo(entry.node.require))) : delete exp.node, entry.import ? exp.import = fileInfo(entry.import) : delete exp.import, [chalk.cyan(path.join(pkg.name, exportPath)), exp];
38
40
  })
39
- ), logger.log(treeify__default.default.asTree(tree, !0, !0));
41
+ ), logger.log(treeify.asTree(tree, !0, !0));
40
42
  }
41
43
  async function check(options) {
42
- const { cwd, strict = !1, tsconfig: tsconfigOption } = options, logger = isRecord.createLogger(), config = await consoleSpy.loadConfig({ cwd }), pkg = await consoleSpy.loadPkgWithReporting({ cwd, logger, strict }), tsconfig = tsconfigOption || config?.tsconfig || "tsconfig.json", ctx = await consoleSpy.resolveBuildContext({ config, cwd, logger, pkg, strict, tsconfig });
44
+ const { cwd, strict = !1, tsconfig: tsconfigOption } = options, logger = createLogger(), config = await loadConfig({ cwd }), pkg = await loadPkgWithReporting({ cwd, logger, strict }), tsconfig = tsconfigOption || config?.tsconfig || "tsconfig.json", ctx = await resolveBuildContext({ config, cwd, logger, pkg, strict, tsconfig });
43
45
  if (printPackageTree(ctx), strict) {
44
46
  const missingFiles = [];
45
47
  for (const [, exp] of Object.entries(ctx.exports || {}))
46
- exp.source && !isRecord.fileExists(path__default.default.resolve(cwd, exp.source)) && missingFiles.push(exp.source), exp.require && !isRecord.fileExists(path__default.default.resolve(cwd, exp.require)) && missingFiles.push(exp.require), exp.import && !isRecord.fileExists(path__default.default.resolve(cwd, exp.import)) && missingFiles.push(exp.import);
47
- ctx.pkg.types && !isRecord.fileExists(path__default.default.resolve(cwd, ctx.pkg.types)) && missingFiles.push(ctx.pkg.types), missingFiles.length && (logger.error(`missing files: ${missingFiles.join(", ")}`), process.exit(1));
48
+ exp.source && !fileExists(path.resolve(cwd, exp.source)) && missingFiles.push(exp.source), exp.require && !fileExists(path.resolve(cwd, exp.require)) && missingFiles.push(exp.require), exp.import && !fileExists(path.resolve(cwd, exp.import)) && missingFiles.push(exp.import);
49
+ ctx.pkg.types && !fileExists(path.resolve(cwd, ctx.pkg.types)) && missingFiles.push(ctx.pkg.types), missingFiles.length && (logger.error(`missing files: ${missingFiles.join(", ")}`), process.exit(1));
48
50
  const exportPaths = {
49
51
  require: [],
50
52
  import: []
@@ -54,15 +56,15 @@ async function check(options) {
54
56
  const external = [
55
57
  ...Object.keys(pkg.dependencies || {}),
56
58
  ...Object.keys(pkg.devDependencies || {})
57
- ], consoleSpy$1 = consoleSpy.createConsoleSpy();
58
- exportPaths.import.length && checkExports(exportPaths.import, { cwd, external, format: "esm", logger }), exportPaths.require.length && checkExports(exportPaths.require, { cwd, external, format: "cjs", logger }), consoleSpy$1.restore();
59
+ ], consoleSpy = createConsoleSpy();
60
+ exportPaths.import.length && checkExports(exportPaths.import, { cwd, external, format: "esm", logger }), exportPaths.require.length && checkExports(exportPaths.require, { cwd, external, format: "cjs", logger }), consoleSpy.restore();
59
61
  }
60
62
  }
61
63
  async function checkExports(exportPaths, options) {
62
64
  const { cwd, external, format, logger } = options, code = exportPaths.map((id) => format ? `import('${id}');` : `require('${id}');`).join(`
63
65
  `);
64
66
  try {
65
- const esbuildResult = await esbuild__default.default.build({
67
+ const esbuildResult = await esbuild.build({
66
68
  bundle: !0,
67
69
  external,
68
70
  format,
@@ -112,5 +114,7 @@ function isEsbuildFailure(err) {
112
114
  function isEsbuildMessage(msg) {
113
115
  return typeof msg == "object" && msg !== null && "text" in msg && typeof msg.text == "string" && "location" in msg && (msg.location === null || typeof msg.location == "object");
114
116
  }
115
- exports.check = check;
116
- //# sourceMappingURL=check.cjs.map
117
+ export {
118
+ check
119
+ };
120
+ //# sourceMappingURL=check.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check.js","sources":["../../src/node/getFilesize.ts","../../src/node/printPackageTree.ts","../../src/node/check.ts"],"sourcesContent":["import {statSync} from 'node:fs'\nimport prettyBytes from 'pretty-bytes'\n\nexport function getFilesize(file: string): string {\n const stats = statSync(file)\n\n return prettyBytes(stats.size)\n}\n","import path from 'node:path'\nimport chalk from 'chalk'\nimport treeify from 'treeify'\nimport type {PkgExport} from './core/config/types'\nimport type {BuildContext} from './core/contexts/buildContext'\nimport {fileExists} from './fileExists'\nimport {getFilesize} from './getFilesize'\n\nfunction getFileInfo(cwd: string, filePath: string) {\n const p = path.resolve(cwd, filePath)\n const exists = fileExists(p)\n const size = exists ? getFilesize(p) : undefined\n\n return {exists, size}\n}\n\nexport function printPackageTree(ctx: BuildContext): void {\n const {cwd, exports, logger, pkg} = ctx\n\n if (!exports) return\n\n logger.log(`${chalk.blue(pkg.name)}@${chalk.green(pkg.version)}`)\n\n const tree: Record<string, unknown> = {}\n\n if (pkg.type) {\n tree['type'] = chalk.yellow(pkg.type)\n }\n\n if (pkg.bin) {\n tree['bin'] = Object.fromEntries(\n Object.entries(pkg.bin).map(([name, file]) => [chalk.cyan(name), fileInfo(file)]),\n )\n }\n\n function fileInfo(file: string) {\n const info = getFileInfo(cwd, file)\n\n if (!info.size) {\n return `${chalk.gray(file)} ${chalk.red('does not exist')}`\n }\n\n return `${chalk.yellow(file)} ${chalk.gray(info.size)}`\n }\n\n tree['exports'] = Object.fromEntries(\n Object.entries(exports)\n .filter(([, entry]) => entry._exported)\n .map(([exportPath, entry]) => {\n const exp: Omit<PkgExport, '_exported'> = {\n source: fileInfo(entry.source),\n browser: undefined,\n require: undefined,\n node: undefined,\n import: undefined,\n default: fileInfo(entry.default),\n }\n\n if (entry.browser) {\n exp.browser = {source: fileInfo(entry.browser.source)}\n\n if (entry.browser.import) exp.browser.import = fileInfo(entry.browser.import)\n if (entry.browser.require) exp.browser.require = fileInfo(entry.browser.require)\n } else {\n delete exp.browser\n }\n\n if (entry.require) {\n exp.require = fileInfo(entry.require)\n } else {\n delete exp.require\n }\n\n if (entry.node) {\n exp.node = {}\n\n if (entry.node.source) exp.node.source = fileInfo(entry.node.source)\n if (entry.node.import) exp.node.import = fileInfo(entry.node.import)\n if (entry.node.require) exp.node.require = fileInfo(entry.node.require)\n } else {\n delete exp.node\n }\n\n if (entry.import) {\n exp.import = fileInfo(entry.import)\n } else {\n delete exp.import\n }\n\n return [chalk.cyan(path.join(pkg.name, exportPath)), exp]\n }),\n )\n\n logger.log(treeify.asTree(tree as Record<string, any>, true, true))\n}\n","import path from 'node:path'\nimport esbuild, {type BuildFailure, type Message} from 'esbuild'\nimport {createConsoleSpy} from './consoleSpy'\nimport {loadConfig} from './core/config/loadConfig'\nimport {loadPkgWithReporting} from './core/pkg/loadPkgWithReporting'\nimport {fileExists} from './fileExists'\nimport {createLogger, type Logger} from './logger'\nimport {printPackageTree} from './printPackageTree'\nimport {resolveBuildContext} from './resolveBuildContext'\n\n/** @public */\nexport async function check(options: {\n cwd: string\n strict?: boolean\n tsconfig?: string\n}): Promise<void> {\n const {cwd, strict = false, tsconfig: tsconfigOption} = options\n const logger = createLogger()\n\n const config = await loadConfig({cwd})\n const pkg = await loadPkgWithReporting({cwd, logger, strict})\n const tsconfig = tsconfigOption || config?.tsconfig || 'tsconfig.json'\n const ctx = await resolveBuildContext({config, cwd, logger, pkg, strict, tsconfig})\n\n printPackageTree(ctx)\n\n if (strict) {\n const missingFiles: string[] = []\n\n // Check if there are missing files\n for (const [, exp] of Object.entries(ctx.exports || {})) {\n if (exp.source && !fileExists(path.resolve(cwd, exp.source))) {\n missingFiles.push(exp.source)\n }\n\n if (exp.require && !fileExists(path.resolve(cwd, exp.require))) {\n missingFiles.push(exp.require)\n }\n\n if (exp.import && !fileExists(path.resolve(cwd, exp.import))) {\n missingFiles.push(exp.import)\n }\n }\n\n if (ctx.pkg.types && !fileExists(path.resolve(cwd, ctx.pkg.types))) {\n missingFiles.push(ctx.pkg.types)\n }\n\n if (missingFiles.length) {\n logger.error(`missing files: ${missingFiles.join(', ')}`)\n process.exit(1)\n }\n\n // Check if the files are resolved\n const exportPaths: {require: string[]; import: string[]} = {\n require: [],\n import: [],\n }\n\n for (const exp of Object.values(ctx.exports || {})) {\n if (!exp._exported) continue\n if (exp.require) exportPaths.require.push(exp.require)\n if (exp.import) exportPaths.import.push(exp.import)\n }\n\n const external = [\n ...Object.keys(pkg.dependencies || {}),\n ...Object.keys(pkg.devDependencies || {}),\n ]\n\n const consoleSpy = createConsoleSpy()\n\n if (exportPaths.import.length) {\n checkExports(exportPaths.import, {cwd, external, format: 'esm', logger})\n }\n\n if (exportPaths.require.length) {\n checkExports(exportPaths.require, {cwd, external, format: 'cjs', logger})\n }\n\n consoleSpy.restore()\n }\n}\n\nasync function checkExports(\n exportPaths: string[],\n options: {cwd: string; external: string[]; format: 'esm' | 'cjs'; logger: Logger},\n) {\n const {cwd, external, format, logger} = options\n\n const code = exportPaths\n .map((id) => (format ? `import('${id}');` : `require('${id}');`))\n .join('\\n')\n\n try {\n const esbuildResult = await esbuild.build({\n bundle: true,\n external,\n format,\n logLevel: 'silent',\n // otherwise output maps to stdout as we're using stdin\n outfile: '/dev/null',\n platform: 'node',\n stdin: {\n contents: code,\n loader: 'js',\n resolveDir: cwd,\n },\n })\n\n if (esbuildResult.errors.length > 0) {\n for (const msg of esbuildResult.errors) {\n printEsbuildMessage(logger.warn, msg)\n\n logger.log()\n }\n\n process.exit(1)\n }\n\n const esbuildWarnings = esbuildResult.warnings.filter((msg) => {\n !(msg.detail || msg.text).includes(`does not affect esbuild's own target setting`)\n })\n\n for (const msg of esbuildWarnings) {\n printEsbuildMessage(logger.warn, msg)\n\n logger.log()\n }\n } catch (err) {\n if (isEsbuildFailure(err)) {\n const {errors} = err\n\n for (const msg of errors) {\n printEsbuildMessage(logger.error, msg)\n\n logger.log()\n }\n } else if (err instanceof Error) {\n logger.error(err.stack || err.message)\n\n logger.log()\n } else {\n logger.error(`${err}`)\n\n logger.log()\n }\n\n process.exit(1)\n }\n}\n\nfunction printEsbuildMessage(log: (...args: unknown[]) => void, msg: esbuild.Message) {\n if (msg.location) {\n log(\n [\n `${msg.detail || msg.text}\\n`,\n `${msg.location.line} | ${msg.location.lineText}\\n`,\n `in ./${msg.location.file}:${msg.location.line}:${msg.location.column}`,\n ].join(''),\n )\n } else {\n log(msg.detail || msg.text)\n }\n}\n\nfunction isEsbuildFailure(err: unknown): err is BuildFailure {\n return (\n err instanceof Error &&\n 'errors' in err &&\n Array.isArray(err.errors) &&\n err.errors.every(isEsbuildMessage) &&\n 'warnings' in err &&\n Array.isArray(err.warnings) &&\n err.warnings.every(isEsbuildMessage)\n )\n}\n\nfunction isEsbuildMessage(msg: unknown): msg is Message {\n return (\n typeof msg === 'object' &&\n msg !== null &&\n 'text' in msg &&\n typeof msg.text === 'string' &&\n 'location' in msg &&\n (msg.location === null || typeof msg.location === 'object')\n )\n}\n"],"names":[],"mappings":";;;;;;;;AAGO,SAAS,YAAY,MAAsB;AAC1C,QAAA,QAAQ,SAAS,IAAI;AAEpB,SAAA,YAAY,MAAM,IAAI;AAC/B;ACCA,SAAS,YAAY,KAAa,UAAkB;AAClD,QAAM,IAAI,KAAK,QAAQ,KAAK,QAAQ,GAC9B,SAAS,WAAW,CAAC,GACrB,OAAO,SAAS,YAAY,CAAC,IAAI;AAEhC,SAAA,EAAC,QAAQ,KAAI;AACtB;AAEO,SAAS,iBAAiB,KAAyB;AACxD,QAAM,EAAC,KAAK,SAAS,QAAQ,IAAO,IAAA;AAEpC,MAAI,CAAC,QAAS;AAEd,SAAO,IAAI,GAAG,MAAM,KAAK,IAAI,IAAI,CAAC,IAAI,MAAM,MAAM,IAAI,OAAO,CAAC,EAAE;AAEhE,QAAM,OAAgC,CAAC;AAEnC,MAAI,SACN,KAAK,OAAU,MAAM,OAAO,IAAI,IAAI,IAGlC,IAAI,QACN,KAAK,MAAS,OAAO;AAAA,IACnB,OAAO,QAAQ,IAAI,GAAG,EAAE,IAAI,CAAC,CAAC,MAA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,OAAO;AAChB,0BAAoB,OAAO,MAAM,GAAG,GAEpC,OAAO,IAAI;AAAA,WAEN,KAAK;AACR,QAAA,iBAAiB,GAAG,GAAG;AACnB,YAAA,EAAC,WAAU;AAEjB,iBAAW,OAAO;AAChB,4BAAoB,OAAO,OAAO,GAAG,GAErC,OAAO,IAAI;AAAA,IAAA,MAEJ,gBAAe,SACxB,OAAO,MAAM,IAAI,SAAS,IAAI,OAAO,GAErC,OAAO,UAEP,OAAO,MAAM,GAAG,GAAG,EAAE,GAErB,OAAO;AAGT,YAAQ,KAAK,CAAC;AAAA,EAAA;AAElB;AAEA,SAAS,oBAAoB,KAAmC,KAAsB;AAChF,MAAI,WACN;AAAA,IACE;AAAA,MACE,GAAG,IAAI,UAAU,IAAI,IAAI;AAAA;AAAA,MACzB,GAAG,IAAI,SAAS,IAAI,MAAM,IAAI,SAAS,QAAQ;AAAA;AAAA,MAC/C,QAAQ,IAAI,SAAS,IAAI,IAAI,IAAI,SAAS,IAAI,IAAI,IAAI,SAAS,MAAM;AAAA,IACvE,EAAE,KAAK,EAAE;AAAA,EAGX,IAAA,IAAI,IAAI,UAAU,IAAI,IAAI;AAE9B;AAEA,SAAS,iBAAiB,KAAmC;AAEzD,SAAA,eAAe,SACf,YAAY,OACZ,MAAM,QAAQ,IAAI,MAAM,KACxB,IAAI,OAAO,MAAM,gBAAgB,KACjC,cAAc,OACd,MAAM,QAAQ,IAAI,QAAQ,KAC1B,IAAI,SAAS,MAAM,gBAAgB;AAEvC;AAEA,SAAS,iBAAiB,KAA8B;AACtD,SACE,OAAO,OAAQ,YACf,QAAQ,QACR,UAAU,OACV,OAAO,IAAI,QAAS,YACpB,cAAc,QACb,IAAI,aAAa,QAAQ,OAAO,IAAI,YAAa;AAEtD;"}
@@ -0,0 +1,17 @@
1
+ import { check } from "./check.js";
2
+ import { handleError } from "./handleError.js";
3
+ async function checkAction(options) {
4
+ try {
5
+ await check({
6
+ cwd: process.cwd(),
7
+ strict: options.strict,
8
+ tsconfig: options.tsconfig
9
+ });
10
+ } catch (err) {
11
+ handleError(err);
12
+ }
13
+ }
14
+ export {
15
+ checkAction
16
+ };
17
+ //# sourceMappingURL=checkAction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkAction.js","sources":["../../src/cli/checkAction.ts"],"sourcesContent":["import {check} from '../node/check'\nimport {handleError} from './handleError'\n\nexport async function checkAction(options: {strict?: boolean; tsconfig?: string}): Promise<void> {\n try {\n await check({\n cwd: process.cwd(),\n strict: options.strict,\n tsconfig: options.tsconfig,\n })\n } catch (err) {\n handleError(err)\n }\n}\n"],"names":[],"mappings":";;AAGA,eAAsB,YAAY,SAA+D;AAC3F,MAAA;AACF,UAAM,MAAM;AAAA,MACV,KAAK,QAAQ,IAAI;AAAA,MACjB,QAAQ,QAAQ;AAAA,MAChB,UAAU,QAAQ;AAAA,IAAA,CACnB;AAAA,WACM,KAAK;AACZ,gBAAY,GAAG;AAAA,EAAA;AAEnB;"}