@sanity/pkg-utils 1.8.3 → 1.10.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 (32) hide show
  1. package/dist/{__resolveBuildContext-17992a0e.cjs → __resolveBuildContext-6eae01b8.cjs} +45 -36
  2. package/dist/__resolveBuildContext-6eae01b8.cjs.map +1 -0
  3. package/dist/{_build-3d61d85e.cjs → _build-ca3c98fa.cjs} +37 -15
  4. package/dist/_build-ca3c98fa.cjs.map +1 -0
  5. package/dist/{_buildAction-ba8138ff.cjs → _buildAction-9dfec4e0.cjs} +8 -8
  6. package/dist/{_buildAction-ba8138ff.cjs.map → _buildAction-9dfec4e0.cjs.map} +1 -1
  7. package/dist/{_check-5f3f5a84.cjs → _check-999d6370.cjs} +23 -18
  8. package/dist/_check-999d6370.cjs.map +1 -0
  9. package/dist/{_checkAction-6ae8d321.cjs → _checkAction-1e3718d5.cjs} +8 -8
  10. package/dist/{_checkAction-6ae8d321.cjs.map → _checkAction-1e3718d5.cjs.map} +1 -1
  11. package/dist/{_index-bc62cfaa.cjs → _index-af5d7ae6.cjs} +4 -4
  12. package/dist/{_index-bc62cfaa.cjs.map → _index-af5d7ae6.cjs.map} +1 -1
  13. package/dist/{_watch-925404b5.cjs → _watch-98f2f5d3.cjs} +12 -9
  14. package/dist/_watch-98f2f5d3.cjs.map +1 -0
  15. package/dist/{_watchAction-e8317c50.cjs → _watchAction-c065319c.cjs} +8 -8
  16. package/dist/{_watchAction-e8317c50.cjs.map → _watchAction-c065319c.cjs.map} +1 -1
  17. package/dist/cli.cjs +4 -4
  18. package/dist/index.cjs +7 -7
  19. package/dist/{types/src/node/index.d.ts → index.d.ts} +13 -0
  20. package/dist/index.js +98 -59
  21. package/dist/index.js.map +1 -1
  22. package/package.json +3 -3
  23. package/src/node/_core/config/_findConfigFile.ts +40 -0
  24. package/src/node/_core/config/_loadConfig.ts +5 -23
  25. package/src/node/_core/config/types.ts +13 -0
  26. package/src/node/_resolveBuildTasks.ts +50 -25
  27. package/src/node/_resolveWatchTasks.ts +22 -17
  28. package/src/node/check.ts +16 -15
  29. package/dist/__resolveBuildContext-17992a0e.cjs.map +0 -1
  30. package/dist/_build-3d61d85e.cjs.map +0 -1
  31. package/dist/_check-5f3f5a84.cjs.map +0 -1
  32. package/dist/_watch-925404b5.cjs.map +0 -1
@@ -10,7 +10,7 @@ var path = require('path');
10
10
 
11
11
  var rxjs = require('rxjs');
12
12
 
13
- var _resolveBuildContext = require('./__resolveBuildContext-17992a0e.cjs');
13
+ var _resolveBuildContext = require('./__resolveBuildContext-6eae01b8.cjs');
14
14
 
15
15
  require('fs/promises');
16
16
 
@@ -20,7 +20,7 @@ require('typescript');
20
20
 
21
21
  var fs = require('fs');
22
22
 
23
- var index = require('./_index-bc62cfaa.cjs');
23
+ var index = require('./_index-af5d7ae6.cjs');
24
24
 
25
25
  require('esbuild-register/dist/node');
26
26
 
@@ -56,6 +56,7 @@ function _resolveWatchTasks(ctx) {
56
56
  var _a, _b, _c, _d, _e;
57
57
 
58
58
  const {
59
+ config,
59
60
  cwd,
60
61
  pkg,
61
62
  target
@@ -153,13 +154,15 @@ function _resolveWatchTasks(ctx) {
153
154
 
154
155
  tasks.push(...Object.values(rollupTasks));
155
156
 
156
- for (const exp of exports) {
157
- if (exp._exported && exp._path !== ".") {
158
- const relativeTargetPath = (((_e = exp.browser) == null ? void 0 : _e.import) || exp.import || "").replace(/\.[^/.]+$/, "");
159
- const ext = index._MODULE_EXT[pkg.type].esm;
157
+ if (config == null ? void 0 : config.legacyExports) {
158
+ for (const exp of exports) {
159
+ if (exp._exported && exp._path !== ".") {
160
+ const relativeTargetPath = (((_e = exp.browser) == null ? void 0 : _e.import) || exp.import || "").replace(/\.[^/.]+$/, "");
161
+ const ext = index._MODULE_EXT[pkg.type].esm;
160
162
 
161
- if (relativeTargetPath) {
162
- fs__default["default"].writeFileSync(path__default["default"].resolve(cwd, "".concat(exp._path, ".js")), ["// AUTO-GENERATED \u2013 DO NOT EDIT", "", "export * from '".concat(relativeTargetPath).concat(pkg.type === "commonjs" ? ext : "", "'"), ""].join("\n"));
163
+ if (relativeTargetPath) {
164
+ fs__default["default"].writeFileSync(path__default["default"].resolve(cwd, "".concat(exp._path, ".js")), ["// AUTO-GENERATED \u2013 DO NOT EDIT", "", "export * from '".concat(relativeTargetPath).concat(pkg.type === "commonjs" ? ext : "", "'"), ""].join("\n"));
165
+ }
163
166
  }
164
167
  }
165
168
  }
@@ -275,4 +278,4 @@ async function watch(options) {
275
278
  }
276
279
 
277
280
  exports.watch = watch;
278
- //# sourceMappingURL=_watch-925404b5.cjs.map
281
+ //# sourceMappingURL=_watch-98f2f5d3.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_watch-98f2f5d3.cjs","sources":["../src/node/_resolveWatchTasks.ts","../src/node/_globFiles.ts","../src/node/_watchFiles.ts","../src/node/_watchConfigFiles.ts","../src/node/watch.ts"],"sourcesContent":["import fs from 'fs'\nimport path from 'path'\nimport {PkgExport, PkgFormat, PkgRuntime, _BuildContext, _MODULE_EXT} from './_core'\nimport {_WatchTask, _DtsWatchTask, _RollupWatchTask, _RollupTaskEntry} from './_tasks'\n\n/** @internal */\nexport function _resolveWatchTasks(ctx: _BuildContext): _WatchTask[] {\n const {config, cwd, pkg, target} = ctx\n const tasks: _WatchTask[] = []\n\n const exports = Object.entries(ctx.exports || {}).map(\n ([_path, exp]) => ({_path, ...exp} as PkgExport & {_path: string})\n )\n\n const dtsTask: _DtsWatchTask = {\n type: 'watch:dts',\n entries: [],\n }\n\n const rollupTasks: Record<string, _RollupWatchTask> = {}\n\n function _addRollupTaskEntry(format: PkgFormat, runtime: PkgRuntime, entry: _RollupTaskEntry) {\n const buildId = `${format}:${runtime}`\n\n if (rollupTasks[buildId]) {\n rollupTasks[buildId].entries.push(entry)\n } else {\n rollupTasks[buildId] = {\n type: 'watch:js',\n buildId,\n entries: [entry],\n runtime,\n format,\n target: target[runtime],\n }\n }\n }\n\n // Parse `dts` tasks\n for (const exp of exports) {\n const importId = path.join(pkg.name, exp._path)\n\n if (exp.types) {\n dtsTask.entries.push({\n importId,\n exportPath: exp._path,\n sourcePath: exp.source,\n targetPath: exp.types,\n })\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: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:* 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: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 if (dtsTask.entries.length) {\n tasks.push(dtsTask)\n }\n\n tasks.push(...Object.values(rollupTasks))\n\n // Write legacy exports files\n if (config?.legacyExports) {\n for (const exp of exports) {\n if (exp._exported && exp._path !== '.') {\n const relativeTargetPath = (exp.browser?.import || exp.import || '').replace(\n /\\.[^/.]+$/,\n ''\n )\n const ext = _MODULE_EXT[pkg.type].esm\n\n if (relativeTargetPath) {\n fs.writeFileSync(\n path.resolve(cwd, `${exp._path}.js`),\n [\n `// AUTO-GENERATED – DO NOT EDIT`,\n ``,\n // `export {default} from '${relativeTargetPath}'`,\n `export * from '${relativeTargetPath}${pkg.type === 'commonjs' ? ext : ''}'`,\n ``,\n ].join('\\n')\n )\n }\n }\n }\n }\n\n return tasks\n}\n","import globby from 'globby'\n\nexport function _globFiles(patterns: string[]): Promise<string[]> {\n return globby(patterns)\n}\n","import chokidar from 'chokidar'\nimport {Observable} from 'rxjs'\n\nexport interface _FileEvent {\n type: 'add' | 'addDir' | 'change' | 'unlink' | 'unlinkDir'\n file: string\n}\n\nexport function _watchFiles(patterns: string[]): Observable<_FileEvent> {\n return new Observable((observer) => {\n const watcher = chokidar.watch(patterns, {\n ignoreInitial: true,\n })\n\n function _handleFileEvent(\n type: 'add' | 'addDir' | 'change' | 'unlink' | 'unlinkDir',\n file: string\n ) {\n observer.next({type, file})\n }\n\n watcher.on('all', _handleFileEvent)\n\n return () => {\n watcher.off('all', _handleFileEvent)\n watcher.close()\n }\n })\n}\n","import path from 'path'\nimport chalk from 'chalk'\nimport {Observable} from 'rxjs'\nimport {distinctUntilChanged, scan, startWith} from 'rxjs/operators'\nimport {_globFiles} from './_globFiles'\nimport {_watchFiles} from './_watchFiles'\n\nexport async function _watchConfigFiles(options: {cwd: string}): Promise<Observable<string[]>> {\n const {cwd} = options\n\n const initialFiles = await _globFiles([\n path.resolve(cwd, 'package.json'),\n path.resolve(cwd, 'package.config.cjs'),\n path.resolve(cwd, 'package.config.js'),\n path.resolve(cwd, 'package.config.ts'),\n ])\n\n const fileEvent$ = _watchFiles([\n path.resolve(cwd, 'package.json'),\n path.resolve(cwd, 'package.config.cjs'),\n path.resolve(cwd, 'package.config.js'),\n path.resolve(cwd, 'package.config.ts'),\n ])\n\n return fileEvent$.pipe(\n scan((files, fileEvent) => {\n if (fileEvent.type === 'add') {\n return files.concat(fileEvent.file)\n }\n\n if (fileEvent.type === 'unlink') {\n return files.filter((f) => f !== fileEvent.file)\n }\n\n if (fileEvent.type === 'change') {\n /* eslint-disable no-console */\n console.log(\n '--------------------------------------------------------------------------------'\n )\n console.log(chalk.blue('info '), path.relative(cwd, fileEvent.file), 'changed')\n console.log('')\n /* eslint-enable no-console */\n\n return files.slice(0) // trigger update\n }\n\n return files\n }, initialFiles),\n startWith(initialFiles),\n distinctUntilChanged()\n )\n}\n","import path from 'path'\nimport {switchMap} from 'rxjs'\nimport {_loadConfig, _loadPkgWithReporting} from './_core'\nimport {_resolveBuildContext} from './_resolveBuildContext'\nimport {_resolveWatchTasks} from './_resolveWatchTasks'\nimport {_WatchTask, _TaskHandler, _watchTaskHandlers} from './_tasks'\nimport {_watchConfigFiles} from './_watchConfigFiles'\n\n/** @public */\nexport async function watch(options: {cwd: string; tsconfig?: string}): Promise<void> {\n const {cwd, tsconfig = 'tsconfig.json'} = options\n\n const configFiles$ = await _watchConfigFiles({cwd})\n\n const ctx$ = configFiles$.pipe(\n switchMap(async (configFiles) => {\n const _files = configFiles.map((f) => path.relative(cwd, f))\n\n const packageJsonPath = _files.find((f) => f === 'package.json')\n\n if (!packageJsonPath) {\n throw new Error('missing package.json')\n }\n\n const pkg = await _loadPkgWithReporting({cwd})\n const config = await _loadConfig({cwd})\n\n return _resolveBuildContext({config, cwd, pkg, tsconfig})\n })\n )\n\n ctx$.subscribe(async (ctx) => {\n const watchTasks = _resolveWatchTasks(ctx)\n\n for (const task of watchTasks) {\n const handler = _watchTaskHandlers[task.type] as _TaskHandler<_WatchTask, unknown>\n const result$ = handler.exec(ctx, task)\n\n result$.subscribe({\n error: (err) => {\n ctx.logger.error(err)\n ctx.logger.log()\n\n process.exit(1)\n },\n next: (result) => {\n handler.complete(ctx, task, result)\n },\n complete: () => {\n ctx.logger.success(handler.name(ctx, task))\n ctx.logger.log()\n },\n })\n }\n })\n}\n"],"names":["_resolveWatchTasks","ctx","_a","_b","_c","_d","_e","config","cwd","pkg","target","tasks","exports","Object","entries","map","_path","exp","dtsTask","type","rollupTasks","_addRollupTaskEntry","format","runtime","entry","buildId","push","importId","path","join","name","types","exportPath","sourcePath","source","targetPath","output","require","browser","import","length","values","legacyExports","_exported","relativeTargetPath","replace","ext","_MODULE_EXT","esm","fs","writeFileSync","resolve","_globFiles","patterns","globby","_watchFiles","Observable","observer","watcher","chokidar","watch","ignoreInitial","_handleFileEvent","file","next","on","off","close","_watchConfigFiles","options","initialFiles","fileEvent$","pipe","scan","files","fileEvent","concat","filter","f","console","log","chalk","blue","relative","slice","startWith","distinctUntilChanged","tsconfig","configFiles$","ctx$","switchMap","configFiles","_files","packageJsonPath","find","Error","_loadPkgWithReporting","_loadConfig","_resolveBuildContext","subscribe","watchTasks","task","handler","_watchTaskHandlers","result$","exec","error","err","logger","process","exit","result","complete","success"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGO,SAASA,kBAAT,CAA4BC,GAA5B,EAAiC;EACtC,IAAIC,EAAJ,EAAQC,EAAR,EAAYC,EAAZ,EAAgBC,EAAhB,EAAoBC,EAApB;;EACA,MAAM;IAAEC,MAAF;IAAUC,GAAV;IAAeC,GAAf;IAAoBC;EAApB,IAA+BT,GAArC;EACA,MAAMU,KAAK,GAAG,EAAd;EACA,MAAMC,OAAO,GAAGC,MAAM,CAACC,OAAP,CAAeb,GAAG,CAACW,OAAJ,IAAe,EAA9B,EAAkCG,GAAlC,CACd;IAAA,IAAC,CAACC,KAAD,EAAQC,GAAR,CAAD;IAAA;MAAqBD;IAArB,GAA+BC,GAA/B;EAAA,CADc,CAAhB;EAGA,MAAMC,OAAO,GAAG;IACdC,IAAI,EAAE,WADQ;IAEdL,OAAO,EAAE;EAFK,CAAhB;EAIA,MAAMM,WAAW,GAAG,EAApB;;EACA,SAASC,mBAAT,CAA6BC,MAA7B,EAAqCC,OAArC,EAA8CC,KAA9C,EAAqD;IACnD,MAAMC,OAAO,aAAMH,MAAN,cAAgBC,OAAhB,CAAb;;IACA,IAAIH,WAAW,CAACK,OAAD,CAAf,EAA0B;MACxBL,WAAW,CAACK,OAAD,CAAX,CAAqBX,OAArB,CAA6BY,IAA7B,CAAkCF,KAAlC;IACD,CAFD,MAEO;MACLJ,WAAW,CAACK,OAAD,CAAX,GAAuB;QACrBN,IAAI,EAAE,UADe;QAErBM,OAFqB;QAGrBX,OAAO,EAAE,CAACU,KAAD,CAHY;QAIrBD,OAJqB;QAKrBD,MALqB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
3
- var watch = require('./_watch-925404b5.cjs');
3
+ var watch = require('./_watch-98f2f5d3.cjs');
4
4
 
5
5
  require('path');
6
6
 
7
7
  require('rxjs');
8
8
 
9
- require('./__resolveBuildContext-17992a0e.cjs');
9
+ require('./__resolveBuildContext-6eae01b8.cjs');
10
10
 
11
11
  require('esbuild-register/dist/node');
12
12
 
13
- require('find-config');
14
-
15
13
  require('pkg-up');
16
14
 
15
+ require('fs/promises');
16
+
17
+ require('find-config');
18
+
17
19
  require('chalk');
18
20
 
19
21
  require('zod');
20
22
 
21
- require('fs/promises');
22
-
23
23
  require('typescript');
24
24
 
25
25
  require('browserslist');
26
26
 
27
27
  require('fs');
28
28
 
29
- require('./_index-bc62cfaa.cjs');
29
+ require('./_index-af5d7ae6.cjs');
30
30
 
31
31
  require('util');
32
32
 
@@ -76,4 +76,4 @@ async function watchAction(options) {
76
76
  }
77
77
 
78
78
  exports.watchAction = watchAction;
79
- //# sourceMappingURL=_watchAction-e8317c50.cjs.map
79
+ //# sourceMappingURL=_watchAction-c065319c.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"_watchAction-e8317c50.cjs","sources":["../src/cli/watchAction.ts"],"sourcesContent":["import {watch} from '../node/watch'\n\nexport async function watchAction(options: {tsconfig?: string}): Promise<void> {\n return await watch({\n cwd: process.cwd(),\n tsconfig: options.tsconfig,\n })\n}\n"],"names":["watchAction","options","watch","cwd","process","tsconfig"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACO,eAAeA,WAAf,CAA2BC,OAA3B,EAAoC;EACzC,OAAO,MAAMC,KAAAA,CAAAA,KAAAA,CAAM;IACjBC,GAAG,EAAEC,OAAO,CAACD,GAAR,EADY;IAEjBE,QAAQ,EAAEJ,OAAO,CAACI;EAFD,CAANH,CAAb;AAIF;;"}
1
+ {"version":3,"file":"_watchAction-c065319c.cjs","sources":["../src/cli/watchAction.ts"],"sourcesContent":["import {watch} from '../node/watch'\n\nexport async function watchAction(options: {tsconfig?: string}): Promise<void> {\n return await watch({\n cwd: process.cwd(),\n tsconfig: options.tsconfig,\n })\n}\n"],"names":["watchAction","options","watch","cwd","process","tsconfig"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACO,eAAeA,WAAf,CAA2BC,OAA3B,EAAoC;EACzC,OAAO,MAAMC,KAAAA,CAAAA,KAAAA,CAAM;IACjBC,GAAG,EAAEC,OAAO,CAACD,GAAR,EADY;IAEjBE,QAAQ,EAAEJ,OAAO,CAACI;EAFD,CAANH,CAAb;AAIF;;"}
package/dist/cli.cjs CHANGED
@@ -10,13 +10,13 @@ function _interopDefaultLegacy(e) {
10
10
 
11
11
  var cac__default = /*#__PURE__*/_interopDefaultLegacy(cac);
12
12
 
13
- var version = "1.8.3";
13
+ var version = "1.10.0";
14
14
  const cli = cac__default["default"]();
15
15
  cli.command("", "Check").option("--strict", "Strict mode").option("--tsconfig [tsconfig]", "[string] tsconfig.json").action(async options => {
16
16
  const {
17
17
  checkAction: statusAction
18
18
  } = await Promise.resolve().then(function () {
19
- return require('./_checkAction-6ae8d321.cjs');
19
+ return require('./_checkAction-1e3718d5.cjs');
20
20
  });
21
21
  return statusAction(options);
22
22
  });
@@ -24,7 +24,7 @@ cli.command("build", "Build package").option("--tsconfig [tsconfig]", "[string]
24
24
  const {
25
25
  buildAction
26
26
  } = await Promise.resolve().then(function () {
27
- return require('./_buildAction-ba8138ff.cjs');
27
+ return require('./_buildAction-9dfec4e0.cjs');
28
28
  });
29
29
  return buildAction(options);
30
30
  });
@@ -32,7 +32,7 @@ cli.command("watch", "Watch package").option("--tsconfig [tsconfig]", "[string]
32
32
  const {
33
33
  watchAction
34
34
  } = await Promise.resolve().then(function () {
35
- return require('./_watchAction-e8317c50.cjs');
35
+ return require('./_watchAction-c065319c.cjs');
36
36
  });
37
37
  return watchAction(options);
38
38
  });
package/dist/index.cjs CHANGED
@@ -4,15 +4,15 @@ Object.defineProperty(exports, '__esModule', {
4
4
  value: true
5
5
  });
6
6
 
7
- var index = require('./_index-bc62cfaa.cjs');
7
+ var index = require('./_index-af5d7ae6.cjs');
8
8
 
9
- var _resolveBuildContext = require('./__resolveBuildContext-17992a0e.cjs');
9
+ var _resolveBuildContext = require('./__resolveBuildContext-6eae01b8.cjs');
10
10
 
11
- var build = require('./_build-3d61d85e.cjs');
11
+ var build = require('./_build-ca3c98fa.cjs');
12
12
 
13
- var check = require('./_check-5f3f5a84.cjs');
13
+ var check = require('./_check-999d6370.cjs');
14
14
 
15
- var watch = require('./_watch-925404b5.cjs');
15
+ var watch = require('./_watch-98f2f5d3.cjs');
16
16
 
17
17
  require('chalk');
18
18
 
@@ -62,10 +62,10 @@ require('rollup-plugin-terser');
62
62
 
63
63
  require('esbuild-register/dist/node');
64
64
 
65
- require('find-config');
66
-
67
65
  require('pkg-up');
68
66
 
67
+ require('find-config');
68
+
69
69
  require('zod');
70
70
 
71
71
  require('browserslist');
@@ -172,8 +172,17 @@ export declare function _parseExports(options: {pkg: _PackageJSON}): (PkgExport
172
172
  _path: string
173
173
  })[]
174
174
 
175
+ /** @public */
176
+ export declare interface PkgBundle {
177
+ source: string
178
+ import?: string
179
+ require?: string
180
+ runtime?: PkgRuntime
181
+ }
182
+
175
183
  /** @public */
176
184
  export declare interface PkgConfigOptions {
185
+ bundles?: PkgBundle[]
177
186
  /**
178
187
  * Directory of distributed & bundled files.
179
188
  */
@@ -207,6 +216,10 @@ export declare interface PkgConfigOptions {
207
216
  * Defaults to `"react"`
208
217
  */
209
218
  jsxImportSource?: string
219
+ /**
220
+ * Build package with support for legacy exports (writes root <export>.js files)
221
+ */
222
+ legacyExports?: boolean
210
223
  minify?: boolean
211
224
  /**
212
225
  * Default runtime of package exports
package/dist/index.js CHANGED
@@ -12,9 +12,9 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
12
12
 
13
13
  import path$1 from 'path';
14
14
  import { register } from 'esbuild-register/dist/node';
15
- import findConfig from 'find-config';
16
15
  import pkgUp from 'pkg-up';
17
- import fs$1, { readFile } from 'fs/promises';
16
+ import fs$1, { stat, readFile } from 'fs/promises';
17
+ import findConfig from 'find-config';
18
18
  import { z, ZodError } from 'zod';
19
19
  import chalk from 'chalk';
20
20
  import ts from 'typescript';
@@ -62,6 +62,36 @@ function _isRecord(value) {
62
62
  return Boolean(value) && !Array.isArray(value) && typeof value === "object";
63
63
  }
64
64
 
65
+ const CONFIG_FILE_NAMES = ["package.config.ts", "package.config.js", "package.config.cjs", "package.config.mjs"];
66
+
67
+ async function _findConfigFile(cwd) {
68
+ const pkgJsonPath = findConfig("package.json", {
69
+ cwd
70
+ });
71
+ if (!pkgJsonPath) return void 0;
72
+ const pkgPath = path$1.dirname(pkgJsonPath);
73
+
74
+ for (const fileName of CONFIG_FILE_NAMES) {
75
+ const configPath = path$1.resolve(pkgPath, fileName);
76
+ const exists = await _fileExists$1(configPath);
77
+
78
+ if (exists) {
79
+ return configPath;
80
+ }
81
+ }
82
+
83
+ return void 0;
84
+ }
85
+
86
+ async function _fileExists$1(filePath) {
87
+ try {
88
+ await stat(filePath);
89
+ return true;
90
+ } catch (_) {
91
+ return false;
92
+ }
93
+ }
94
+
65
95
  async function _loadConfig(options) {
66
96
  const {
67
97
  cwd
@@ -71,27 +101,24 @@ async function _loadConfig(options) {
71
101
  });
72
102
  if (!pkgPath) return void 0;
73
103
  const root = path$1.dirname(pkgPath);
74
-
75
- const configFile = _findConfigFile(root);
104
+ const configFile = await _findConfigFile(root);
76
105
 
77
106
  if (!configFile) {
78
107
  return void 0;
79
108
  }
80
109
 
81
- if (!configFile.path.startsWith(cwd)) {
110
+ if (!configFile.startsWith(cwd)) {
82
111
  return void 0;
83
112
  }
84
113
 
85
114
  try {
86
115
  const {
87
116
  unregister
88
- } = configFile.transform ? register({
89
- extensions: [".js", ".ts"]
90
- }) : {
91
- unregister: () => void 0
92
- };
117
+ } = register({
118
+ extensions: [".js", ".mjs", ".ts"]
119
+ });
93
120
 
94
- const mod = require(configFile.path);
121
+ const mod = require(configFile);
95
122
 
96
123
  unregister();
97
124
  return (mod == null ? void 0 : mod.default) || mod || void 0;
@@ -100,24 +127,6 @@ async function _loadConfig(options) {
100
127
  }
101
128
  }
102
129
 
103
- function _findConfigFile(cwd) {
104
- const ts = findConfig("package.config.ts", {
105
- cwd
106
- });
107
- if (ts) return {
108
- path: ts,
109
- transform: true
110
- };
111
- const cjs = findConfig("package.config.cjs", {
112
- cwd
113
- });
114
- if (cjs) return {
115
- path: cjs,
116
- transform: false
117
- };
118
- return null;
119
- }
120
-
121
130
  function _resolveConfigProperty(prop, initialValue) {
122
131
  if (!prop) return initialValue;
123
132
 
@@ -305,10 +314,12 @@ function _resolveBuildTasks(ctx) {
305
314
  var _a, _b, _c, _d, _e;
306
315
 
307
316
  const {
317
+ config,
308
318
  cwd,
309
319
  pkg,
310
320
  target
311
321
  } = ctx;
322
+ const bundles = (config == null ? void 0 : config.bundles) || [];
312
323
  const tasks = [];
313
324
  const exports = Object.entries(ctx.exports || {}).map(_ref => {
314
325
  let [_path, exp] = _ref;
@@ -364,23 +375,23 @@ function _resolveBuildTasks(ctx) {
364
375
  }
365
376
 
366
377
  for (const exp of exports) {
367
- const output = (_a = exp.browser) == null ? void 0 : _a.require;
378
+ const output = exp.import;
368
379
  if (!output) continue;
369
380
 
370
- _addRollupTaskEntry("commonjs", "browser", {
381
+ _addRollupTaskEntry("esm", ctx.runtime, {
371
382
  path: exp._path,
372
- source: ((_b = exp.browser) == null ? void 0 : _b.source) || exp.source,
383
+ source: exp.source,
373
384
  output
374
385
  });
375
386
  }
376
387
 
377
388
  for (const exp of exports) {
378
- const output = exp.import;
389
+ const output = (_a = exp.browser) == null ? void 0 : _a.require;
379
390
  if (!output) continue;
380
391
 
381
- _addRollupTaskEntry("esm", ctx.runtime, {
392
+ _addRollupTaskEntry("commonjs", "browser", {
382
393
  path: exp._path,
383
- source: exp.source,
394
+ source: ((_b = exp.browser) == null ? void 0 : _b.source) || exp.source,
384
395
  output
385
396
  });
386
397
  }
@@ -396,19 +407,39 @@ function _resolveBuildTasks(ctx) {
396
407
  });
397
408
  }
398
409
 
410
+ for (const bundle of bundles) {
411
+ if (bundle.require) {
412
+ _addRollupTaskEntry("commonjs", bundle.runtime || ctx.runtime, {
413
+ path: "__bundle__",
414
+ source: bundle.source,
415
+ output: bundle.require
416
+ });
417
+ }
418
+
419
+ if (bundle.import) {
420
+ _addRollupTaskEntry("commonjs", bundle.runtime || ctx.runtime, {
421
+ path: "__bundle__",
422
+ source: bundle.source,
423
+ output: bundle.import
424
+ });
425
+ }
426
+ }
427
+
399
428
  if (dtsTask.entries.length) {
400
429
  tasks.push(dtsTask);
401
430
  }
402
431
 
403
432
  tasks.push(...Object.values(rollupTasks));
404
433
 
405
- for (const exp of exports) {
406
- if (exp._exported && exp._path !== ".") {
407
- const relativeTargetPath = (((_e = exp.browser) == null ? void 0 : _e.import) || exp.import || "").replace(/\.[^/.]+$/, "");
408
- const ext = _MODULE_EXT[pkg.type].esm;
434
+ if (config == null ? void 0 : config.legacyExports) {
435
+ for (const exp of exports) {
436
+ if (exp._exported && exp._path !== ".") {
437
+ const relativeTargetPath = (((_e = exp.browser) == null ? void 0 : _e.import) || exp.import || "").replace(/\.[^/.]+$/, "");
438
+ const ext = _MODULE_EXT[pkg.type].esm;
409
439
 
410
- if (relativeTargetPath) {
411
- fs$2.writeFileSync(path$1.resolve(cwd, "".concat(exp._path, ".js")), ["// AUTO-GENERATED \u2013 DO NOT EDIT", "", "export * from '".concat(relativeTargetPath).concat(pkg.type === "commonjs" ? ext : "", "'"), ""].join("\n"));
440
+ if (relativeTargetPath) {
441
+ fs$2.writeFileSync(path$1.resolve(cwd, "".concat(exp._path, ".js")), ["// AUTO-GENERATED \u2013 DO NOT EDIT", "", "export * from '".concat(relativeTargetPath).concat(pkg.type === "commonjs" ? ext : "", "'"), ""].join("\n"));
442
+ }
412
443
  }
413
444
  }
414
445
  }
@@ -4935,6 +4966,9 @@ async function check(options) {
4935
4966
  pkg,
4936
4967
  tsconfig
4937
4968
  });
4969
+ const {
4970
+ logger
4971
+ } = ctx;
4938
4972
 
4939
4973
  _printPackageTree(ctx);
4940
4974
 
@@ -4960,7 +4994,8 @@ async function check(options) {
4960
4994
  }
4961
4995
 
4962
4996
  if (missingFiles.length) {
4963
- throw new Error("missing files");
4997
+ logger.error("missing files");
4998
+ process.exit(1);
4964
4999
  }
4965
5000
 
4966
5001
  const _paths = {
@@ -4968,10 +5003,10 @@ async function check(options) {
4968
5003
  import: []
4969
5004
  };
4970
5005
 
4971
- for (const [exportPath, exp] of Object.entries(ctx.exports || {})) {
5006
+ for (const exp of Object.values(ctx.exports || {})) {
4972
5007
  if (!exp._exported) continue;
4973
- if (exp.require) _paths.require.push(exportPath);
4974
- if (exp.import) _paths.import.push(exportPath);
5008
+ if (exp.require) _paths.require.push(exp.require);
5009
+ if (exp.import) _paths.import.push(exp.import);
4975
5010
  }
4976
5011
 
4977
5012
  const external = Object.keys(pkg.dependencies || {}).concat(Object.keys(pkg.devDependencies || {}));
@@ -4995,7 +5030,7 @@ async function check(options) {
4995
5030
  });
4996
5031
 
4997
5032
  if (esbuildResult.warnings.length > 0) {
4998
- console.warn(...esbuildResult.warnings);
5033
+ logger.warn(...esbuildResult.warnings);
4999
5034
  }
5000
5035
  } catch (err) {
5001
5036
  const {
@@ -5004,14 +5039,14 @@ async function check(options) {
5004
5039
 
5005
5040
  for (const _err of errors) {
5006
5041
  if (_err.location) {
5007
- console.log(chalk.red("error"), _err.detail || _err.text);
5008
- console.log("".concat(_err.location.line, " | ").concat(_err.location.lineText));
5009
- console.log("in", "./".concat(_err.location.file, ":").concat(_err.location.line, ":").concat(_err.location.column));
5042
+ logger.error(_err.detail || _err.text);
5043
+ logger.error("".concat(_err.location.line, " | ").concat(_err.location.lineText));
5044
+ logger.error("in", "./".concat(_err.location.file, ":").concat(_err.location.line, ":").concat(_err.location.column));
5010
5045
  } else {
5011
- console.log(_err.detail || _err.text);
5046
+ logger.error(_err.detail || _err.text);
5012
5047
  }
5013
5048
 
5014
- console.log();
5049
+ logger.log();
5015
5050
  }
5016
5051
 
5017
5052
  process.exit(1);
@@ -5035,11 +5070,12 @@ async function check(options) {
5035
5070
  });
5036
5071
 
5037
5072
  if (esbuildResult.errors.length > 0) {
5038
- throw new Error(esbuildResult.errors.join(", "));
5073
+ logger.error(esbuildResult.errors.join(", "));
5074
+ process.exit(1);
5039
5075
  }
5040
5076
 
5041
5077
  if (esbuildResult.warnings.length > 0) {
5042
- console.warn(...esbuildResult.warnings);
5078
+ logger.warn(...esbuildResult.warnings);
5043
5079
  }
5044
5080
  }
5045
5081
  }
@@ -5049,6 +5085,7 @@ function _resolveWatchTasks(ctx) {
5049
5085
  var _a, _b, _c, _d, _e;
5050
5086
 
5051
5087
  const {
5088
+ config,
5052
5089
  cwd,
5053
5090
  pkg,
5054
5091
  target
@@ -5146,13 +5183,15 @@ function _resolveWatchTasks(ctx) {
5146
5183
 
5147
5184
  tasks.push(...Object.values(rollupTasks));
5148
5185
 
5149
- for (const exp of exports) {
5150
- if (exp._exported && exp._path !== ".") {
5151
- const relativeTargetPath = (((_e = exp.browser) == null ? void 0 : _e.import) || exp.import || "").replace(/\.[^/.]+$/, "");
5152
- const ext = _MODULE_EXT[pkg.type].esm;
5186
+ if (config == null ? void 0 : config.legacyExports) {
5187
+ for (const exp of exports) {
5188
+ if (exp._exported && exp._path !== ".") {
5189
+ const relativeTargetPath = (((_e = exp.browser) == null ? void 0 : _e.import) || exp.import || "").replace(/\.[^/.]+$/, "");
5190
+ const ext = _MODULE_EXT[pkg.type].esm;
5153
5191
 
5154
- if (relativeTargetPath) {
5155
- fs$2.writeFileSync(path$1.resolve(cwd, "".concat(exp._path, ".js")), ["// AUTO-GENERATED \u2013 DO NOT EDIT", "", "export * from '".concat(relativeTargetPath).concat(pkg.type === "commonjs" ? ext : "", "'"), ""].join("\n"));
5192
+ if (relativeTargetPath) {
5193
+ fs$2.writeFileSync(path$1.resolve(cwd, "".concat(exp._path, ".js")), ["// AUTO-GENERATED \u2013 DO NOT EDIT", "", "export * from '".concat(relativeTargetPath).concat(pkg.type === "commonjs" ? ext : "", "'"), ""].join("\n"));
5194
+ }
5156
5195
  }
5157
5196
  }
5158
5197
  }