@sanity/pkg-utils 7.2.7 → 7.2.8-canary.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks-cjs/build.cjs +2 -2
- package/dist/_chunks-cjs/build.cjs.map +1 -1
- package/dist/_chunks-cjs/check.cjs.map +1 -1
- package/dist/_chunks-cjs/consoleSpy.cjs +73 -9
- package/dist/_chunks-cjs/consoleSpy.cjs.map +1 -1
- package/dist/_chunks-cjs/handleError.cjs.map +1 -1
- package/dist/_chunks-cjs/index.cjs +36 -21
- package/dist/_chunks-cjs/index.cjs.map +1 -1
- package/dist/_chunks-cjs/init.cjs +12 -12
- package/dist/_chunks-cjs/init.cjs.map +1 -1
- package/dist/_chunks-cjs/logger.cjs +1 -71
- package/dist/_chunks-cjs/logger.cjs.map +1 -1
- package/dist/_chunks-cjs/watch.cjs +17 -2
- package/dist/_chunks-cjs/watch.cjs.map +1 -1
- package/dist/cli.cjs +2 -6
- package/dist/cli.cjs.map +1 -1
- package/dist/index.d.cts +5 -8
- package/dist/index.d.ts +5 -8
- package/dist/index.js +39 -40
- package/dist/index.js.map +1 -1
- package/package.json +11 -14
- package/src/cli/handleError.ts +0 -2
- package/src/cli/index.ts +1 -2
- package/src/global.ts +0 -1
- package/src/node/build.ts +3 -4
- package/src/node/check.ts +0 -3
- package/src/node/consoleSpy.ts +0 -2
- package/src/node/core/config/findConfigFile.ts +0 -2
- package/src/node/core/config/index.ts +3 -3
- package/src/node/core/config/loadConfig.ts +0 -3
- package/src/node/core/config/types.ts +0 -4
- package/src/node/core/contexts/buildContext.ts +2 -3
- package/src/node/core/pkg/loadPkg.ts +0 -2
- package/src/node/core/pkg/loadPkgWithReporting.ts +0 -1
- package/src/node/core/pkg/parseExports.ts +1 -2
- package/src/node/core/pkg/validateExports.ts +1 -1
- package/src/node/core/pkg/validatePkg.ts +0 -1
- package/src/node/core/template/createFromTemplate.ts +0 -2
- package/src/node/core/template/types.ts +0 -3
- package/src/node/getFilesize.ts +0 -1
- package/src/node/globFiles.ts +0 -1
- package/src/node/index.ts +64 -8
- package/src/node/init.ts +1 -3
- package/src/node/logger.ts +1 -2
- package/src/node/printExtractMessages.ts +1 -3
- package/src/node/printPackageTree.ts +2 -5
- package/src/node/resolveBuildContext.ts +12 -23
- package/src/node/resolveBuildTasks.ts +4 -3
- package/src/node/resolveWatchTasks.ts +4 -3
- package/src/node/spinner.ts +1 -2
- package/src/node/strict.test-d.ts +0 -1
- package/src/node/tasks/dts/buildTypes.ts +0 -1
- package/src/node/tasks/dts/createApiExtractorConfig.ts +0 -1
- package/src/node/tasks/dts/createTSDocConfig.ts +0 -1
- package/src/node/tasks/dts/doExtract.ts +2 -4
- package/src/node/tasks/dts/dtsTask.ts +0 -1
- package/src/node/tasks/dts/dtsWatchTask.ts +1 -3
- package/src/node/tasks/dts/extractTypes.ts +3 -4
- package/src/node/tasks/dts/getExtractMessagesConfig.ts +1 -2
- package/src/node/tasks/dts/getTargetPaths.ts +2 -2
- package/src/node/tasks/dts/printDiagnostic.ts +0 -2
- package/src/node/tasks/index.ts +4 -2
- package/src/node/tasks/rollup/resolveRollupConfig.ts +10 -11
- package/src/node/tasks/rollup/rollupTask.ts +1 -4
- package/src/node/tasks/rollup/rollupWatchTask.ts +1 -3
- package/src/node/tasks/types.ts +3 -3
- package/src/node/templates/default/template.ts +20 -23
- package/src/node/watch.ts +2 -3
- package/src/node/watchConfigFiles.ts +0 -2
- package/src/node/watchFiles.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/pkg-utils",
|
|
3
|
-
"version": "7.2.
|
|
3
|
+
"version": "7.2.8-canary.1",
|
|
4
4
|
"description": "Simple utilities for modern npm packages.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity-io",
|
|
@@ -59,13 +59,15 @@
|
|
|
59
59
|
]
|
|
60
60
|
},
|
|
61
61
|
"lint-staged": {
|
|
62
|
+
"*.{js,jsx,ts,tsx,mjs,cjs}": [
|
|
63
|
+
"prettier --cache --write",
|
|
64
|
+
"oxlint --fix --quiet"
|
|
65
|
+
],
|
|
62
66
|
"*": [
|
|
63
|
-
"prettier --write --cache --ignore-unknown"
|
|
64
|
-
"eslint --ext .cjs,.js,.ts,.tsx --fix"
|
|
67
|
+
"prettier --write --cache --ignore-unknown"
|
|
65
68
|
]
|
|
66
69
|
},
|
|
67
70
|
"browserslist": "extends @sanity/browserslist-config",
|
|
68
|
-
"prettier": "@sanity/prettier-config",
|
|
69
71
|
"dependencies": {
|
|
70
72
|
"@babel/core": "^7.27.4",
|
|
71
73
|
"@babel/preset-typescript": "^7.27.1",
|
|
@@ -111,6 +113,7 @@
|
|
|
111
113
|
"devDependencies": {
|
|
112
114
|
"@commitlint/cli": "^19.8.1",
|
|
113
115
|
"@commitlint/config-conventional": "^19.8.1",
|
|
116
|
+
"@ianvs/prettier-plugin-sort-imports": "^4.4.2",
|
|
114
117
|
"@sanity/prettier-config": "^1.0.4",
|
|
115
118
|
"@types/babel__core": "^7.20.5",
|
|
116
119
|
"@types/cpx": "^1.5.5",
|
|
@@ -122,27 +125,21 @@
|
|
|
122
125
|
"@types/semver": "^7.5.8",
|
|
123
126
|
"@types/treeify": "^1.0.3",
|
|
124
127
|
"@types/uuid": "^10.0.0",
|
|
125
|
-
"@typescript-eslint/eslint-plugin": "^8.34.1",
|
|
126
|
-
"@typescript-eslint/parser": "^8.34.1",
|
|
127
128
|
"browserslist-to-esbuild": "2.1.1",
|
|
128
129
|
"commitizen": "^4.3.1",
|
|
129
130
|
"cpx": "^1.5.0",
|
|
130
131
|
"cz-conventional-changelog": "^3.3.0",
|
|
131
|
-
"eslint": "^8.57.1",
|
|
132
|
-
"eslint-config-prettier": "^10.1.5",
|
|
133
|
-
"eslint-plugin-import": "^2.31.0",
|
|
134
|
-
"eslint-plugin-prettier": "^5.5.0",
|
|
135
|
-
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
136
132
|
"husky": "^8.0.3",
|
|
137
133
|
"lint-staged": "^15.0.2",
|
|
138
134
|
"npm-run-all2": "^8.0.4",
|
|
139
135
|
"outdent": "^0.8.0",
|
|
136
|
+
"oxlint": "^1.1.0",
|
|
140
137
|
"rollup-plugin-visualizer": "^6.0.3",
|
|
141
138
|
"semver": "^7.6.0",
|
|
142
139
|
"ts-node": "^10.9.2",
|
|
143
140
|
"typescript": "5.8.3",
|
|
144
141
|
"vitest": "^3.2.4",
|
|
145
|
-
"@sanity/pkg-utils": "7.2.
|
|
142
|
+
"@sanity/pkg-utils": "7.2.8-canary.1"
|
|
146
143
|
},
|
|
147
144
|
"peerDependencies": {
|
|
148
145
|
"babel-plugin-react-compiler": "*",
|
|
@@ -167,8 +164,8 @@
|
|
|
167
164
|
"clean": "rimraf dist test/env/__tmp__",
|
|
168
165
|
"commit": "cz",
|
|
169
166
|
"extract": "sanity-tsdoc etl --outDir etc/api/@sanity/pkg-utils --tsconfig tsconfig.dist.json",
|
|
170
|
-
"format": "prettier --write --cache --ignore-unknown . &&
|
|
171
|
-
"lint": "
|
|
167
|
+
"format": "prettier --write --cache --ignore-unknown . && oxlint --fix --quiet",
|
|
168
|
+
"lint": "oxlint",
|
|
172
169
|
"playground:build": "pnpm --filter './playground/**' build",
|
|
173
170
|
"playground:clean": "pnpm --filter './playground/**' --silent clean",
|
|
174
171
|
"pretest": "run-s playground:clean",
|
package/src/cli/handleError.ts
CHANGED
package/src/cli/index.ts
CHANGED
package/src/global.ts
CHANGED
package/src/node/build.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
|
-
|
|
3
|
-
import rimraf from 'rimraf'
|
|
4
|
-
|
|
2
|
+
import {rimraf} from 'rimraf'
|
|
5
3
|
import {loadConfig, loadPkgWithReporting} from './core'
|
|
6
4
|
import {createLogger} from './logger'
|
|
7
5
|
import {resolveBuildContext} from './resolveBuildContext'
|
|
8
6
|
import {resolveBuildTasks} from './resolveBuildTasks'
|
|
9
7
|
import {createSpinner} from './spinner'
|
|
10
|
-
import {
|
|
8
|
+
import {buildTaskHandlers} from './tasks'
|
|
9
|
+
import {type BuildTask, type TaskHandler} from './tasks/types'
|
|
11
10
|
|
|
12
11
|
/**
|
|
13
12
|
* Build the distribution files of a npm package.
|
package/src/node/check.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
|
-
|
|
3
2
|
import esbuild, {type BuildFailure, type Message} from 'esbuild'
|
|
4
|
-
|
|
5
3
|
import {createConsoleSpy} from './consoleSpy'
|
|
6
4
|
import {loadConfig, loadPkgWithReporting} from './core'
|
|
7
5
|
import {fileExists} from './fileExists'
|
|
@@ -120,7 +118,6 @@ async function checkExports(
|
|
|
120
118
|
}
|
|
121
119
|
|
|
122
120
|
const esbuildWarnings = esbuildResult.warnings.filter((msg) => {
|
|
123
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
124
121
|
!(msg.detail || msg.text).includes(`does not affect esbuild's own target setting`)
|
|
125
122
|
})
|
|
126
123
|
|
package/src/node/consoleSpy.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
1
|
+
export {defineConfig} from './defineConfig'
|
|
2
|
+
export {loadConfig} from './loadConfig'
|
|
3
|
+
export {resolveConfigProperty} from './resolveConfigProperty'
|
|
4
4
|
export * from './types'
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
|
-
|
|
3
2
|
import {register} from 'esbuild-register/dist/node'
|
|
4
3
|
import pkgUp from 'pkg-up'
|
|
5
|
-
|
|
6
4
|
import {findConfigFile} from './findConfigFile'
|
|
7
5
|
import type {PkgConfigOptions} from './types'
|
|
8
6
|
|
|
@@ -31,7 +29,6 @@ export async function loadConfig(options: {cwd: string}): Promise<PkgConfigOptio
|
|
|
31
29
|
|
|
32
30
|
const {unregister} = globalThis.__DEV__ ? {unregister: () => undefined} : register(esbuildOptions)
|
|
33
31
|
|
|
34
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports
|
|
35
32
|
const mod = require(configFile)
|
|
36
33
|
|
|
37
34
|
unregister()
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import type {PluginItem as BabelPluginItem} from '@babel/core'
|
|
2
2
|
import type {OptimizeLodashOptions} from '@optimize-lodash/rollup-plugin'
|
|
3
3
|
import type {NormalizedOutputOptions, Plugin as RollupPlugin, TreeshakingOptions} from 'rollup'
|
|
4
|
-
|
|
5
4
|
import type {StrictOptions} from '../../strict'
|
|
6
5
|
|
|
7
|
-
// re-export
|
|
8
|
-
export type {RollupPlugin, StrictOptions}
|
|
9
|
-
|
|
10
6
|
/** @public */
|
|
11
7
|
export type PkgFormat = 'commonjs' | 'esm'
|
|
12
8
|
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type ts from 'typescript'
|
|
2
|
-
|
|
3
2
|
import type {Logger} from '../../logger'
|
|
4
|
-
import type {PkgConfigOptions, PkgExports, PkgRuntime} from '../config'
|
|
5
|
-
import type {PackageJSON} from '../pkg'
|
|
3
|
+
import type {PkgConfigOptions, PkgExports, PkgRuntime} from '../config/types'
|
|
4
|
+
import type {PackageJSON} from '../pkg/types'
|
|
6
5
|
|
|
7
6
|
/** @internal */
|
|
8
7
|
export interface BuildFile {
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import {existsSync} from 'node:fs'
|
|
2
2
|
import {resolve as resolvePath} from 'node:path'
|
|
3
|
-
|
|
4
3
|
import type {Logger} from '../../logger'
|
|
5
4
|
import type {InferredStrictOptions} from '../../strict'
|
|
6
5
|
import {defaultEnding, fileEnding} from '../../tasks/dts/getTargetPaths'
|
|
7
|
-
import type {PkgExport} from '../config'
|
|
6
|
+
import type {PkgExport} from '../config/types'
|
|
8
7
|
import {isRecord} from '../isRecord'
|
|
9
8
|
import {pkgExtMap} from './pkgExt'
|
|
10
9
|
import type {PackageJSON} from './types'
|
|
@@ -11,7 +11,6 @@ export interface PkgTemplateStringOption<T = string> {
|
|
|
11
11
|
name: string
|
|
12
12
|
type: 'string'
|
|
13
13
|
description: string
|
|
14
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
14
|
initial?: T | ((options: Record<string, any>) => T)
|
|
16
15
|
parse?: (v: string) => T | null
|
|
17
16
|
validate?: (v: string) => string | true
|
|
@@ -22,7 +21,6 @@ export type PkgTemplateOption<T = string> = PkgTemplateStringOption<T>
|
|
|
22
21
|
|
|
23
22
|
/** @public */
|
|
24
23
|
export interface PkgTemplateDefinition {
|
|
25
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
26
24
|
options: PkgTemplateStringOption<any>[]
|
|
27
25
|
features: {
|
|
28
26
|
name: string
|
|
@@ -30,7 +28,6 @@ export interface PkgTemplateDefinition {
|
|
|
30
28
|
initial: boolean
|
|
31
29
|
}[]
|
|
32
30
|
getFiles: (
|
|
33
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
34
31
|
options: Record<string, any>,
|
|
35
32
|
features: Record<string, boolean>,
|
|
36
33
|
) => Promise<PkgTemplateFile[]>
|
package/src/node/getFilesize.ts
CHANGED
package/src/node/globFiles.ts
CHANGED
package/src/node/index.ts
CHANGED
|
@@ -1,15 +1,71 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
1
|
+
export {build} from './build'
|
|
2
|
+
export {check} from './check'
|
|
3
|
+
export {defineConfig} from './core/config/defineConfig'
|
|
4
|
+
export {loadConfig} from './core/config/loadConfig'
|
|
5
|
+
export {resolveConfigProperty} from './core/config/resolveConfigProperty'
|
|
6
|
+
export type {
|
|
7
|
+
PkgFormat,
|
|
8
|
+
PkgRuntime,
|
|
9
|
+
PkgExport,
|
|
10
|
+
PkgConfigPropertyResolver,
|
|
11
|
+
PkgConfigProperty,
|
|
12
|
+
PkgBundle,
|
|
13
|
+
PkgExports,
|
|
14
|
+
PkgRuleLevel,
|
|
15
|
+
TSDocCustomTag,
|
|
16
|
+
ReactCompilerOptions,
|
|
17
|
+
ReactCompilerLoggerEvent,
|
|
18
|
+
ReactCompilerLogger,
|
|
19
|
+
PkgConfigOptions,
|
|
20
|
+
} from './core/config/types'
|
|
21
|
+
export type {BuildFile, BuildContext} from './core/contexts/buildContext'
|
|
22
|
+
export {DEFAULT_BROWSERSLIST_QUERY} from './core/defaults'
|
|
23
|
+
export * from './core/isRecord'
|
|
24
|
+
export {loadPkg} from './core/pkg/loadPkg'
|
|
25
|
+
export {loadPkgWithReporting} from './core/pkg/loadPkgWithReporting'
|
|
26
|
+
export {parseExports} from './core/pkg/parseExports'
|
|
27
|
+
export {type PkgExtMap, pkgExtMap} from './core/pkg/pkgExt'
|
|
28
|
+
export * from './core/pkg/types'
|
|
29
|
+
export {createFromTemplate} from './core/template/createFromTemplate'
|
|
30
|
+
export {defineTemplateOption} from './core/template/define'
|
|
7
31
|
export {
|
|
32
|
+
type PkgTemplateFile,
|
|
33
|
+
type PkgTemplateStringOption,
|
|
34
|
+
type PkgTemplateOption,
|
|
35
|
+
type PkgTemplateDefinition,
|
|
36
|
+
type PkgTemplateResolver,
|
|
37
|
+
type PkgTemplate,
|
|
38
|
+
} from './core/template/types'
|
|
39
|
+
export {loadTSConfig} from './core/ts/loadTSConfig'
|
|
40
|
+
|
|
41
|
+
export {init} from './init'
|
|
42
|
+
export {type Logger, createLogger} from './logger'
|
|
43
|
+
export {resolveBuildTasks} from './resolveBuildTasks'
|
|
44
|
+
export {
|
|
45
|
+
type StrictOptions,
|
|
8
46
|
type InferredStrictOptions,
|
|
9
47
|
parseStrictOptions,
|
|
10
48
|
strictOptions,
|
|
11
49
|
toggle,
|
|
12
50
|
type ToggleType,
|
|
13
51
|
} from './strict'
|
|
14
|
-
export
|
|
15
|
-
export
|
|
52
|
+
export {buildTaskHandlers, watchTaskHandlers} from './tasks'
|
|
53
|
+
export {dtsTask} from './tasks/dts/dtsTask'
|
|
54
|
+
export {dtsWatchTask} from './tasks/dts/dtsWatchTask'
|
|
55
|
+
export {getExtractMessagesConfig} from './tasks/dts/getExtractMessagesConfig'
|
|
56
|
+
export type {DtsWatchTask, DtsTask, DtsResult} from './tasks/dts/types'
|
|
57
|
+
export {rollupTask} from './tasks/rollup/rollupTask'
|
|
58
|
+
export {rollupWatchTask} from './tasks/rollup/rollupWatchTask'
|
|
59
|
+
export type {
|
|
60
|
+
RollupTaskEntry,
|
|
61
|
+
RollupTask,
|
|
62
|
+
RollupWatchTask,
|
|
63
|
+
BuildTask,
|
|
64
|
+
WatchTask,
|
|
65
|
+
TaskHandler,
|
|
66
|
+
BuildTaskHandlers,
|
|
67
|
+
WatchTaskHandlers,
|
|
68
|
+
} from './tasks/types'
|
|
69
|
+
export {watch} from './watch'
|
|
70
|
+
|
|
71
|
+
export type {Plugin as RollupPlugin} from 'rollup'
|
package/src/node/init.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import {lstat} from 'node:fs/promises'
|
|
2
2
|
import {resolve} from 'node:path'
|
|
3
|
-
|
|
4
3
|
import {mkdirp} from 'mkdirp'
|
|
5
|
-
|
|
6
4
|
import {createFromTemplate} from './core/template'
|
|
7
5
|
import {fileExists} from './fileExists'
|
|
8
6
|
import {isEmptyDirectory} from './isEmptyDirectory'
|
|
9
7
|
import {createLogger} from './logger'
|
|
10
|
-
import {defaultTemplate} from './templates'
|
|
8
|
+
import {defaultTemplate} from './templates/default/template'
|
|
11
9
|
|
|
12
10
|
/** @public */
|
|
13
11
|
export async function init(options: {cwd: string; path: string}): Promise<void> {
|
package/src/node/logger.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// oxlint-disable no-console
|
|
1
2
|
import chalk from 'chalk'
|
|
2
3
|
|
|
3
4
|
/** @internal */
|
|
@@ -12,7 +13,6 @@ export interface Logger {
|
|
|
12
13
|
/** @internal */
|
|
13
14
|
export function createLogger(): Logger {
|
|
14
15
|
return {
|
|
15
|
-
/* eslint-disable no-console */
|
|
16
16
|
log: (...args) => {
|
|
17
17
|
console.log(...args)
|
|
18
18
|
},
|
|
@@ -28,6 +28,5 @@ export function createLogger(): Logger {
|
|
|
28
28
|
success: (...args) => {
|
|
29
29
|
console.log(chalk.green('[success]'), ...args)
|
|
30
30
|
},
|
|
31
|
-
/* eslint-enable no-console */
|
|
32
31
|
}
|
|
33
32
|
}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
|
-
|
|
3
2
|
import type {ExtractorMessage} from '@microsoft/api-extractor'
|
|
4
3
|
import chalk from 'chalk'
|
|
5
|
-
|
|
6
|
-
import type {BuildContext} from './core'
|
|
4
|
+
import type {BuildContext} from './core/contexts/buildContext'
|
|
7
5
|
|
|
8
6
|
export function printExtractMessages(ctx: BuildContext, messages: ExtractorMessage[]): void {
|
|
9
7
|
const {cwd, logger} = ctx
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
|
-
|
|
3
2
|
import chalk from 'chalk'
|
|
4
3
|
import treeify from 'treeify'
|
|
5
|
-
|
|
6
|
-
import type {BuildContext
|
|
4
|
+
import type {PkgExport} from './core/config/types'
|
|
5
|
+
import type {BuildContext} from './core/contexts/buildContext'
|
|
7
6
|
import {fileExists} from './fileExists'
|
|
8
7
|
import {getFilesize} from './getFilesize'
|
|
9
8
|
|
|
@@ -22,7 +21,6 @@ export function printPackageTree(ctx: BuildContext): void {
|
|
|
22
21
|
|
|
23
22
|
logger.log(`${chalk.blue(pkg.name)}@${chalk.green(pkg.version)}`)
|
|
24
23
|
|
|
25
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
26
24
|
const tree: Record<string, unknown> = {}
|
|
27
25
|
|
|
28
26
|
if (pkg.type) {
|
|
@@ -93,6 +91,5 @@ export function printPackageTree(ctx: BuildContext): void {
|
|
|
93
91
|
}),
|
|
94
92
|
)
|
|
95
93
|
|
|
96
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
97
94
|
logger.log(treeify.asTree(tree as Record<string, any>, true, true))
|
|
98
95
|
}
|
|
@@ -1,19 +1,13 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
|
-
|
|
3
2
|
import browserslistToEsbuild from 'browserslist-to-esbuild'
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
type PackageJSON,
|
|
10
|
-
parseExports,
|
|
11
|
-
type PkgConfigOptions,
|
|
12
|
-
type PkgExports,
|
|
13
|
-
type PkgRuntime,
|
|
14
|
-
resolveConfigProperty,
|
|
15
|
-
} from './core'
|
|
3
|
+
import {loadTSConfig} from './core'
|
|
4
|
+
import {resolveConfigProperty} from './core/config/resolveConfigProperty'
|
|
5
|
+
import {type PkgConfigOptions, type PkgExports, type PkgRuntime} from './core/config/types'
|
|
6
|
+
import type {BuildContext} from './core/contexts/buildContext'
|
|
7
|
+
import {DEFAULT_BROWSERSLIST_QUERY} from './core/defaults'
|
|
16
8
|
import {findCommonDirPath, pathContains} from './core/findCommonPath'
|
|
9
|
+
import {parseExports} from './core/pkg/parseExports'
|
|
10
|
+
import type {PackageJSON} from './core/pkg/types'
|
|
17
11
|
import type {Logger} from './logger'
|
|
18
12
|
import {resolveBrowserTarget} from './resolveBrowserTarget'
|
|
19
13
|
import {resolveNodeTarget} from './resolveNodeTarget'
|
|
@@ -40,7 +34,6 @@ export async function resolveBuildContext(options: {
|
|
|
40
34
|
const tsconfig = await loadTSConfig({cwd, tsconfigPath})
|
|
41
35
|
const strictOptions = parseStrictOptions(config?.strictOptions ?? {})
|
|
42
36
|
|
|
43
|
-
/* eslint-disable padding-line-between-statements */
|
|
44
37
|
let browserslist = pkg.browserslist
|
|
45
38
|
if (!browserslist) {
|
|
46
39
|
if (strict && strictOptions.noImplicitBrowsersList !== 'off') {
|
|
@@ -58,7 +51,6 @@ export async function resolveBuildContext(options: {
|
|
|
58
51
|
browserslist = DEFAULT_BROWSERSLIST_QUERY
|
|
59
52
|
}
|
|
60
53
|
const targetVersions = browserslistToEsbuild(browserslist)
|
|
61
|
-
/* eslint-enable padding-line-between-statements */
|
|
62
54
|
|
|
63
55
|
if (
|
|
64
56
|
strict &&
|
|
@@ -98,11 +90,10 @@ export async function resolveBuildContext(options: {
|
|
|
98
90
|
strict,
|
|
99
91
|
strictOptions,
|
|
100
92
|
logger,
|
|
101
|
-
}).reduce<PkgExports>(
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}, {})
|
|
93
|
+
}).reduce<PkgExports>(
|
|
94
|
+
(acc, {_path: exportPath, ...exportEntry}) => Object.assign(acc, {[exportPath]: exportEntry}),
|
|
95
|
+
{},
|
|
96
|
+
)
|
|
106
97
|
|
|
107
98
|
const exports = resolveConfigProperty(config?.exports, parsedExports)
|
|
108
99
|
|
|
@@ -118,9 +109,7 @@ export async function resolveBuildContext(options: {
|
|
|
118
109
|
: resolveConfigProperty(config?.external, parsedExternal)
|
|
119
110
|
// Merge bundledPackages with dev deps, replace if it's a function
|
|
120
111
|
const externalWithTypes = new Set([pkg.name, ...external, ...external.map(transformPackageName)])
|
|
121
|
-
const bundledDependencies = [
|
|
122
|
-
...(pkg.devDependencies ? Object.keys(pkg.devDependencies) : []),
|
|
123
|
-
].filter(
|
|
112
|
+
const bundledDependencies = (pkg.devDependencies ? Object.keys(pkg.devDependencies) : []).filter(
|
|
124
113
|
// Do not bundle anything that is marked as external
|
|
125
114
|
(_) => !externalWithTypes.has(_),
|
|
126
115
|
)
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
|
-
|
|
3
|
-
import type {BuildContext
|
|
4
|
-
import type {BuildTask, DtsTask, RollupTask, RollupTaskEntry} from './tasks'
|
|
2
|
+
import type {PkgExport, PkgFormat, PkgRuntime} from './core/config/types'
|
|
3
|
+
import type {BuildContext} from './core/contexts/buildContext'
|
|
5
4
|
import {getTargetPaths} from './tasks/dts/getTargetPaths'
|
|
5
|
+
import type {DtsTask} from './tasks/dts/types'
|
|
6
|
+
import type {BuildTask, RollupTask, RollupTaskEntry} from './tasks/types'
|
|
6
7
|
|
|
7
8
|
/** @internal */
|
|
8
9
|
export function resolveBuildTasks(ctx: BuildContext): BuildTask[] {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
|
-
|
|
3
|
-
import type {BuildContext
|
|
4
|
-
import type {DtsWatchTask, RollupTaskEntry, RollupWatchTask, WatchTask} from './tasks'
|
|
2
|
+
import type {PkgExport, PkgFormat, PkgRuntime} from './core/config/types'
|
|
3
|
+
import type {BuildContext} from './core/contexts/buildContext'
|
|
5
4
|
import {getTargetPaths} from './tasks/dts/getTargetPaths'
|
|
5
|
+
import type {DtsWatchTask} from './tasks/dts/types'
|
|
6
|
+
import type {RollupTaskEntry, RollupWatchTask, WatchTask} from './tasks/types'
|
|
6
7
|
|
|
7
8
|
/** @internal */
|
|
8
9
|
export function resolveWatchTasks(ctx: BuildContext): WatchTask[] {
|
package/src/node/spinner.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
|
-
|
|
3
2
|
import type {ExtractorMessage} from '@microsoft/api-extractor'
|
|
4
|
-
import rimraf from 'rimraf'
|
|
5
|
-
|
|
6
|
-
import type {BuildContext} from '../../core'
|
|
3
|
+
import {rimraf} from 'rimraf'
|
|
4
|
+
import type {BuildContext} from '../../core/contexts/buildContext'
|
|
7
5
|
import {buildTypes} from './buildTypes'
|
|
8
6
|
import {DtsError} from './DtsError'
|
|
9
7
|
import {extractTypes} from './extractTypes'
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
|
-
|
|
3
2
|
import type {ExtractorMessage} from '@microsoft/api-extractor'
|
|
4
3
|
import chalk from 'chalk'
|
|
5
|
-
import rimraf from 'rimraf'
|
|
4
|
+
import * as rimraf from 'rimraf'
|
|
6
5
|
import {Observable} from 'rxjs'
|
|
7
6
|
import ts from 'typescript'
|
|
8
|
-
|
|
9
7
|
import {printExtractMessages} from '../../printExtractMessages'
|
|
10
8
|
import type {TaskHandler} from '../types'
|
|
11
9
|
import {buildTypes} from './buildTypes'
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import fs from 'node:fs/promises'
|
|
2
2
|
import path from 'node:path'
|
|
3
|
-
|
|
4
3
|
import {
|
|
5
4
|
Extractor,
|
|
6
5
|
ExtractorConfig,
|
|
@@ -8,10 +7,10 @@ import {
|
|
|
8
7
|
type ExtractorResult,
|
|
9
8
|
} from '@microsoft/api-extractor'
|
|
10
9
|
import {mkdirp} from 'mkdirp'
|
|
11
|
-
import prettier from 'prettier'
|
|
10
|
+
import * as prettier from 'prettier'
|
|
12
11
|
import type ts from 'typescript'
|
|
13
|
-
|
|
14
|
-
import type {BuildFile
|
|
12
|
+
import type {PkgConfigOptions} from '../../core/config/types'
|
|
13
|
+
import type {BuildFile} from '../../core/contexts/buildContext'
|
|
15
14
|
import {createApiExtractorConfig} from './createApiExtractorConfig'
|
|
16
15
|
import {createTSDocConfig} from './createTSDocConfig'
|
|
17
16
|
import {extractModuleBlocksFromTypes} from './extractModuleBlocks'
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type {ExtractorLogLevel, IExtractorMessagesConfig} from '@microsoft/api-extractor'
|
|
2
|
-
|
|
3
|
-
import type {PkgConfigOptions, PkgRuleLevel} from '../../core'
|
|
2
|
+
import type {PkgConfigOptions, PkgRuleLevel} from '../../core/config/types'
|
|
4
3
|
|
|
5
4
|
const LOG_LEVELS: Record<PkgRuleLevel, ExtractorLogLevel> = {
|
|
6
5
|
error: 'error' as ExtractorLogLevel.Error,
|