@sanity/pkg-utils 2.3.5 → 2.3.7
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/{build-61901816.cjs → build-010eef33.cjs} +2 -2
- package/dist/_chunks/build-010eef33.cjs.map +1 -0
- package/dist/_chunks/{buildAction-2e2ae058.cjs → buildAction-82c8ffda.cjs} +2 -2
- package/dist/_chunks/{buildAction-2e2ae058.cjs.map → buildAction-82c8ffda.cjs.map} +1 -1
- package/dist/_chunks/check-0665cb35.cjs.map +1 -1
- package/dist/_chunks/checkAction-c3e5da35.cjs.map +1 -1
- package/dist/_chunks/consoleSpy-d738cb9f.cjs.map +1 -1
- package/dist/_chunks/{index-07125387.cjs → index-04fb159f.cjs} +2 -2
- package/dist/_chunks/index-04fb159f.cjs.map +1 -0
- package/dist/_chunks/{init-ab36343b.cjs → init-2377e6e5.cjs} +10 -10
- package/dist/_chunks/init-2377e6e5.cjs.map +1 -0
- package/dist/_chunks/{initAction-d18cf4f2.cjs → initAction-2abd8576.cjs} +2 -2
- package/dist/_chunks/{initAction-d18cf4f2.cjs.map → initAction-2abd8576.cjs.map} +1 -1
- package/dist/_chunks/logger-c593f06b.cjs.map +1 -1
- package/dist/_chunks/{watch-8c2aec77.cjs → watch-fdd55720.cjs} +2 -2
- package/dist/_chunks/watch-fdd55720.cjs.map +1 -0
- package/dist/_chunks/{watchAction-994967c6.cjs → watchAction-52b8ded3.cjs} +2 -2
- package/dist/_chunks/{watchAction-994967c6.cjs.map → watchAction-52b8ded3.cjs.map} +1 -1
- package/dist/cli.cjs +4 -4
- package/dist/index.cjs +4 -4
- package/dist/index.d.ts +2 -2
- package/dist/index.js +10 -10
- package/dist/index.js.map +1 -1
- package/package.json +27 -28
- package/src/node/check.ts +2 -2
- package/src/node/core/config/resolveConfigProperty.ts +1 -1
- package/src/node/core/pkg/loadPkgWithReporting.ts +4 -4
- package/src/node/core/pkg/parseExports.ts +4 -4
- package/src/node/core/pkg/validateExports.ts +3 -3
- package/src/node/core/pkg/validatePkg.ts +4 -4
- package/src/node/core/template/createFromTemplate.ts +2 -2
- package/src/node/core/template/types.ts +4 -1
- package/src/node/printExtractMessages.ts +2 -2
- package/src/node/printPackageTree.ts +3 -2
- package/src/node/resolveBuildContext.ts +1 -1
- package/src/node/resolveBuildTasks.ts +4 -4
- package/src/node/resolveWatchTasks.ts +4 -4
- package/src/node/tasks/dts/createTSDocConfig.ts +2 -2
- package/src/node/tasks/dts/doExtract.ts +2 -2
- package/src/node/tasks/dts/dtsTask.ts +1 -1
- package/src/node/tasks/dts/dtsWatchTask.ts +1 -1
- package/src/node/tasks/dts/extractTypes.ts +2 -2
- package/src/node/tasks/dts/getExtractMessagesConfig.ts +1 -1
- package/src/node/tasks/node/reexportCjsTask.ts +2 -1
- package/src/node/tasks/rollup/resolveRollupConfig.ts +6 -6
- package/src/node/tasks/rollup/rollupTask.ts +2 -2
- package/src/node/tasks/rollup/rollupWatchTask.ts +1 -1
- package/src/node/templates/default/template.ts +20 -18
- package/src/node/watch.ts +1 -1
- package/src/node/watchConfigFiles.ts +2 -2
- package/src/node/watchFiles.ts +1 -1
- package/dist/_chunks/build-61901816.cjs.map +0 -1
- package/dist/_chunks/index-07125387.cjs.map +0 -1
- package/dist/_chunks/init-ab36343b.cjs.map +0 -1
- package/dist/_chunks/watch-8c2aec77.cjs.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/pkg-utils",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.7",
|
|
4
4
|
"description": "Simple utilities for modern npm packages.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity-io",
|
|
@@ -120,26 +120,26 @@
|
|
|
120
120
|
"extends": "@sanity/semantic-release-preset"
|
|
121
121
|
},
|
|
122
122
|
"dependencies": {
|
|
123
|
-
"@babel/core": "^7.22.
|
|
124
|
-
"@babel/preset-env": "^7.22.
|
|
125
|
-
"@babel/types": "^7.22.
|
|
126
|
-
"@microsoft/api-extractor": "^7.
|
|
123
|
+
"@babel/core": "^7.22.9",
|
|
124
|
+
"@babel/preset-env": "^7.22.9",
|
|
125
|
+
"@babel/types": "^7.22.5",
|
|
126
|
+
"@microsoft/api-extractor": "^7.36.3",
|
|
127
127
|
"@microsoft/tsdoc-config": "^0.16.2",
|
|
128
128
|
"@rollup/plugin-alias": "^5.0.0",
|
|
129
129
|
"@rollup/plugin-babel": "^6.0.3",
|
|
130
|
-
"@rollup/plugin-commonjs": "^25.0.
|
|
130
|
+
"@rollup/plugin-commonjs": "^25.0.3",
|
|
131
131
|
"@rollup/plugin-json": "^6.0.0",
|
|
132
132
|
"@rollup/plugin-node-resolve": "^15.1.0",
|
|
133
133
|
"@rollup/plugin-replace": "^5.0.2",
|
|
134
134
|
"@rollup/plugin-terser": "^0.4.3",
|
|
135
|
-
"browserslist": "^4.21.
|
|
135
|
+
"browserslist": "^4.21.9",
|
|
136
136
|
"cac": "^6.7.14",
|
|
137
137
|
"chalk": "^4.1.2",
|
|
138
138
|
"chokidar": "^3.5.3",
|
|
139
|
-
"esbuild": "^0.18.
|
|
139
|
+
"esbuild": "^0.18.16",
|
|
140
140
|
"esbuild-register": "^3.4.2",
|
|
141
141
|
"find-config": "^1.0.0",
|
|
142
|
-
"get-latest-version": "^5.0
|
|
142
|
+
"get-latest-version": "^5.1.0",
|
|
143
143
|
"git-url-parse": "^13.1.0",
|
|
144
144
|
"globby": "^11.1.0",
|
|
145
145
|
"jsonc-parser": "^3.2.0",
|
|
@@ -147,13 +147,13 @@
|
|
|
147
147
|
"outdent": "^0.8.0",
|
|
148
148
|
"parse-git-config": "^3.0.0",
|
|
149
149
|
"pkg-up": "^3.1.0",
|
|
150
|
-
"prettier": "^
|
|
151
|
-
"prettier-plugin-packagejson": "^2.4.
|
|
150
|
+
"prettier": "^3.0.0",
|
|
151
|
+
"prettier-plugin-packagejson": "^2.4.5",
|
|
152
152
|
"pretty-bytes": "^5.6.0",
|
|
153
153
|
"prompts": "^2.4.2",
|
|
154
|
-
"recast": "^0.23.
|
|
155
|
-
"rimraf": "^4.4.
|
|
156
|
-
"rollup": "^3.
|
|
154
|
+
"recast": "^0.23.3",
|
|
155
|
+
"rimraf": "^4.4.1",
|
|
156
|
+
"rollup": "^3.26.3",
|
|
157
157
|
"rollup-plugin-esbuild": "^5.0.0",
|
|
158
158
|
"rxjs": "^7.8.1",
|
|
159
159
|
"treeify": "^1.1.0",
|
|
@@ -161,45 +161,44 @@
|
|
|
161
161
|
"zod": "^3.21.4"
|
|
162
162
|
},
|
|
163
163
|
"devDependencies": {
|
|
164
|
-
"@commitlint/cli": "^17.6.
|
|
165
|
-
"@commitlint/config-conventional": "^17.6.
|
|
164
|
+
"@commitlint/cli": "^17.6.7",
|
|
165
|
+
"@commitlint/config-conventional": "^17.6.7",
|
|
166
166
|
"@sanity/pkg-utils": "workspace:*",
|
|
167
167
|
"@sanity/semantic-release-preset": "4.1.2",
|
|
168
168
|
"@types/babel__core": "^7.20.1",
|
|
169
169
|
"@types/cpx": "^1.5.2",
|
|
170
170
|
"@types/find-config": "^1.0.1",
|
|
171
171
|
"@types/git-url-parse": "^9.0.1",
|
|
172
|
-
"@types/node": "^20.
|
|
172
|
+
"@types/node": "^20.4.4",
|
|
173
173
|
"@types/parse-git-config": "^3.0.1",
|
|
174
|
-
"@types/prettier": "^2.7.3",
|
|
175
174
|
"@types/prompts": "^2.4.4",
|
|
176
175
|
"@types/rimraf": "^3.0.2",
|
|
177
176
|
"@types/treeify": "^1.0.0",
|
|
178
|
-
"@types/uuid": "^9.0.
|
|
179
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
180
|
-
"@typescript-eslint/parser": "^
|
|
177
|
+
"@types/uuid": "^9.0.2",
|
|
178
|
+
"@typescript-eslint/eslint-plugin": "^6.2.0",
|
|
179
|
+
"@typescript-eslint/parser": "^6.2.0",
|
|
181
180
|
"commitizen": "^4.3.0",
|
|
182
181
|
"cpx": "^1.5.0",
|
|
183
182
|
"cz-conventional-changelog": "^3.3.0",
|
|
184
|
-
"eslint": "^8.
|
|
183
|
+
"eslint": "^8.45.0",
|
|
185
184
|
"eslint-config-prettier": "^8.8.0",
|
|
186
185
|
"eslint-plugin-import": "^2.27.5",
|
|
187
|
-
"eslint-plugin-prettier": "^
|
|
186
|
+
"eslint-plugin-prettier": "^5.0.0",
|
|
188
187
|
"eslint-plugin-simple-import-sort": "10.0.0",
|
|
189
188
|
"husky": "^8.0.3",
|
|
190
|
-
"lint-staged": "^13.2.
|
|
189
|
+
"lint-staged": "^13.2.3",
|
|
191
190
|
"npm-run-all": "^4.1.5",
|
|
192
191
|
"outdent": "^0.8.0",
|
|
193
|
-
"rollup-plugin-visualizer": "^5.9.
|
|
194
|
-
"semantic-release": "^21.0.
|
|
192
|
+
"rollup-plugin-visualizer": "^5.9.2",
|
|
193
|
+
"semantic-release": "^21.0.7",
|
|
195
194
|
"ts-node": "^10.9.1",
|
|
196
|
-
"typescript": "^5.1.
|
|
195
|
+
"typescript": "^5.1.6",
|
|
197
196
|
"vitest": "^0.33.0"
|
|
198
197
|
},
|
|
199
198
|
"peerDependencies": {
|
|
200
199
|
"typescript": "^4.7 || ^5"
|
|
201
200
|
},
|
|
202
|
-
"packageManager": "pnpm@8.6.
|
|
201
|
+
"packageManager": "pnpm@8.6.10",
|
|
203
202
|
"engines": {
|
|
204
203
|
"node": ">=16.0.0"
|
|
205
204
|
},
|
package/src/node/check.ts
CHANGED
|
@@ -85,7 +85,7 @@ export async function check(options: {
|
|
|
85
85
|
|
|
86
86
|
async function checkExports(
|
|
87
87
|
exportPaths: string[],
|
|
88
|
-
options: {cwd: string; external: string[]; format: 'esm' | 'cjs'; logger: Logger}
|
|
88
|
+
options: {cwd: string; external: string[]; format: 'esm' | 'cjs'; logger: Logger},
|
|
89
89
|
) {
|
|
90
90
|
const {cwd, external, format, logger} = options
|
|
91
91
|
|
|
@@ -148,7 +148,7 @@ function printEsbuildMessage(log: (...args: unknown[]) => void, msg: esbuild.Mes
|
|
|
148
148
|
`${msg.detail || msg.text}\n`,
|
|
149
149
|
`${msg.location.line} | ${msg.location.lineText}\n`,
|
|
150
150
|
`in ./${msg.location.file}:${msg.location.line}:${msg.location.column}`,
|
|
151
|
-
].join('')
|
|
151
|
+
].join(''),
|
|
152
152
|
)
|
|
153
153
|
} else {
|
|
154
154
|
log(msg.detail || msg.text)
|
|
@@ -33,19 +33,19 @@ export async function loadPkgWithReporting(options: {
|
|
|
33
33
|
|
|
34
34
|
if (!assertOrder('require', 'import', keys)) {
|
|
35
35
|
logger.warn(
|
|
36
|
-
`exports["${expPath}"]: the \`require\` property should come before the \`import\` property
|
|
36
|
+
`exports["${expPath}"]: the \`require\` property should come before the \`import\` property`,
|
|
37
37
|
)
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
if (!assertOrder('require', 'node', keys)) {
|
|
41
41
|
logger.warn(
|
|
42
|
-
`exports["${expPath}"]: the \`require\` property should come before the \`node\` property
|
|
42
|
+
`exports["${expPath}"]: the \`require\` property should come before the \`node\` property`,
|
|
43
43
|
)
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
if (!assertOrder('node', 'import', keys)) {
|
|
47
47
|
logger.warn(
|
|
48
|
-
`exports["${expPath}"]: the \`node\` property should come before \`import\` property
|
|
48
|
+
`exports["${expPath}"]: the \`node\` property should come before \`import\` property`,
|
|
49
49
|
)
|
|
50
50
|
}
|
|
51
51
|
|
|
@@ -65,7 +65,7 @@ export async function loadPkgWithReporting(options: {
|
|
|
65
65
|
`\`${formatPath(issue.path)}\` `,
|
|
66
66
|
`in \`./package.json\` must be of type ${chalk.magenta(issue.expected)} `,
|
|
67
67
|
`(received ${chalk.magenta(issue.received)})`,
|
|
68
|
-
].join('')
|
|
68
|
+
].join(''),
|
|
69
69
|
)
|
|
70
70
|
continue
|
|
71
71
|
}
|
|
@@ -51,25 +51,25 @@ export function parseExports(options: {
|
|
|
51
51
|
exportEntry.require !== rootExport.require
|
|
52
52
|
) {
|
|
53
53
|
errors.push(
|
|
54
|
-
'package.json: mismatch between "main" and "exports.require". These must be equal.'
|
|
54
|
+
'package.json: mismatch between "main" and "exports.require". These must be equal.',
|
|
55
55
|
)
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
if (exportEntry.import && rootExport.import && exportEntry.import !== rootExport.import) {
|
|
59
59
|
errors.push(
|
|
60
|
-
'package.json: mismatch between "module" and "exports.import" These must be equal.'
|
|
60
|
+
'package.json: mismatch between "module" and "exports.import" These must be equal.',
|
|
61
61
|
)
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
if (exportEntry.types && rootExport.types && exportEntry.types !== rootExport.types) {
|
|
65
65
|
errors.push(
|
|
66
|
-
'package.json: mismatch between "types" and "exports.types". These must be equal.'
|
|
66
|
+
'package.json: mismatch between "types" and "exports.types". These must be equal.',
|
|
67
67
|
)
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
if (exportEntry.source && rootExport.source && exportEntry.source !== rootExport.source) {
|
|
71
71
|
errors.push(
|
|
72
|
-
'package.json: mismatch between "source" and "exports.source". These must be equal.'
|
|
72
|
+
'package.json: mismatch between "source" and "exports.source". These must be equal.',
|
|
73
73
|
)
|
|
74
74
|
}
|
|
75
75
|
|
|
@@ -4,7 +4,7 @@ import {PackageJSON} from './types'
|
|
|
4
4
|
|
|
5
5
|
export function validateExports(
|
|
6
6
|
_exports: (PkgExport & {_path: string})[],
|
|
7
|
-
options: {extMap: PkgExtMap; pkg: PackageJSON}
|
|
7
|
+
options: {extMap: PkgExtMap; pkg: PackageJSON},
|
|
8
8
|
): string[] {
|
|
9
9
|
const {extMap, pkg} = options
|
|
10
10
|
const ext = extMap[pkg.type || 'commonjs']
|
|
@@ -14,13 +14,13 @@ export function validateExports(
|
|
|
14
14
|
for (const exp of _exports) {
|
|
15
15
|
if (exp.require && !exp.require.endsWith(ext.commonjs)) {
|
|
16
16
|
errors.push(
|
|
17
|
-
`package.json with \`type: "${pkg.type}"\` - \`exports["${exp._path}"].require\` must end with "${ext.commonjs}"
|
|
17
|
+
`package.json with \`type: "${pkg.type}"\` - \`exports["${exp._path}"].require\` must end with "${ext.commonjs}"`,
|
|
18
18
|
)
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
if (exp.import && !exp.import.endsWith(ext.esm)) {
|
|
22
22
|
errors.push(
|
|
23
|
-
`package.json with \`type: "${pkg.type}"\` - \`exports["${exp._path}"].import\` must end with "${ext.esm}"
|
|
23
|
+
`package.json with \`type: "${pkg.type}"\` - \`exports["${exp._path}"].import\` must end with "${ext.esm}"`,
|
|
24
24
|
)
|
|
25
25
|
}
|
|
26
26
|
}
|
|
@@ -29,20 +29,20 @@ const pkgSchema = z.object({
|
|
|
29
29
|
source: z.string(),
|
|
30
30
|
require: z.optional(z.string()),
|
|
31
31
|
import: z.optional(z.string()),
|
|
32
|
-
})
|
|
32
|
+
}),
|
|
33
33
|
),
|
|
34
34
|
node: z.optional(
|
|
35
35
|
z.object({
|
|
36
36
|
source: z.optional(z.string()),
|
|
37
37
|
require: z.optional(z.string()),
|
|
38
38
|
import: z.optional(z.string()),
|
|
39
|
-
})
|
|
39
|
+
}),
|
|
40
40
|
),
|
|
41
41
|
import: z.optional(z.string()),
|
|
42
42
|
default: z.string(),
|
|
43
43
|
}),
|
|
44
|
-
])
|
|
45
|
-
)
|
|
44
|
+
]),
|
|
45
|
+
),
|
|
46
46
|
),
|
|
47
47
|
browserslist: z.optional(z.array(z.string())),
|
|
48
48
|
})
|
|
@@ -42,7 +42,7 @@ export async function createFromTemplate(options: {
|
|
|
42
42
|
? templateOption.initial(templateOptions)
|
|
43
43
|
: templateOption.initial,
|
|
44
44
|
},
|
|
45
|
-
{onCancel: () => process.exit(0)}
|
|
45
|
+
{onCancel: () => process.exit(0)},
|
|
46
46
|
)
|
|
47
47
|
|
|
48
48
|
templateOptions[templateOption.name] = templateOption.parse
|
|
@@ -61,7 +61,7 @@ export async function createFromTemplate(options: {
|
|
|
61
61
|
message: `use ${templateFeature.name}?`,
|
|
62
62
|
initial: templateFeature.initial,
|
|
63
63
|
},
|
|
64
|
-
{onCancel: () => process.exit(0)}
|
|
64
|
+
{onCancel: () => process.exit(0)},
|
|
65
65
|
)
|
|
66
66
|
: undefined
|
|
67
67
|
|
|
@@ -11,6 +11,7 @@ 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
|
|
14
15
|
initial?: T | ((options: Record<string, any>) => T)
|
|
15
16
|
parse?: (v: string) => T | null
|
|
16
17
|
validate?: (v: string) => string | true
|
|
@@ -21,6 +22,7 @@ export type PkgTemplateOption<T = string> = PkgTemplateStringOption<T>
|
|
|
21
22
|
|
|
22
23
|
/** @public */
|
|
23
24
|
export interface PkgTemplateDefinition {
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
24
26
|
options: PkgTemplateStringOption<any>[]
|
|
25
27
|
features: {
|
|
26
28
|
name: string
|
|
@@ -28,8 +30,9 @@ export interface PkgTemplateDefinition {
|
|
|
28
30
|
initial: boolean
|
|
29
31
|
}[]
|
|
30
32
|
getFiles: (
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
31
34
|
options: Record<string, any>,
|
|
32
|
-
features: Record<string, boolean
|
|
35
|
+
features: Record<string, boolean>,
|
|
33
36
|
) => Promise<PkgTemplateFile[]>
|
|
34
37
|
}
|
|
35
38
|
|
|
@@ -30,7 +30,7 @@ export function printExtractMessages(ctx: BuildContext, messages: ExtractorMessa
|
|
|
30
30
|
` - ${chalk.yellow('warning')} ${chalk.gray(msg.messageId)}\n`,
|
|
31
31
|
msg.text,
|
|
32
32
|
'\n',
|
|
33
|
-
].join('')
|
|
33
|
+
].join(''),
|
|
34
34
|
)
|
|
35
35
|
}
|
|
36
36
|
|
|
@@ -50,7 +50,7 @@ export function printExtractMessages(ctx: BuildContext, messages: ExtractorMessa
|
|
|
50
50
|
` - ${chalk.red('error')} ${chalk.gray(msg.messageId)}\n`,
|
|
51
51
|
msg.text,
|
|
52
52
|
'\n',
|
|
53
|
-
].join('')
|
|
53
|
+
].join(''),
|
|
54
54
|
)
|
|
55
55
|
}
|
|
56
56
|
|
|
@@ -30,7 +30,7 @@ export function printPackageTree(ctx: BuildContext): void {
|
|
|
30
30
|
|
|
31
31
|
if (pkg.bin) {
|
|
32
32
|
tree.bin = Object.fromEntries(
|
|
33
|
-
Object.entries(pkg.bin).map(([name, file]) => [chalk.cyan(name), fileInfo(file)])
|
|
33
|
+
Object.entries(pkg.bin).map(([name, file]) => [chalk.cyan(name), fileInfo(file)]),
|
|
34
34
|
)
|
|
35
35
|
}
|
|
36
36
|
|
|
@@ -96,8 +96,9 @@ export function printPackageTree(ctx: BuildContext): void {
|
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
return [chalk.cyan(path.join(pkg.name, exportPath)), exp]
|
|
99
|
-
})
|
|
99
|
+
}),
|
|
100
100
|
)
|
|
101
101
|
|
|
102
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
102
103
|
logger.log(treeify.asTree(tree as Record<string, any>, true, true))
|
|
103
104
|
}
|
|
@@ -93,7 +93,7 @@ export async function resolveBuildContext(options: {
|
|
|
93
93
|
|
|
94
94
|
if (commonDistPath === cwd) {
|
|
95
95
|
throw new Error(
|
|
96
|
-
'all output files must share a common parent directory which is not the root package directory'
|
|
96
|
+
'all output files must share a common parent directory which is not the root package directory',
|
|
97
97
|
)
|
|
98
98
|
}
|
|
99
99
|
|
|
@@ -13,7 +13,7 @@ export function resolveBuildTasks(ctx: BuildContext): BuildTask[] {
|
|
|
13
13
|
const tasks: BuildTask[] = []
|
|
14
14
|
|
|
15
15
|
const exports = Object.entries(ctx.exports || {}).map(
|
|
16
|
-
([_path, exp]) => ({_path, ...exp} as PkgExport & {_path: string}
|
|
16
|
+
([_path, exp]) => ({_path, ...exp}) as PkgExport & {_path: string},
|
|
17
17
|
)
|
|
18
18
|
|
|
19
19
|
const dtsTask: DtsTask = {
|
|
@@ -140,15 +140,15 @@ export function resolveBuildTasks(ctx: BuildContext): BuildTask[] {
|
|
|
140
140
|
if (exp._exported && exp._path !== '.') {
|
|
141
141
|
const relativeTargetPath = (exp.browser?.import || exp.import || '').replace(
|
|
142
142
|
/\.[^/.]+$/,
|
|
143
|
-
''
|
|
143
|
+
'',
|
|
144
144
|
)
|
|
145
145
|
|
|
146
146
|
if (relativeTargetPath) {
|
|
147
147
|
fs.writeFileSync(
|
|
148
148
|
path.resolve(cwd, `${exp._path}.js`),
|
|
149
149
|
[`// AUTO-GENERATED – DO NOT EDIT`, `export * from '${relativeTargetPath}'`, ``].join(
|
|
150
|
-
'\n'
|
|
151
|
-
)
|
|
150
|
+
'\n',
|
|
151
|
+
),
|
|
152
152
|
)
|
|
153
153
|
}
|
|
154
154
|
}
|
|
@@ -10,7 +10,7 @@ export function resolveWatchTasks(ctx: BuildContext): WatchTask[] {
|
|
|
10
10
|
const tasks: WatchTask[] = []
|
|
11
11
|
|
|
12
12
|
const exports = Object.entries(ctx.exports || {}).map(
|
|
13
|
-
([_path, exp]) => ({_path, ...exp} as PkgExport & {_path: string}
|
|
13
|
+
([_path, exp]) => ({_path, ...exp}) as PkgExport & {_path: string},
|
|
14
14
|
)
|
|
15
15
|
|
|
16
16
|
const dtsTask: DtsWatchTask = {
|
|
@@ -115,15 +115,15 @@ export function resolveWatchTasks(ctx: BuildContext): WatchTask[] {
|
|
|
115
115
|
if (exp._exported && exp._path !== '.') {
|
|
116
116
|
const relativeTargetPath = (exp.browser?.import || exp.import || '').replace(
|
|
117
117
|
/\.[^/.]+$/,
|
|
118
|
-
''
|
|
118
|
+
'',
|
|
119
119
|
)
|
|
120
120
|
|
|
121
121
|
if (relativeTargetPath) {
|
|
122
122
|
fs.writeFileSync(
|
|
123
123
|
path.resolve(cwd, `${exp._path}.js`),
|
|
124
124
|
[`// AUTO-GENERATED – DO NOT EDIT`, `export * from '${relativeTargetPath}'`, ``].join(
|
|
125
|
-
'\n'
|
|
126
|
-
)
|
|
125
|
+
'\n',
|
|
126
|
+
),
|
|
127
127
|
)
|
|
128
128
|
}
|
|
129
129
|
}
|
|
@@ -20,7 +20,7 @@ export async function createTSDocConfig(opts: {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
const tsDocBaseBuf = await readFile(
|
|
23
|
-
require.resolve('@microsoft/api-extractor/extends/tsdoc-base.json')
|
|
23
|
+
require.resolve('@microsoft/api-extractor/extends/tsdoc-base.json'),
|
|
24
24
|
)
|
|
25
25
|
|
|
26
26
|
// Include the definitions that are required for API Extractor
|
|
@@ -33,7 +33,7 @@ export async function createTSDocConfig(opts: {
|
|
|
33
33
|
tagName: `@${t.name}`,
|
|
34
34
|
syntaxKind: t.syntaxKind,
|
|
35
35
|
allowMultiple: t.allowMultiple,
|
|
36
|
-
}))
|
|
36
|
+
})),
|
|
37
37
|
)
|
|
38
38
|
|
|
39
39
|
// Indicate that custom tags are supported by your tooling.
|
|
@@ -15,7 +15,7 @@ import {DtsResult, DtsTask, DtsWatchTask} from './types'
|
|
|
15
15
|
*/
|
|
16
16
|
export async function doExtract(
|
|
17
17
|
ctx: BuildContext,
|
|
18
|
-
task: DtsTask | DtsWatchTask
|
|
18
|
+
task: DtsTask | DtsWatchTask,
|
|
19
19
|
): Promise<DtsResult> {
|
|
20
20
|
const {config, cwd, files, logger, strict, ts} = ctx
|
|
21
21
|
|
|
@@ -41,7 +41,7 @@ export async function doExtract(
|
|
|
41
41
|
|
|
42
42
|
const sourceTypesPath = path.resolve(
|
|
43
43
|
tmpPath,
|
|
44
|
-
path.relative(rootDir, path.resolve(cwd, entry.sourcePath)).replace(/\.ts$/, '.d.ts')
|
|
44
|
+
path.relative(rootDir, path.resolve(cwd, entry.sourcePath)).replace(/\.ts$/, '.d.ts'),
|
|
45
45
|
)
|
|
46
46
|
|
|
47
47
|
const targetPath = path.resolve(cwd, entry.targetPath)
|
|
@@ -17,7 +17,7 @@ export const dtsTask: TaskHandler<DtsTask, DtsResult> = {
|
|
|
17
17
|
[
|
|
18
18
|
` - ${chalk.cyan(entry.importId)}: `,
|
|
19
19
|
`${chalk.yellow(entry.sourcePath)} ${chalk.gray('→')} ${chalk.yellow(entry.targetPath)}`,
|
|
20
|
-
].join('')
|
|
20
|
+
].join(''),
|
|
21
21
|
),
|
|
22
22
|
].join('\n'),
|
|
23
23
|
exec: (ctx, task) => {
|
|
@@ -14,7 +14,7 @@ export const dtsWatchTask: TaskHandler<DtsWatchTask, DtsResult> = {
|
|
|
14
14
|
`build type definitions`,
|
|
15
15
|
...task.entries.map(
|
|
16
16
|
(entry) =>
|
|
17
|
-
` ${chalk.blue(entry.importId)}: ${entry.sourcePath} -> ${entry.targetPath}
|
|
17
|
+
` ${chalk.blue(entry.importId)}: ${entry.sourcePath} -> ${entry.targetPath}`,
|
|
18
18
|
),
|
|
19
19
|
].join('\n'),
|
|
20
20
|
exec: (ctx, task) => {
|
|
@@ -17,7 +17,7 @@ export function getExtractMessagesConfig(options: {
|
|
|
17
17
|
|
|
18
18
|
function ruleToLogLevel(
|
|
19
19
|
key: keyof NonNullable<NonNullable<PkgConfigOptions['extract']>['rules']>,
|
|
20
|
-
defaultLevel?: ExtractorLogLevel
|
|
20
|
+
defaultLevel?: ExtractorLogLevel,
|
|
21
21
|
) {
|
|
22
22
|
const r = rules?.[key]
|
|
23
23
|
|
|
@@ -17,7 +17,7 @@ export const nodeReexportCjsTask: TaskHandler<NodeReExportFromCJSTask> = {
|
|
|
17
17
|
[
|
|
18
18
|
` - ${chalk.cyan(entry.importId)}: `,
|
|
19
19
|
`${chalk.yellow(entry.require)} ${chalk.gray('→')} ${chalk.yellow(entry.import)}`,
|
|
20
|
-
].join('')
|
|
20
|
+
].join(''),
|
|
21
21
|
),
|
|
22
22
|
].join('\n'),
|
|
23
23
|
exec: (ctx, task) => {
|
|
@@ -58,6 +58,7 @@ async function exec(ctx: BuildContext, task: NodeReExportFromCJSTask) {
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
61
62
|
function compileESMWrapper(mod: any, relativeImport: string) {
|
|
62
63
|
const keys = Object.keys(mod).filter((k) => k !== '__esModule')
|
|
63
64
|
|
|
@@ -20,7 +20,7 @@ export interface RollupConfig {
|
|
|
20
20
|
/** @internal */
|
|
21
21
|
export function resolveRollupConfig(
|
|
22
22
|
ctx: BuildContext,
|
|
23
|
-
buildTask: RollupTask | RollupWatchTask
|
|
23
|
+
buildTask: RollupTask | RollupWatchTask,
|
|
24
24
|
): RollupConfig {
|
|
25
25
|
const {format, runtime, target} = buildTask
|
|
26
26
|
const {config, cwd, exports: _exports, extMap, external, distPath, logger, pkg, ts} = ctx
|
|
@@ -31,7 +31,7 @@ export function resolveRollupConfig(
|
|
|
31
31
|
const pathAliases = Object.fromEntries(
|
|
32
32
|
Object.entries(ts.config?.options.paths || {}).map(([key, val]) => {
|
|
33
33
|
return [key, path.resolve(cwd, ts.config?.options.baseUrl || '.', val[0])]
|
|
34
|
-
})
|
|
34
|
+
}),
|
|
35
35
|
)
|
|
36
36
|
|
|
37
37
|
const entries = buildTask.entries.map((entry) => {
|
|
@@ -47,7 +47,7 @@ export function resolveRollupConfig(
|
|
|
47
47
|
const sourcePaths = _exports && Object.values(_exports).map((e) => path.resolve(cwd, e.source))
|
|
48
48
|
|
|
49
49
|
const replacements = Object.fromEntries(
|
|
50
|
-
Object.entries(config?.define || {}).map(([key, val]) => [key, JSON.stringify(val)])
|
|
50
|
+
Object.entries(config?.define || {}).map(([key, val]) => [key, JSON.stringify(val)]),
|
|
51
51
|
)
|
|
52
52
|
|
|
53
53
|
const defaultPlugins = [
|
|
@@ -69,7 +69,7 @@ export function resolveRollupConfig(
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
return JSON.stringify(
|
|
72
|
-
path.relative(cwd, path.resolve(outDir, entry.name + outputExt))
|
|
72
|
+
path.relative(cwd, path.resolve(outDir, entry.name + outputExt)),
|
|
73
73
|
)
|
|
74
74
|
},
|
|
75
75
|
'process.env.PKG_FORMAT': JSON.stringify(format),
|
|
@@ -156,8 +156,8 @@ export function resolveRollupConfig(
|
|
|
156
156
|
logger.warn(
|
|
157
157
|
`detected self-referencing import – treating as external: ${path.relative(
|
|
158
158
|
cwd,
|
|
159
|
-
idPath
|
|
160
|
-
)}
|
|
159
|
+
idPath,
|
|
160
|
+
)}`,
|
|
161
161
|
)
|
|
162
162
|
|
|
163
163
|
return true
|
|
@@ -25,7 +25,7 @@ export const rollupTask: TaskHandler<RollupTask> = {
|
|
|
25
25
|
[
|
|
26
26
|
` - `,
|
|
27
27
|
`${chalk.yellow(e.source)} ${chalk.gray('→')} ${chalk.yellow(e.output)}`,
|
|
28
|
-
].join('')
|
|
28
|
+
].join(''),
|
|
29
29
|
),
|
|
30
30
|
]
|
|
31
31
|
: []
|
|
@@ -38,7 +38,7 @@ export const rollupTask: TaskHandler<RollupTask> = {
|
|
|
38
38
|
` - `,
|
|
39
39
|
`${chalk.cyan(path.join(ctx.pkg.name, e.path))}: `,
|
|
40
40
|
`${chalk.yellow(e.source)} ${chalk.gray('→')} ${chalk.yellow(e.output)}`,
|
|
41
|
-
].join('')
|
|
41
|
+
].join(''),
|
|
42
42
|
),
|
|
43
43
|
]
|
|
44
44
|
: []
|
|
@@ -43,7 +43,7 @@ export const rollupWatchTask: TaskHandler<RollupWatchTask, RollupWatcherEvent> =
|
|
|
43
43
|
task.format
|
|
44
44
|
})\n ${task.entries
|
|
45
45
|
.map((e) => `${chalk.blue(path.join(ctx.pkg.name, e.path))}: ${e.source} -> ${e.output}`)
|
|
46
|
-
.join('\n ')}
|
|
46
|
+
.join('\n ')}`,
|
|
47
47
|
)
|
|
48
48
|
logger.log('')
|
|
49
49
|
|