@sanity/pkg-utils 1.8.1 → 1.8.3

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 (36) hide show
  1. package/dist/{_build-0377061e.cjs → _build-3d61d85e.cjs} +10 -3
  2. package/dist/_build-3d61d85e.cjs.map +1 -0
  3. package/dist/{_buildAction-68633427.cjs → _buildAction-ba8138ff.cjs} +3 -5
  4. package/dist/{_buildAction-68633427.cjs.map → _buildAction-ba8138ff.cjs.map} +1 -1
  5. package/dist/{_check-11811a4d.cjs → _check-5f3f5a84.cjs} +30 -6
  6. package/dist/_check-5f3f5a84.cjs.map +1 -0
  7. package/dist/{_checkAction-386fe8d4.cjs → _checkAction-6ae8d321.cjs} +2 -2
  8. package/dist/{_checkAction-386fe8d4.cjs.map → _checkAction-6ae8d321.cjs.map} +1 -1
  9. package/dist/{_index-8cd98d8d.cjs → _index-bc62cfaa.cjs} +44 -39
  10. package/dist/_index-bc62cfaa.cjs.map +1 -0
  11. package/dist/{_watch-259b1e4f.cjs → _watch-925404b5.cjs} +10 -3
  12. package/dist/_watch-925404b5.cjs.map +1 -0
  13. package/dist/{_watchAction-a48d3934.cjs → _watchAction-e8317c50.cjs} +3 -5
  14. package/dist/{_watchAction-a48d3934.cjs.map → _watchAction-e8317c50.cjs.map} +1 -1
  15. package/dist/cli.cjs +4 -4
  16. package/dist/index.cjs +29 -30
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.js +72 -40
  19. package/dist/index.js.map +1 -1
  20. package/dist/types/src/node/index.d.ts +9 -0
  21. package/package.json +15 -13
  22. package/src/node/_core/_constants.ts +13 -0
  23. package/src/node/_core/index.ts +1 -0
  24. package/src/node/_printPackageTree.ts +31 -6
  25. package/src/node/_resolveBuildTasks.ts +3 -2
  26. package/src/node/_resolveWatchTasks.ts +3 -2
  27. package/src/node/_tasks/dts/_buildTypes.ts +1 -0
  28. package/src/node/_tasks/dts/_createApiExtractorConfig.ts +13 -5
  29. package/src/node/_tasks/dts/_doExtract.ts +24 -35
  30. package/src/node/_tasks/dts/_extractTypes.ts +4 -4
  31. package/src/node/_tasks/rollup/_resolveRollupConfig.ts +3 -2
  32. package/src/node/watch.ts +1 -1
  33. package/dist/_build-0377061e.cjs.map +0 -1
  34. package/dist/_check-11811a4d.cjs.map +0 -1
  35. package/dist/_index-8cd98d8d.cjs.map +0 -1
  36. package/dist/_watch-259b1e4f.cjs.map +0 -1
@@ -20,10 +20,16 @@ require('typescript');
20
20
 
21
21
  var fs = require('fs');
22
22
 
23
- var index = require('./_index-8cd98d8d.cjs');
23
+ var index = require('./_index-bc62cfaa.cjs');
24
+
25
+ require('esbuild-register/dist/node');
26
+
27
+ require('find-config');
24
28
 
25
29
  var chalk = require('chalk');
26
30
 
31
+ require('zod');
32
+
27
33
  var operators = require('rxjs/operators');
28
34
 
29
35
  var globby = require('globby');
@@ -150,9 +156,10 @@ function _resolveWatchTasks(ctx) {
150
156
  for (const exp of exports) {
151
157
  if (exp._exported && exp._path !== ".") {
152
158
  const relativeTargetPath = (((_e = exp.browser) == null ? void 0 : _e.import) || exp.import || "").replace(/\.[^/.]+$/, "");
159
+ const ext = index._MODULE_EXT[pkg.type].esm;
153
160
 
154
161
  if (relativeTargetPath) {
155
- fs__default["default"].writeFileSync(path__default["default"].resolve(cwd, "".concat(exp._path, ".js")), ["// AUTO-GENERATED \u2013 DO NOT EDIT", "", "export * from '".concat(relativeTargetPath, "'"), ""].join("\n"));
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"));
156
163
  }
157
164
  }
158
165
  }
@@ -268,4 +275,4 @@ async function watch(options) {
268
275
  }
269
276
 
270
277
  exports.watch = watch;
271
- //# sourceMappingURL=_watch-259b1e4f.cjs.map
278
+ //# sourceMappingURL=_watch-925404b5.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_watch-925404b5.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 {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 // Parse rollup:esm:browser tasks\n for (const exp of exports) {\n if (exp._exported && exp._path !== '.') {\n const relativeTargetPath = (exp.browser?.import || exp.import || '').replace(/\\.[^/.]+$/, '')\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 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","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","_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","config","_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,GAAF;IAAOC,GAAP;IAAYC;EAAZ,IAAuBR,GAA7B;EACA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GAAGF,OAAO,CAACG,IAAR,CAAavG,GAAb,EAAkBmG,IAAlB,CAAhB;MACAG,OAAO,CAACL,SAAR,CAAkB;QAChBO,KAAK,EAAGC,GAAD,IAAS;UACdzG,GAAG,CAAC0G,MAAJ,CAAWF,KAAX,CAAiBC,GAAjB;UACAzG,GAAG,CAAC0G,MAAJ,CAAW7B,GAAX;UACA8B,OAAO,CAACC,IAAR,CAAa,CAAb;QACD,CALe;QAMhB/C,IAAI,EAAGgD,MAAD,IAAY;UAChBT,OAAO,CAACU,QAAR,CAAiB9G,GAAjB,EAAsBmG,IAAtB,EAA4BU,MAA5B;QACD,CARe;QAShBC,QAAQ,EAAE,MAAM;UACd9G,GAAG,CAAC0G,MAAJ,CAAWK,OAAX,CAAmBX,OAAO,CAACxE,IAAR,CAAa5B,GAAb,EAAkBmG,IAAlB,CAAnB;UACAnG,GAAG,CAAC0G,MAAJ,CAAW7B,GAAX;QACD;MAZe,CAAlB;IAcD;EACF,CApBD;AAqBF;;"}
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var watch = require('./_watch-259b1e4f.cjs');
3
+ var watch = require('./_watch-925404b5.cjs');
4
4
 
5
5
  require('path');
6
6
 
@@ -26,12 +26,10 @@ require('browserslist');
26
26
 
27
27
  require('fs');
28
28
 
29
- require('./_index-8cd98d8d.cjs');
29
+ require('./_index-bc62cfaa.cjs');
30
30
 
31
31
  require('util');
32
32
 
33
- require('cpx');
34
-
35
33
  require('assert');
36
34
 
37
35
  require('events');
@@ -78,4 +76,4 @@ async function watchAction(options) {
78
76
  }
79
77
 
80
78
  exports.watchAction = watchAction;
81
- //# sourceMappingURL=_watchAction-a48d3934.cjs.map
79
+ //# sourceMappingURL=_watchAction-e8317c50.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"_watchAction-a48d3934.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-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;;"}
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.1";
13
+ var version = "1.8.3";
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-386fe8d4.cjs');
19
+ return require('./_checkAction-6ae8d321.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-68633427.cjs');
27
+ return require('./_buildAction-ba8138ff.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-a48d3934.cjs');
35
+ return require('./_watchAction-e8317c50.cjs');
36
36
  });
37
37
  return watchAction(options);
38
38
  });
package/dist/index.cjs CHANGED
@@ -4,45 +4,33 @@ Object.defineProperty(exports, '__esModule', {
4
4
  value: true
5
5
  });
6
6
 
7
- var _resolveBuildContext = require('./__resolveBuildContext-17992a0e.cjs');
8
-
9
- var build = require('./_build-0377061e.cjs');
7
+ var index = require('./_index-bc62cfaa.cjs');
10
8
 
11
- var index = require('./_index-8cd98d8d.cjs');
9
+ var _resolveBuildContext = require('./__resolveBuildContext-17992a0e.cjs');
12
10
 
13
- var check = require('./_check-11811a4d.cjs');
11
+ var build = require('./_build-3d61d85e.cjs');
14
12
 
15
- var watch = require('./_watch-259b1e4f.cjs');
13
+ var check = require('./_check-5f3f5a84.cjs');
16
14
 
17
- require('path');
18
-
19
- require('esbuild-register/dist/node');
20
-
21
- require('find-config');
22
-
23
- require('pkg-up');
15
+ var watch = require('./_watch-925404b5.cjs');
24
16
 
25
17
  require('chalk');
26
18
 
27
- require('zod');
19
+ require('rxjs');
28
20
 
29
- require('fs/promises');
21
+ require('path');
30
22
 
31
- require('typescript');
23
+ require('util');
32
24
 
33
- require('browserslist');
25
+ require('assert');
34
26
 
35
27
  require('fs');
36
28
 
37
- require('rxjs');
38
-
39
- require('util');
40
-
41
- require('cpx');
29
+ require('events');
42
30
 
43
- require('assert');
31
+ require('typescript');
44
32
 
45
- require('events');
33
+ require('fs/promises');
46
34
 
47
35
  require('@microsoft/api-extractor');
48
36
 
@@ -72,6 +60,16 @@ require('rollup-plugin-esbuild');
72
60
 
73
61
  require('rollup-plugin-terser');
74
62
 
63
+ require('esbuild-register/dist/node');
64
+
65
+ require('find-config');
66
+
67
+ require('pkg-up');
68
+
69
+ require('zod');
70
+
71
+ require('browserslist');
72
+
75
73
  require('esbuild');
76
74
 
77
75
  require('treeify');
@@ -88,6 +86,13 @@ function defineConfig(configOptions) {
88
86
  return configOptions;
89
87
  }
90
88
 
89
+ exports._MODULE_EXT = index._MODULE_EXT;
90
+ exports._buildTaskHandlers = index._buildTaskHandlers;
91
+ exports._dtsTask = index._dtsTask;
92
+ exports._dtsWatchTask = index._dtsWatchTask;
93
+ exports._rollupTask = index._rollupTask;
94
+ exports._rollupWatchTask = index._rollupWatchTask;
95
+ exports._watchTaskHandlers = index._watchTaskHandlers;
91
96
  exports._DEFAULTS = _resolveBuildContext._DEFAULTS;
92
97
  exports._isRecord = _resolveBuildContext._isRecord;
93
98
  exports._loadConfig = _resolveBuildContext._loadConfig;
@@ -98,12 +103,6 @@ exports._parseExports = _resolveBuildContext._parseExports;
98
103
  exports._resolveConfigProperty = _resolveBuildContext._resolveConfigProperty;
99
104
  exports._resolveBuildTasks = build._resolveBuildTasks;
100
105
  exports.build = build.build;
101
- exports._buildTaskHandlers = index._buildTaskHandlers;
102
- exports._dtsTask = index._dtsTask;
103
- exports._dtsWatchTask = index._dtsWatchTask;
104
- exports._rollupTask = index._rollupTask;
105
- exports._rollupWatchTask = index._rollupWatchTask;
106
- exports._watchTaskHandlers = index._watchTaskHandlers;
107
106
  exports.check = check.check;
108
107
  exports.watch = watch.watch;
109
108
  exports.defineConfig = defineConfig;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../src/node/_core/config/defineConfig.ts"],"sourcesContent":["import {PkgConfigOptions} from './types'\n\n/** @public */\nexport function defineConfig(configOptions: PkgConfigOptions): PkgConfigOptions {\n return configOptions\n}\n"],"names":["defineConfig","configOptions"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAO,SAASA,YAAT,CAAsBC,aAAtB,EAAqC;EAC1C,OAAOA,aAAP;AACF;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":["../src/node/_core/config/defineConfig.ts"],"sourcesContent":["import {PkgConfigOptions} from './types'\n\n/** @public */\nexport function defineConfig(configOptions: PkgConfigOptions): PkgConfigOptions {\n return configOptions\n}\n"],"names":["defineConfig","configOptions"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAO,SAASA,YAAT,CAAsBC,aAAtB,EAAqC;EAC1C,OAAOA,aAAP;AACF;;;;;;;;;;;;;;;;;;;;;"}
package/dist/index.js CHANGED
@@ -14,14 +14,13 @@ import path$1 from 'path';
14
14
  import { register } from 'esbuild-register/dist/node';
15
15
  import findConfig from 'find-config';
16
16
  import pkgUp from 'pkg-up';
17
- import fs$1, { readFile, rename } from 'fs/promises';
17
+ import fs$1, { readFile } from 'fs/promises';
18
18
  import { z, ZodError } from 'zod';
19
19
  import chalk from 'chalk';
20
20
  import ts from 'typescript';
21
21
  import fs$2, { statSync } from 'fs';
22
22
  import { Observable, switchMap } from 'rxjs';
23
23
  import { promisify } from 'util';
24
- import cpx from 'cpx';
25
24
  import require$$5 from 'assert';
26
25
  import require$$3 from 'events';
27
26
  import { ExtractorConfig, Extractor } from '@microsoft/api-extractor';
@@ -45,6 +44,16 @@ import prettyBytes from 'pretty-bytes';
45
44
  import { scan, startWith, distinctUntilChanged } from 'rxjs/operators';
46
45
  import globby from 'globby';
47
46
  import chokidar from 'chokidar';
47
+ const _MODULE_EXT = {
48
+ commonjs: {
49
+ commonjs: ".js",
50
+ esm: ".mjs"
51
+ },
52
+ module: {
53
+ commonjs: ".cjs",
54
+ esm: ".js"
55
+ }
56
+ };
48
57
  const _DEFAULTS = {
49
58
  browserslist: ["> 0.2% and supports es6-module and supports es6-module-dynamic-import", "not dead", "not IE 11", "maintained node versions"]
50
59
  };
@@ -396,9 +405,10 @@ function _resolveBuildTasks(ctx) {
396
405
  for (const exp of exports) {
397
406
  if (exp._exported && exp._path !== ".") {
398
407
  const relativeTargetPath = (((_e = exp.browser) == null ? void 0 : _e.import) || exp.import || "").replace(/\.[^/.]+$/, "");
408
+ const ext = _MODULE_EXT[pkg.type].esm;
399
409
 
400
410
  if (relativeTargetPath) {
401
- fs$2.writeFileSync(path$1.resolve(cwd, "".concat(exp._path, ".js")), ["// AUTO-GENERATED \u2013 DO NOT EDIT", "", "export * from '".concat(relativeTargetPath, "'"), ""].join("\n"));
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"));
402
412
  }
403
413
  }
404
414
  }
@@ -3972,8 +3982,8 @@ function _createApiExtractorConfig(options) {
3972
3982
  exportPath,
3973
3983
  filePath,
3974
3984
  messages,
3975
- projectPath,
3976
- sourcePath,
3985
+ projectFolder,
3986
+ mainEntryPointFilePath,
3977
3987
  tsconfigPath
3978
3988
  } = options;
3979
3989
  return {
@@ -3996,8 +4006,8 @@ function _createApiExtractorConfig(options) {
3996
4006
  enabled: false
3997
4007
  },
3998
4008
  messages,
3999
- mainEntryPointFilePath: sourcePath,
4000
- projectFolder: projectPath
4009
+ mainEntryPointFilePath,
4010
+ projectFolder
4001
4011
  };
4002
4012
  }
4003
4013
 
@@ -4046,7 +4056,7 @@ async function _extractTypes(options) {
4046
4056
  filePath,
4047
4057
  projectPath,
4048
4058
  rules,
4049
- sourcePath,
4059
+ sourceTypesPath,
4050
4060
  tsconfigPath
4051
4061
  } = options;
4052
4062
  const tsdocConfigFile = await _createTSDocConfig({
@@ -4103,8 +4113,8 @@ async function _extractTypes(options) {
4103
4113
  exportPath,
4104
4114
  filePath,
4105
4115
  messages: messagesConfig,
4106
- projectPath,
4107
- sourcePath,
4116
+ projectFolder: projectPath,
4117
+ mainEntryPointFilePath: sourceTypesPath,
4108
4118
  tsconfigPath
4109
4119
  }),
4110
4120
  configObjectFullPath: void 0,
@@ -4147,7 +4157,6 @@ async function _doExtract(ctx, task) {
4147
4157
  const {
4148
4158
  config,
4149
4159
  cwd,
4150
- dist,
4151
4160
  files,
4152
4161
  ts
4153
4162
  } = ctx;
@@ -4160,14 +4169,19 @@ async function _doExtract(ctx, task) {
4160
4169
  };
4161
4170
  }
4162
4171
 
4163
- const distPath = path$1.resolve(cwd, dist);
4164
4172
  const {
4165
- outDir = distPath,
4173
+ outDir,
4166
4174
  rootDir = cwd
4167
4175
  } = ts.config.options;
4176
+
4177
+ if (!outDir) {
4178
+ throw new Error("tsconfig.json is missing `compilerOptions.outDir`");
4179
+ }
4180
+
4181
+ const tmpPath = path$1.resolve(outDir, "__tmp__");
4168
4182
  await _buildTypes({
4169
4183
  cwd,
4170
- outDir,
4184
+ outDir: tmpPath,
4171
4185
  tsconfig: ts.config
4172
4186
  });
4173
4187
  const messages = [];
@@ -4175,37 +4189,30 @@ async function _doExtract(ctx, task) {
4175
4189
 
4176
4190
  for (const entry of task.entries) {
4177
4191
  const exportPath = entry.exportPath === "." ? "./index" : entry.exportPath;
4178
- const sourcePath = path$1.resolve(outDir, path$1.relative(cwd, rootDir), entry.sourcePath.replace(/\.ts$/, ".d.ts"));
4179
- const filePath = path$1.relative(distPath, path$1.resolve(cwd, entry.targetPath));
4192
+ const sourceTypesPath = path$1.resolve(tmpPath, path$1.relative(rootDir, path$1.resolve(cwd, entry.sourcePath)).replace(/\.ts$/, ".d.ts"));
4193
+ const targetPath = path$1.resolve(cwd, entry.targetPath);
4180
4194
  const result = await _extractTypes({
4181
4195
  cwd,
4182
4196
  exportPath,
4183
4197
  files,
4184
- filePath,
4198
+ filePath: path$1.relative(outDir, targetPath),
4185
4199
  projectPath: cwd,
4186
4200
  rules: (_a = config == null ? void 0 : config.extract) == null ? void 0 : _a.rules,
4187
- sourcePath,
4188
- tsconfigPath: path$1.resolve(cwd, ts.configPath),
4189
- distPath
4190
- });
4191
- results.push({
4192
- sourcePath,
4193
- filePath
4201
+ sourceTypesPath,
4202
+ tsconfigPath: path$1.resolve(cwd, ts.configPath || "tsconfig.json"),
4203
+ distPath: outDir
4194
4204
  });
4195
4205
  messages.push(...result.messages);
4196
4206
 
4197
4207
  if (result.messages.some(msg => msg.logLevel === "error")) {
4208
+ await rimraf(tmpPath);
4198
4209
  throw new _DtsError("encountered errors when extracting types", result.messages);
4199
4210
  }
4200
- }
4201
-
4202
- const tmpPath = path$1.resolve(distPath, "__tmp__");
4203
- await rename(outDir, tmpPath);
4204
4211
 
4205
- for (const result of results) {
4206
- const fromPath = path$1.resolve(tmpPath, path$1.relative(outDir, path$1.resolve(distPath, result.filePath)));
4207
- const toPath = path$1.resolve(distPath, result.filePath);
4208
- cpx.copySync(fromPath, path$1.dirname(toPath));
4212
+ results.push({
4213
+ sourcePath: path$1.resolve(cwd, entry.sourcePath),
4214
+ filePath: targetPath
4215
+ });
4209
4216
  }
4210
4217
 
4211
4218
  await rimraf(tmpPath);
@@ -4296,7 +4303,7 @@ function _resolveRollupConfig(ctx, buildTask) {
4296
4303
  pkg,
4297
4304
  ts
4298
4305
  } = ctx;
4299
- const outputExt = format === "commonjs" ? ".cjs" : ".js";
4306
+ const outputExt = _MODULE_EXT[pkg.type][format];
4300
4307
  const minify = (_ref2 = config == null ? void 0 : config.minify) !== null && _ref2 !== void 0 ? _ref2 : true;
4301
4308
  const pathAliases = Object.fromEntries(Object.entries(((_a = ts.config) == null ? void 0 : _a.options.paths) || {}).map(_ref3 => {
4302
4309
  let [key, val] = _ref3;
@@ -4858,16 +4865,28 @@ function _printPackageTree(ctx) {
4858
4865
  let [exportPath, entry] = _ref11;
4859
4866
  const exp = {
4860
4867
  source: entry.source,
4868
+ types: void 0,
4869
+ browser: void 0,
4870
+ node: void 0,
4871
+ import: void 0,
4872
+ require: void 0,
4861
4873
  default: entry.default
4862
4874
  };
4863
- if (entry.types) exp.types = _fileInfo(entry.types);
4875
+
4876
+ if (entry.types) {
4877
+ exp.types = _fileInfo(entry.types);
4878
+ } else {
4879
+ delete exp.types;
4880
+ }
4864
4881
 
4865
4882
  if (entry.browser) {
4866
4883
  exp.browser = {
4867
4884
  source: entry.browser.source
4868
4885
  };
4869
4886
  if (entry.browser.import) exp.browser.import = _fileInfo(entry.browser.import);
4870
- if (entry.browser.require) exp.browser.import = _fileInfo(entry.browser.require);
4887
+ if (entry.browser.require) exp.browser.require = _fileInfo(entry.browser.require);
4888
+ } else {
4889
+ delete exp.browser;
4871
4890
  }
4872
4891
 
4873
4892
  if (entry.node) {
@@ -4875,11 +4894,23 @@ function _printPackageTree(ctx) {
4875
4894
  source: entry.node.source
4876
4895
  };
4877
4896
  if (entry.node.import) exp.node.import = _fileInfo(entry.node.import);
4878
- if (entry.node.require) exp.node.import = _fileInfo(entry.node.require);
4897
+ if (entry.node.require) exp.node.require = _fileInfo(entry.node.require);
4898
+ } else {
4899
+ delete exp.node;
4900
+ }
4901
+
4902
+ if (entry.import) {
4903
+ exp.import = _fileInfo(entry.import);
4904
+ } else {
4905
+ delete exp.import;
4906
+ }
4907
+
4908
+ if (entry.require) {
4909
+ exp.require = _fileInfo(entry.require);
4910
+ } else {
4911
+ delete exp.require;
4879
4912
  }
4880
4913
 
4881
- if (entry.import) exp.import = _fileInfo(entry.import);
4882
- if (entry.require) exp.require = _fileInfo(entry.require);
4883
4914
  exp.default = _fileInfo(entry.default);
4884
4915
  return [chalk.green(path$1.join(pkg.name, exportPath)), exp];
4885
4916
  }));
@@ -5118,9 +5149,10 @@ function _resolveWatchTasks(ctx) {
5118
5149
  for (const exp of exports) {
5119
5150
  if (exp._exported && exp._path !== ".") {
5120
5151
  const relativeTargetPath = (((_e = exp.browser) == null ? void 0 : _e.import) || exp.import || "").replace(/\.[^/.]+$/, "");
5152
+ const ext = _MODULE_EXT[pkg.type].esm;
5121
5153
 
5122
5154
  if (relativeTargetPath) {
5123
- fs$2.writeFileSync(path$1.resolve(cwd, "".concat(exp._path, ".js")), ["// AUTO-GENERATED \u2013 DO NOT EDIT", "", "export * from '".concat(relativeTargetPath, "'"), ""].join("\n"));
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"));
5124
5156
  }
5125
5157
  }
5126
5158
  }
@@ -5235,5 +5267,5 @@ async function watch(options) {
5235
5267
  });
5236
5268
  }
5237
5269
 
5238
- export { _DEFAULTS, _buildTaskHandlers, _dtsTask, _dtsWatchTask, _isRecord, _loadConfig, _loadPkg, _loadPkgWithReporting, _loadTSConfig, _parseExports, _resolveBuildTasks, _resolveConfigProperty, _rollupTask, _rollupWatchTask, _watchTaskHandlers, build, check, defineConfig, watch };
5270
+ export { _DEFAULTS, _MODULE_EXT, _buildTaskHandlers, _dtsTask, _dtsWatchTask, _isRecord, _loadConfig, _loadPkg, _loadPkgWithReporting, _loadTSConfig, _parseExports, _resolveBuildTasks, _resolveConfigProperty, _rollupTask, _rollupWatchTask, _watchTaskHandlers, build, check, defineConfig, watch };
5239
5271
  //# sourceMappingURL=index.js.map