@sanity/pkg-utils 6.11.15 → 6.12.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/consoleSpy.cjs +10 -3
- package/dist/_chunks-cjs/consoleSpy.cjs.map +1 -1
- package/dist/_chunks-cjs/logger.cjs +1 -0
- package/dist/_chunks-cjs/logger.cjs.map +1 -1
- package/dist/_chunks-cjs/watch.cjs +1 -1
- package/dist/_chunks-cjs/watch.cjs.map +1 -1
- package/dist/cli.cjs +1 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +13 -5
- package/dist/index.js.map +1 -1
- package/package.json +13 -13
- package/src/node/core/pkg/parseExports.ts +16 -2
- package/src/node/core/pkg/types.ts +1 -0
- package/src/node/core/pkg/validatePkg.ts +1 -0
- package/src/node/resolveBuildContext.ts +1 -0
- package/src/node/watchFiles.ts +8 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/pkg-utils",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.12.1",
|
|
4
4
|
"description": "Simple utilities for modern npm packages.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity-io",
|
|
@@ -70,21 +70,21 @@
|
|
|
70
70
|
"@babel/core": "^7.26.0",
|
|
71
71
|
"@babel/preset-typescript": "^7.26.0",
|
|
72
72
|
"@babel/types": "^7.26.3",
|
|
73
|
-
"@microsoft/api-extractor": "7.48.
|
|
73
|
+
"@microsoft/api-extractor": "7.48.1",
|
|
74
74
|
"@microsoft/tsdoc-config": "0.17.1",
|
|
75
75
|
"@optimize-lodash/rollup-plugin": "5.0.0",
|
|
76
76
|
"@rollup/plugin-alias": "^5.1.1",
|
|
77
77
|
"@rollup/plugin-babel": "^6.0.4",
|
|
78
|
-
"@rollup/plugin-commonjs": "^28.0.
|
|
78
|
+
"@rollup/plugin-commonjs": "^28.0.2",
|
|
79
79
|
"@rollup/plugin-json": "^6.1.0",
|
|
80
|
-
"@rollup/plugin-node-resolve": "^
|
|
81
|
-
"@rollup/plugin-replace": "^6.0.
|
|
80
|
+
"@rollup/plugin-node-resolve": "^16.0.0",
|
|
81
|
+
"@rollup/plugin-replace": "^6.0.2",
|
|
82
82
|
"@rollup/plugin-terser": "^0.4.4",
|
|
83
|
-
"@sanity/browserslist-config": "^1.0.
|
|
84
|
-
"browserslist": "^4.24.
|
|
83
|
+
"@sanity/browserslist-config": "^1.0.4",
|
|
84
|
+
"browserslist": "^4.24.3",
|
|
85
85
|
"cac": "^6.7.14",
|
|
86
86
|
"chalk": "^4.1.2",
|
|
87
|
-
"chokidar": "^4.0.
|
|
87
|
+
"chokidar": "^4.0.2",
|
|
88
88
|
"esbuild": "^0.24.0",
|
|
89
89
|
"esbuild-register": "^3.6.0",
|
|
90
90
|
"find-config": "^1.0.0",
|
|
@@ -106,11 +106,11 @@
|
|
|
106
106
|
"rxjs": "^7.8.1",
|
|
107
107
|
"treeify": "^1.1.0",
|
|
108
108
|
"uuid": "^11.0.3",
|
|
109
|
-
"zod": "3.
|
|
109
|
+
"zod": "3.24.1",
|
|
110
110
|
"zod-validation-error": "3.4.0"
|
|
111
111
|
},
|
|
112
112
|
"devDependencies": {
|
|
113
|
-
"@commitlint/cli": "^19.6.
|
|
113
|
+
"@commitlint/cli": "^19.6.1",
|
|
114
114
|
"@commitlint/config-conventional": "^19.6.0",
|
|
115
115
|
"@sanity/prettier-config": "^1.0.3",
|
|
116
116
|
"@types/babel__core": "^7.20.5",
|
|
@@ -138,15 +138,15 @@
|
|
|
138
138
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
139
139
|
"husky": "^8.0.3",
|
|
140
140
|
"lint-staged": "^15.0.2",
|
|
141
|
-
"npm-run-all2": "^7.0.
|
|
141
|
+
"npm-run-all2": "^7.0.2",
|
|
142
142
|
"outdent": "^0.8.0",
|
|
143
143
|
"rollup-plugin-visualizer": "^5.12.0",
|
|
144
144
|
"semver": "^7.6.0",
|
|
145
145
|
"ts-node": "^10.9.2",
|
|
146
146
|
"typescript": "5.7.2",
|
|
147
|
-
"vitest": "^2.1.
|
|
147
|
+
"vitest": "^2.1.8",
|
|
148
148
|
"vitest-github-actions-reporter": "^0.11.1",
|
|
149
|
-
"@sanity/pkg-utils": "6.
|
|
149
|
+
"@sanity/pkg-utils": "6.12.1"
|
|
150
150
|
},
|
|
151
151
|
"peerDependencies": {
|
|
152
152
|
"babel-plugin-react-compiler": "*",
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {existsSync} from 'node:fs'
|
|
2
|
+
import {resolve as resolvePath} from 'node:path'
|
|
3
|
+
|
|
1
4
|
import type {Logger} from '../../logger'
|
|
2
5
|
import type {InferredStrictOptions} from '../../strict'
|
|
3
6
|
import {defaultEnding, fileEnding, legacyEnding} from '../../tasks/dts/getTargetPaths'
|
|
@@ -9,13 +12,14 @@ import {validateExports} from './validateExports'
|
|
|
9
12
|
|
|
10
13
|
/** @internal */
|
|
11
14
|
export function parseExports(options: {
|
|
15
|
+
cwd: string
|
|
12
16
|
pkg: PackageJSON
|
|
13
17
|
strict: boolean
|
|
14
18
|
strictOptions: InferredStrictOptions
|
|
15
19
|
legacyExports: boolean
|
|
16
20
|
logger: Logger
|
|
17
21
|
}): (PkgExport & {_path: string})[] {
|
|
18
|
-
const {pkg, strict, strictOptions, legacyExports, logger} = options
|
|
22
|
+
const {cwd, pkg, strict, strictOptions, legacyExports, logger} = options
|
|
19
23
|
const type = pkg.type || 'commonjs'
|
|
20
24
|
const errors: string[] = []
|
|
21
25
|
|
|
@@ -169,9 +173,19 @@ export function parseExports(options: {
|
|
|
169
173
|
) {
|
|
170
174
|
if (exportPath === './package.json') {
|
|
171
175
|
if (exportEntry !== './package.json') {
|
|
172
|
-
errors.push('package.json: `exports["./package.json"] must be "./package.json".')
|
|
176
|
+
errors.push('package.json: `exports["./package.json"]` must be "./package.json".')
|
|
173
177
|
}
|
|
174
178
|
}
|
|
179
|
+
} else if (exportPath.endsWith('.css')) {
|
|
180
|
+
if (typeof exportEntry === 'string' && !existsSync(resolvePath(cwd, exportEntry))) {
|
|
181
|
+
errors.push(
|
|
182
|
+
`package.json: \`exports[${JSON.stringify(exportPath)}]\`: file does not exist.`,
|
|
183
|
+
)
|
|
184
|
+
} else if (typeof exportEntry !== 'string') {
|
|
185
|
+
errors.push(
|
|
186
|
+
`package.json: \`exports[${JSON.stringify(exportPath)}]\`: export conditions not supported for CSS files.`,
|
|
187
|
+
)
|
|
188
|
+
}
|
|
175
189
|
} else if (isRecord(exportEntry) && 'svelte' in exportEntry) {
|
|
176
190
|
// @TODO should we report a warning or a debug message here about a detected svelte export that is ignored?
|
|
177
191
|
} else if (isPkgExport(exportEntry)) {
|
|
@@ -20,6 +20,7 @@ const pkgSchema = z.object({
|
|
|
20
20
|
z.record(
|
|
21
21
|
z.union([
|
|
22
22
|
z.custom<`./${string}.json`>((val) => /^\.\/.*\.json$/.test(val as string)),
|
|
23
|
+
z.custom<`./${string}.css`>((val) => /^\.\/.*\.css$/.test(val as string)),
|
|
23
24
|
z.object({
|
|
24
25
|
'types': z.optional(z.string()),
|
|
25
26
|
'source': z.optional(z.string()),
|
package/src/node/watchFiles.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import chokidar from 'chokidar'
|
|
2
|
+
import type {EventName} from 'chokidar/handler.js'
|
|
2
3
|
import {Observable} from 'rxjs'
|
|
3
4
|
|
|
4
5
|
export interface FileEvent {
|
|
5
|
-
type:
|
|
6
|
+
type: EventName
|
|
6
7
|
file: string
|
|
7
8
|
}
|
|
8
9
|
|
|
@@ -12,11 +13,12 @@ export function watchFiles(patterns: string[]): Observable<FileEvent> {
|
|
|
12
13
|
ignoreInitial: true,
|
|
13
14
|
})
|
|
14
15
|
|
|
15
|
-
function handleFileEvent(
|
|
16
|
-
type
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
function handleFileEvent(type: EventName, file: string | Error) {
|
|
17
|
+
if (type === 'error' || file instanceof Error) {
|
|
18
|
+
observer.error(file)
|
|
19
|
+
} else {
|
|
20
|
+
observer.next({type, file})
|
|
21
|
+
}
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
watcher.on('all', handleFileEvent)
|