@sanity/pkg-utils 1.8.2 → 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.
- package/dist/{_build-be4da439.cjs → _build-3d61d85e.cjs} +2 -2
- package/dist/{_build-be4da439.cjs.map → _build-3d61d85e.cjs.map} +1 -1
- package/dist/{_buildAction-db8d7aa0.cjs → _buildAction-ba8138ff.cjs} +3 -5
- package/dist/{_buildAction-db8d7aa0.cjs.map → _buildAction-ba8138ff.cjs.map} +1 -1
- package/dist/{_check-11811a4d.cjs → _check-5f3f5a84.cjs} +30 -6
- package/dist/_check-5f3f5a84.cjs.map +1 -0
- package/dist/{_checkAction-386fe8d4.cjs → _checkAction-6ae8d321.cjs} +2 -2
- package/dist/{_checkAction-386fe8d4.cjs.map → _checkAction-6ae8d321.cjs.map} +1 -1
- package/dist/{_index-066890ec.cjs → _index-bc62cfaa.cjs} +31 -38
- package/dist/_index-bc62cfaa.cjs.map +1 -0
- package/dist/{_watch-feff6936.cjs → _watch-925404b5.cjs} +2 -2
- package/dist/_watch-925404b5.cjs.map +1 -0
- package/dist/{_watchAction-453b8884.cjs → _watchAction-e8317c50.cjs} +3 -5
- package/dist/{_watchAction-453b8884.cjs.map → _watchAction-e8317c50.cjs.map} +1 -1
- package/dist/cli.cjs +4 -4
- package/dist/index.cjs +6 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +56 -36
- package/dist/index.js.map +1 -1
- package/package.json +15 -13
- package/src/node/_printPackageTree.ts +31 -6
- package/src/node/_tasks/dts/_buildTypes.ts +1 -0
- package/src/node/_tasks/dts/_createApiExtractorConfig.ts +13 -5
- package/src/node/_tasks/dts/_doExtract.ts +24 -35
- package/src/node/_tasks/dts/_extractTypes.ts +4 -4
- package/src/node/watch.ts +1 -1
- package/dist/_check-11811a4d.cjs.map +0 -1
- package/dist/_index-066890ec.cjs.map +0 -1
- package/dist/_watch-feff6936.cjs.map +0 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@sanity/pkg-utils",
|
|
4
|
-
"version": "1.8.
|
|
4
|
+
"version": "1.8.3",
|
|
5
5
|
"author": "Sanity.io <hello@sanity.io>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"description": "Simple utilities for modern npm packages.",
|
|
@@ -37,19 +37,18 @@
|
|
|
37
37
|
"dist"
|
|
38
38
|
],
|
|
39
39
|
"scripts": {
|
|
40
|
-
"build": "
|
|
41
|
-
"
|
|
40
|
+
"build": "run-s clean build:pkg check:pkg",
|
|
41
|
+
"build:pkg": "node --experimental-loader ./scripts/_experimental-loader.js --no-warnings -r esbuild-register scripts/build",
|
|
42
|
+
"check:pkg": "node --experimental-loader ./scripts/_experimental-loader.js --no-warnings -r esbuild-register scripts/check",
|
|
43
|
+
"check:types": "tsc --build",
|
|
42
44
|
"clean": "rimraf dist test/env/__tmp__",
|
|
43
45
|
"commit": "cz",
|
|
44
46
|
"extract": "sanity-tsdoc etl --outDir etc/api/@sanity/pkg-utils --tsconfig tsconfig.dist.json",
|
|
45
47
|
"format": "prettier --write --cache --ignore-unknown .",
|
|
46
|
-
"lint": "eslint . --ext .cjs,.js,.ts",
|
|
47
|
-
"postbuild": "pnpm run check:package",
|
|
48
|
-
"prebuild": "pnpm run clean",
|
|
48
|
+
"lint": "eslint . --ext .cjs,.js,.ts,.tsx",
|
|
49
49
|
"prepublishOnly": "pnpm run build",
|
|
50
50
|
"release": "semantic-release",
|
|
51
51
|
"test": "vitest run",
|
|
52
|
-
"type-check": "tsc --build",
|
|
53
52
|
"watch": "node --experimental-loader ./scripts/_experimental-loader.js --no-warnings -r esbuild-register scripts/watch"
|
|
54
53
|
},
|
|
55
54
|
"dependencies": {
|
|
@@ -68,7 +67,6 @@
|
|
|
68
67
|
"cac": "^6.7.12",
|
|
69
68
|
"chalk": "^4.1.2",
|
|
70
69
|
"chokidar": "^3.5.3",
|
|
71
|
-
"cpx": "^1.5.0",
|
|
72
70
|
"esbuild": "^0.15.5",
|
|
73
71
|
"esbuild-register": "^3.3.3",
|
|
74
72
|
"find-config": "^1.0.0",
|
|
@@ -89,6 +87,7 @@
|
|
|
89
87
|
"devDependencies": {
|
|
90
88
|
"@commitlint/cli": "^17.0.3",
|
|
91
89
|
"@commitlint/config-conventional": "^17.0.3",
|
|
90
|
+
"@sanity/pkg-utils": "workspace:*",
|
|
92
91
|
"@sanity/semantic-release-preset": "^2.0.0",
|
|
93
92
|
"@types/babel__core": "^7.1.19",
|
|
94
93
|
"@types/cpx": "^1.5.2",
|
|
@@ -102,6 +101,7 @@
|
|
|
102
101
|
"@typescript-eslint/eslint-plugin": "^5.35.1",
|
|
103
102
|
"@typescript-eslint/parser": "^5.35.1",
|
|
104
103
|
"commitizen": "^4.2.5",
|
|
104
|
+
"cpx": "^1.5.0",
|
|
105
105
|
"cz-conventional-changelog": "^3.3.0",
|
|
106
106
|
"eslint": "^8.23.0",
|
|
107
107
|
"eslint-config-prettier": "^8.5.0",
|
|
@@ -109,6 +109,7 @@
|
|
|
109
109
|
"eslint-plugin-prettier": "^4.2.1",
|
|
110
110
|
"husky": "^8.0.1",
|
|
111
111
|
"lint-staged": "^12.5.0",
|
|
112
|
+
"npm-run-all": "^4.1.5",
|
|
112
113
|
"rimraf": "^3.0.2",
|
|
113
114
|
"semantic-release": "^19.0.5",
|
|
114
115
|
"ts-node": "^10.9.1",
|
|
@@ -118,11 +119,6 @@
|
|
|
118
119
|
"peerDependencies": {
|
|
119
120
|
"typescript": "^4.7"
|
|
120
121
|
},
|
|
121
|
-
"config": {
|
|
122
|
-
"commitizen": {
|
|
123
|
-
"path": "cz-conventional-changelog"
|
|
124
|
-
}
|
|
125
|
-
},
|
|
126
122
|
"engines": {
|
|
127
123
|
"node": ">=14.0.0"
|
|
128
124
|
},
|
|
@@ -141,5 +137,11 @@
|
|
|
141
137
|
"homepage": "https://github.com/sanity-io/pkg-utils#readme",
|
|
142
138
|
"publishConfig": {
|
|
143
139
|
"access": "public"
|
|
140
|
+
},
|
|
141
|
+
"packageManager": "pnpm@7.12.2",
|
|
142
|
+
"pnpm": {
|
|
143
|
+
"overrides": {
|
|
144
|
+
"@sanity/pkg-utils": "workspace:*"
|
|
145
|
+
}
|
|
144
146
|
}
|
|
145
147
|
}
|
|
@@ -51,26 +51,51 @@ export function _printPackageTree(ctx: _BuildContext): void {
|
|
|
51
51
|
Object.entries(exports)
|
|
52
52
|
.filter(([, entry]) => entry._exported)
|
|
53
53
|
.map(([exportPath, entry]) => {
|
|
54
|
-
const exp: Omit<PkgExport, '_exported'> = {
|
|
54
|
+
const exp: Omit<PkgExport, '_exported'> = {
|
|
55
|
+
source: entry.source,
|
|
56
|
+
types: undefined,
|
|
57
|
+
browser: undefined,
|
|
58
|
+
node: undefined,
|
|
59
|
+
import: undefined,
|
|
60
|
+
require: undefined,
|
|
61
|
+
default: entry.default,
|
|
62
|
+
}
|
|
55
63
|
|
|
56
|
-
if (entry.types)
|
|
64
|
+
if (entry.types) {
|
|
65
|
+
exp.types = _fileInfo(entry.types)
|
|
66
|
+
} else {
|
|
67
|
+
delete exp.types
|
|
68
|
+
}
|
|
57
69
|
|
|
58
70
|
if (entry.browser) {
|
|
59
71
|
exp.browser = {source: entry.browser.source}
|
|
60
72
|
|
|
61
73
|
if (entry.browser.import) exp.browser.import = _fileInfo(entry.browser.import)
|
|
62
|
-
if (entry.browser.require) exp.browser.
|
|
74
|
+
if (entry.browser.require) exp.browser.require = _fileInfo(entry.browser.require)
|
|
75
|
+
} else {
|
|
76
|
+
delete exp.browser
|
|
63
77
|
}
|
|
64
78
|
|
|
65
79
|
if (entry.node) {
|
|
66
80
|
exp.node = {source: entry.node.source}
|
|
67
81
|
|
|
68
82
|
if (entry.node.import) exp.node.import = _fileInfo(entry.node.import)
|
|
69
|
-
if (entry.node.require) exp.node.
|
|
83
|
+
if (entry.node.require) exp.node.require = _fileInfo(entry.node.require)
|
|
84
|
+
} else {
|
|
85
|
+
delete exp.node
|
|
70
86
|
}
|
|
71
87
|
|
|
72
|
-
if (entry.import)
|
|
73
|
-
|
|
88
|
+
if (entry.import) {
|
|
89
|
+
exp.import = _fileInfo(entry.import)
|
|
90
|
+
} else {
|
|
91
|
+
delete exp.import
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (entry.require) {
|
|
95
|
+
exp.require = _fileInfo(entry.require)
|
|
96
|
+
} else {
|
|
97
|
+
delete exp.require
|
|
98
|
+
}
|
|
74
99
|
|
|
75
100
|
exp.default = _fileInfo(entry.default)
|
|
76
101
|
|
|
@@ -31,6 +31,7 @@ export async function _buildTypes(options: {
|
|
|
31
31
|
|
|
32
32
|
const allDiagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics)
|
|
33
33
|
|
|
34
|
+
// TODO: improve logging
|
|
34
35
|
allDiagnostics.forEach((diagnostic) => {
|
|
35
36
|
if (diagnostic.file && diagnostic.start) {
|
|
36
37
|
const {line, character} = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start)
|
|
@@ -6,11 +6,19 @@ export function _createApiExtractorConfig(options: {
|
|
|
6
6
|
exportPath: string
|
|
7
7
|
filePath: string
|
|
8
8
|
messages: IExtractorMessagesConfig
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
projectFolder: string
|
|
10
|
+
mainEntryPointFilePath: string
|
|
11
11
|
tsconfigPath: string
|
|
12
12
|
}): IConfigFile {
|
|
13
|
-
const {
|
|
13
|
+
const {
|
|
14
|
+
distPath,
|
|
15
|
+
exportPath,
|
|
16
|
+
filePath,
|
|
17
|
+
messages,
|
|
18
|
+
projectFolder,
|
|
19
|
+
mainEntryPointFilePath,
|
|
20
|
+
tsconfigPath,
|
|
21
|
+
} = options
|
|
14
22
|
|
|
15
23
|
return {
|
|
16
24
|
apiReport: {
|
|
@@ -35,7 +43,7 @@ export function _createApiExtractorConfig(options: {
|
|
|
35
43
|
enabled: false,
|
|
36
44
|
},
|
|
37
45
|
messages,
|
|
38
|
-
mainEntryPointFilePath
|
|
39
|
-
projectFolder
|
|
46
|
+
mainEntryPointFilePath,
|
|
47
|
+
projectFolder,
|
|
40
48
|
}
|
|
41
49
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import {rename} from 'fs/promises'
|
|
2
1
|
import path from 'path'
|
|
3
2
|
import {promisify} from 'util'
|
|
4
3
|
import {ExtractorMessage} from '@microsoft/api-extractor'
|
|
5
|
-
import cpx from 'cpx'
|
|
6
4
|
import rimrafCallback from 'rimraf'
|
|
7
5
|
import {_BuildContext} from '../../_core'
|
|
8
6
|
import {_buildTypes} from './_buildTypes'
|
|
@@ -12,25 +10,30 @@ import {_DtsResult, _DtsTask, _DtsWatchTask} from './_types'
|
|
|
12
10
|
|
|
13
11
|
const rimraf = promisify(rimrafCallback)
|
|
14
12
|
|
|
13
|
+
/**
|
|
14
|
+
* - Build type definitions to a temporary directory using TypeScript compiler.
|
|
15
|
+
* - Create a type definition bundle for each export entry.
|
|
16
|
+
* - When done, remove the temporary directory.
|
|
17
|
+
*/
|
|
15
18
|
export async function _doExtract(
|
|
16
19
|
ctx: _BuildContext,
|
|
17
20
|
task: _DtsTask | _DtsWatchTask
|
|
18
21
|
): Promise<_DtsResult> {
|
|
19
|
-
const {config, cwd,
|
|
22
|
+
const {config, cwd, files, ts} = ctx
|
|
20
23
|
|
|
21
24
|
if (!ts.config || !ts.configPath) {
|
|
22
25
|
return {type: 'dts', messages: [], results: []}
|
|
23
26
|
}
|
|
24
27
|
|
|
25
|
-
const
|
|
28
|
+
const {outDir, rootDir = cwd} = ts.config.options
|
|
26
29
|
|
|
27
|
-
|
|
30
|
+
if (!outDir) {
|
|
31
|
+
throw new Error('tsconfig.json is missing `compilerOptions.outDir`')
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const tmpPath = path.resolve(outDir, '__tmp__')
|
|
28
35
|
|
|
29
|
-
await _buildTypes({
|
|
30
|
-
cwd,
|
|
31
|
-
outDir: outDir,
|
|
32
|
-
tsconfig: ts.config,
|
|
33
|
-
})
|
|
36
|
+
await _buildTypes({cwd, outDir: tmpPath, tsconfig: ts.config})
|
|
34
37
|
|
|
35
38
|
const messages: ExtractorMessage[] = []
|
|
36
39
|
|
|
@@ -39,48 +42,34 @@ export async function _doExtract(
|
|
|
39
42
|
for (const entry of task.entries) {
|
|
40
43
|
const exportPath = entry.exportPath === '.' ? './index' : entry.exportPath
|
|
41
44
|
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
path.relative(cwd,
|
|
45
|
-
entry.sourcePath.replace(/\.ts$/, '.d.ts')
|
|
45
|
+
const sourceTypesPath = path.resolve(
|
|
46
|
+
tmpPath,
|
|
47
|
+
path.relative(rootDir, path.resolve(cwd, entry.sourcePath)).replace(/\.ts$/, '.d.ts')
|
|
46
48
|
)
|
|
47
49
|
|
|
48
|
-
const
|
|
50
|
+
const targetPath = path.resolve(cwd, entry.targetPath)
|
|
49
51
|
|
|
50
52
|
const result = await _extractTypes({
|
|
51
53
|
cwd,
|
|
52
54
|
exportPath,
|
|
53
55
|
files,
|
|
54
|
-
filePath,
|
|
56
|
+
filePath: path.relative(outDir, targetPath),
|
|
55
57
|
projectPath: cwd,
|
|
56
58
|
rules: config?.extract?.rules,
|
|
57
|
-
|
|
58
|
-
tsconfigPath: path.resolve(cwd, ts.configPath),
|
|
59
|
-
distPath,
|
|
59
|
+
sourceTypesPath: sourceTypesPath,
|
|
60
|
+
tsconfigPath: path.resolve(cwd, ts.configPath || 'tsconfig.json'),
|
|
61
|
+
distPath: outDir,
|
|
60
62
|
})
|
|
61
63
|
|
|
62
|
-
results.push({sourcePath, filePath})
|
|
63
|
-
|
|
64
64
|
messages.push(...result.messages)
|
|
65
65
|
|
|
66
66
|
if (result.messages.some((msg) => msg.logLevel === 'error')) {
|
|
67
|
+
await rimraf(tmpPath)
|
|
68
|
+
|
|
67
69
|
throw new _DtsError('encountered errors when extracting types', result.messages)
|
|
68
70
|
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const tmpPath = path.resolve(distPath, '__tmp__')
|
|
72
|
-
|
|
73
|
-
await rename(outDir, tmpPath)
|
|
74
|
-
|
|
75
|
-
for (const result of results) {
|
|
76
|
-
const fromPath = path.resolve(
|
|
77
|
-
tmpPath,
|
|
78
|
-
path.relative(outDir, path.resolve(distPath, result.filePath))
|
|
79
|
-
)
|
|
80
|
-
|
|
81
|
-
const toPath = path.resolve(distPath, result.filePath)
|
|
82
71
|
|
|
83
|
-
|
|
72
|
+
results.push({sourcePath: path.resolve(cwd, entry.sourcePath), filePath: targetPath})
|
|
84
73
|
}
|
|
85
74
|
|
|
86
75
|
await rimraf(tmpPath)
|
|
@@ -29,10 +29,10 @@ export async function _extractTypes(options: {
|
|
|
29
29
|
files: _BuildFile[]
|
|
30
30
|
projectPath: string
|
|
31
31
|
rules?: NonNullable<PkgConfigOptions['extract']>['rules']
|
|
32
|
-
|
|
32
|
+
sourceTypesPath: string
|
|
33
33
|
tsconfigPath: string
|
|
34
34
|
}): Promise<{extractorResult: ExtractorResult; messages: ExtractorMessage[]}> {
|
|
35
|
-
const {distPath, exportPath, files, filePath, projectPath, rules,
|
|
35
|
+
const {distPath, exportPath, files, filePath, projectPath, rules, sourceTypesPath, tsconfigPath} =
|
|
36
36
|
options
|
|
37
37
|
|
|
38
38
|
const tsdocConfigFile = await _createTSDocConfig({
|
|
@@ -116,8 +116,8 @@ export async function _extractTypes(options: {
|
|
|
116
116
|
exportPath,
|
|
117
117
|
filePath,
|
|
118
118
|
messages: messagesConfig,
|
|
119
|
-
projectPath,
|
|
120
|
-
|
|
119
|
+
projectFolder: projectPath,
|
|
120
|
+
mainEntryPointFilePath: sourceTypesPath,
|
|
121
121
|
tsconfigPath,
|
|
122
122
|
}),
|
|
123
123
|
configObjectFullPath: undefined,
|
package/src/node/watch.ts
CHANGED
|
@@ -33,7 +33,7 @@ export async function watch(options: {cwd: string; tsconfig?: string}): Promise<
|
|
|
33
33
|
const watchTasks = _resolveWatchTasks(ctx)
|
|
34
34
|
|
|
35
35
|
for (const task of watchTasks) {
|
|
36
|
-
const handler = _watchTaskHandlers[task.type] as _TaskHandler<_WatchTask,
|
|
36
|
+
const handler = _watchTaskHandlers[task.type] as _TaskHandler<_WatchTask, unknown>
|
|
37
37
|
const result$ = handler.exec(ctx, task)
|
|
38
38
|
|
|
39
39
|
result$.subscribe({
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_check-11811a4d.cjs","sources":["../src/node/_getFilesize.ts","../src/node/_printPackageTree.ts","../src/node/check.ts"],"sourcesContent":["import {statSync} from '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 fs from 'fs'\nimport path from 'path'\nimport chalk from 'chalk'\nimport treeify from 'treeify'\nimport {PkgExport, _BuildContext} from './_core'\nimport {_getFilesize} from './_getFilesize'\n\nexport function _fileExists(file: string): boolean {\n try {\n fs.accessSync(file)\n\n return true\n } catch (_) {\n return false\n }\n}\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 // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const tree: Record<string, any> = {}\n\n if (pkg.bin) {\n tree.bin = pkg.bin\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 `${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'> = {source: entry.source, default: entry.default}\n\n if (entry.types) exp.types = _fileInfo(entry.types)\n\n if (entry.browser) {\n exp.browser = {source: entry.browser.source}\n\n if (entry.browser.import) exp.browser.import = _fileInfo(entry.browser.import)\n if (entry.browser.require) exp.browser.import = _fileInfo(entry.browser.require)\n }\n\n if (entry.node) {\n exp.node = {source: entry.node.source}\n\n if (entry.node.import) exp.node.import = _fileInfo(entry.node.import)\n if (entry.node.require) exp.node.import = _fileInfo(entry.node.require)\n }\n\n if (entry.import) exp.import = _fileInfo(entry.import)\n if (entry.require) exp.require = _fileInfo(entry.require)\n\n exp.default = _fileInfo(entry.default)\n\n return [chalk.green(path.join(pkg.name, exportPath)), exp]\n })\n )\n\n logger.log(treeify.asTree(tree, true, true))\n}\n","/* eslint-disable no-console */\n\nimport path from 'path'\nimport chalk from 'chalk'\nimport esbuild, {BuildFailure} from 'esbuild'\nimport {_loadConfig, _loadPkgWithReporting} from './_core'\nimport {_fileExists, _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, tsconfig = 'tsconfig.json'} = options\n\n const pkg = await _loadPkgWithReporting({cwd})\n const config = await _loadConfig({cwd})\n const ctx = await _resolveBuildContext({config, cwd, pkg, 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 if (exp.types && !_fileExists(path.resolve(cwd, exp.types))) {\n missingFiles.push(exp.types)\n }\n }\n\n if (missingFiles.length) {\n throw new Error('missing files')\n }\n\n // Check if the files are resolved\n const _paths: {require: string[]; import: string[]} = {\n require: [],\n import: [],\n }\n\n for (const [exportPath, exp] of Object.entries(ctx.exports || {})) {\n if (!exp._exported) continue\n if (exp.require) _paths.require.push(exportPath)\n if (exp.import) _paths.import.push(exportPath)\n }\n\n const external = Object.keys(pkg.dependencies || {}).concat(\n Object.keys(pkg.devDependencies || {})\n )\n\n if (_paths.import.length) {\n const code = _paths.import.map((id) => `import('${id}')`).join('\\n')\n\n try {\n const esbuildResult = await esbuild.build({\n external,\n stdin: {\n contents: code,\n loader: 'js',\n resolveDir: cwd,\n },\n format: 'esm',\n bundle: true,\n logLevel: 'silent',\n // otherwise output maps to stdout as we're using stdin\n outfile: '/dev/null',\n platform: 'node',\n })\n\n if (esbuildResult.warnings.length > 0) {\n console.warn(...esbuildResult.warnings)\n }\n } catch (err) {\n const {errors} = err as BuildFailure\n\n for (const _err of errors) {\n if (_err.location) {\n console.log(chalk.red('error'), _err.detail || _err.text)\n console.log(`${_err.location.line} | ${_err.location.lineText}`)\n console.log(\n 'in',\n `./${_err.location.file}:${_err.location.line}:${_err.location.column}`\n )\n } else {\n console.log(_err.detail || _err.text)\n }\n\n console.log()\n }\n\n process.exit(1)\n }\n }\n\n if (_paths.require.length) {\n const code = _paths.require.map((id) => `require('${id}')`).join('\\n')\n\n const esbuildResult = await esbuild.build({\n external,\n stdin: {\n contents: code,\n loader: 'js',\n resolveDir: cwd,\n },\n format: 'cjs',\n bundle: true,\n // otherwise output maps to stdout as we're using stdin\n outfile: '/dev/null',\n platform: 'node',\n })\n\n if (esbuildResult.errors.length > 0) {\n throw new Error(esbuildResult.errors.join(', '))\n }\n\n if (esbuildResult.warnings.length > 0) {\n console.warn(...esbuildResult.warnings)\n }\n }\n }\n}\n"],"names":["_getFilesize","file","stats","statSync","prettyBytes","size","_fileExists","fs","accessSync","_","_getFileInfo","cwd","filePath","p","path","resolve","exists","_printPackageTree","ctx","exports","logger","pkg","log","chalk","blue","name","green","version","tree","bin","_fileInfo","info","gray","red","Object","fromEntries","entries","filter","entry","_exported","map","exportPath","exp","source","default","types","browser","import","require","node","join","treeify","asTree","check","options","strict","tsconfig","_loadPkgWithReporting","config","_loadConfig","_resolveBuildContext","missingFiles","push","length","Error","_paths","external","keys","dependencies","concat","devDependencies","code","id","esbuildResult","esbuild","build","stdin","contents","loader","resolveDir","format","bundle","logLevel","outfile","platform","warnings","console","warn","err","errors","_err","location","detail","text","line","lineText","column","process","exit"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEO,SAASA,YAAT,CAAsBC,IAAtB,EAA4B;EACjC,MAAMC,KAAK,GAAGC,WAAAA,CAASF,IAATE,CAAd;EACA,OAAOC,oBAAW,CAAA,SAAA,CAAXA,CAAYF,KAAK,CAACG,IAAlBD,CAAP;AACF;;ACAO,SAASE,WAAT,CAAqBL,IAArB,EAA2B;EAChC,IAAI;IACFM,sBAAAA,CAAGC,UAAHD,CAAcN,IAAdM;IACA,OAAO,IAAP;EACD,CAHD,CAGE,OAAOE,CAAP,EAAU;IACV,OAAO,KAAP;EACD;AACF;;AACD,SAASC,YAAT,CAAsBC,GAAtB,EAA2BC,QAA3B,EAAqC;EACnC,MAAMC,CAAC,GAAGC,aAAI,CAAA,SAAA,CAAJA,CAAKC,OAALD,CAAaH,GAAbG,EAAkBF,QAAlBE,CAAV;;EACA,MAAME,MAAM,GAAGV,WAAW,CAACO,CAAD,CAA1B;;EACA,MAAMR,IAAI,GAAGW,MAAM,GAAGhB,YAAY,CAACa,CAAD,CAAf,GAAqB,KAAK,CAA7C;EACA,OAAO;IAAEG,MAAF;IAAUX;EAAV,CAAP;AACD;;AACM,SAASY,iBAAT,CAA2BC,GAA3B,EAAgC;EACrC,MAAM;IAAEP,GAAF;IAAOQ,OAAP;IAAgBC,MAAhB;IAAwBC;EAAxB,IAAgCH,GAAtC;EACA,IAAI,CAACC,OAAL,EACE;EACFC,MAAM,CAACE,GAAP,WAAcC,cAAK,CA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