@sanity/pkg-utils 5.1.4 → 5.1.6
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 +1 -1
- package/dist/_chunks-cjs/build.cjs.map +1 -1
- package/dist/_chunks-cjs/check.cjs +1 -1
- package/dist/_chunks-cjs/check.cjs.map +1 -1
- package/dist/_chunks-cjs/consoleSpy.cjs +5 -3
- package/dist/_chunks-cjs/consoleSpy.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 +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +8 -6
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
- package/src/node/build.ts +3 -2
- package/src/node/check.ts +2 -1
- package/src/node/core/config/types.ts +4 -0
- package/src/node/core/pkg/loadPkgWithReporting.ts +16 -6
- package/src/node/watch.ts +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/pkg-utils",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.6",
|
|
4
4
|
"description": "Simple utilities for modern npm packages.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity-io",
|
|
@@ -87,11 +87,11 @@
|
|
|
87
87
|
"parse-git-config": "^3.0.0",
|
|
88
88
|
"pkg-up": "^3.1.0",
|
|
89
89
|
"prettier": "^3.2.5",
|
|
90
|
-
"prettier-plugin-packagejson": "^2.4.
|
|
90
|
+
"prettier-plugin-packagejson": "^2.4.14",
|
|
91
91
|
"pretty-bytes": "^5.6.0",
|
|
92
92
|
"prompts": "^2.4.2",
|
|
93
93
|
"rimraf": "^4.4.1",
|
|
94
|
-
"rollup": "^4.13.
|
|
94
|
+
"rollup": "^4.13.2",
|
|
95
95
|
"rollup-plugin-esbuild": "^6.1.1",
|
|
96
96
|
"rxjs": "^7.8.1",
|
|
97
97
|
"treeify": "^1.1.0",
|
|
@@ -111,8 +111,8 @@
|
|
|
111
111
|
"@types/rimraf": "^3.0.2",
|
|
112
112
|
"@types/treeify": "^1.0.3",
|
|
113
113
|
"@types/uuid": "^9.0.8",
|
|
114
|
-
"@typescript-eslint/eslint-plugin": "^7.
|
|
115
|
-
"@typescript-eslint/parser": "^7.
|
|
114
|
+
"@typescript-eslint/eslint-plugin": "^7.5.0",
|
|
115
|
+
"@typescript-eslint/parser": "^7.5.0",
|
|
116
116
|
"browserslist-to-esbuild": "2.1.1",
|
|
117
117
|
"commitizen": "^4.3.0",
|
|
118
118
|
"cpx": "^1.5.0",
|
|
@@ -132,12 +132,12 @@
|
|
|
132
132
|
"typescript": "5.4.2",
|
|
133
133
|
"vitest": "^1.4.0",
|
|
134
134
|
"vitest-github-actions-reporter": "^0.11.1",
|
|
135
|
-
"@sanity/pkg-utils": "5.1.
|
|
135
|
+
"@sanity/pkg-utils": "5.1.6"
|
|
136
136
|
},
|
|
137
137
|
"peerDependencies": {
|
|
138
138
|
"typescript": "5.4.2"
|
|
139
139
|
},
|
|
140
|
-
"packageManager": "pnpm@8.15.
|
|
140
|
+
"packageManager": "pnpm@8.15.6",
|
|
141
141
|
"engines": {
|
|
142
142
|
"node": ">=16.0.0"
|
|
143
143
|
},
|
package/src/node/build.ts
CHANGED
|
@@ -33,9 +33,10 @@ export async function build(options: {
|
|
|
33
33
|
const {cwd, emitDeclarationOnly, strict = false, tsconfig: tsconfigOption} = options
|
|
34
34
|
const logger = createLogger()
|
|
35
35
|
|
|
36
|
-
const pkg = await loadPkgWithReporting({cwd, logger, strict})
|
|
37
|
-
|
|
38
36
|
const config = await loadConfig({cwd})
|
|
37
|
+
const legacyExports = config?.legacyExports ?? false
|
|
38
|
+
const pkg = await loadPkgWithReporting({cwd, logger, strict, legacyExports})
|
|
39
|
+
|
|
39
40
|
const tsconfig = tsconfigOption || config?.tsconfig || 'tsconfig.json'
|
|
40
41
|
|
|
41
42
|
const ctx = await resolveBuildContext({
|
package/src/node/check.ts
CHANGED
|
@@ -17,8 +17,9 @@ export async function check(options: {
|
|
|
17
17
|
const {cwd, strict = false, tsconfig: tsconfigOption} = options
|
|
18
18
|
const logger = createLogger()
|
|
19
19
|
|
|
20
|
-
const pkg = await loadPkgWithReporting({cwd, logger, strict})
|
|
21
20
|
const config = await loadConfig({cwd})
|
|
21
|
+
const legacyExports = config?.legacyExports ?? false
|
|
22
|
+
const pkg = await loadPkgWithReporting({cwd, logger, strict, legacyExports})
|
|
22
23
|
const tsconfig = tsconfigOption || config?.tsconfig || 'tsconfig.json'
|
|
23
24
|
const ctx = await resolveBuildContext({config, cwd, logger, pkg, strict, tsconfig})
|
|
24
25
|
|
|
@@ -93,6 +93,10 @@ export interface PkgConfigOptions {
|
|
|
93
93
|
}
|
|
94
94
|
/**
|
|
95
95
|
* Packages to exclude from bundles.
|
|
96
|
+
* Provide an array to merge with default exclusions, use a function to replace them:
|
|
97
|
+
* ```
|
|
98
|
+
* exclude: (prev) => prev.filter(package => package !== 'foo')
|
|
99
|
+
* ```
|
|
96
100
|
*/
|
|
97
101
|
external?: PkgConfigProperty<string[]>
|
|
98
102
|
/**
|
|
@@ -11,18 +11,28 @@ export async function loadPkgWithReporting(options: {
|
|
|
11
11
|
cwd: string
|
|
12
12
|
logger: Logger
|
|
13
13
|
strict: boolean
|
|
14
|
+
legacyExports: boolean
|
|
14
15
|
}): Promise<PackageJSON> {
|
|
15
|
-
const {cwd, logger, strict} = options
|
|
16
|
+
const {cwd, logger, strict, legacyExports} = options
|
|
16
17
|
|
|
17
18
|
try {
|
|
18
19
|
const pkg = await loadPkg({cwd})
|
|
19
20
|
let shouldError = false
|
|
20
21
|
|
|
21
|
-
if (strict
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
if (strict) {
|
|
23
|
+
if (legacyExports && pkg.type === 'commonjs') {
|
|
24
|
+
shouldError = true
|
|
25
|
+
logger.error(
|
|
26
|
+
`the \`type\` field in \`./package.json\` shouldn't be "commonjs" when \`legacyExports\` is set to true)`,
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (!legacyExports && !pkg.type) {
|
|
31
|
+
shouldError = true
|
|
32
|
+
logger.error(
|
|
33
|
+
`the \`type\` field in \`./package.json\` must be either "module" or "commonjs")`,
|
|
34
|
+
)
|
|
35
|
+
}
|
|
26
36
|
}
|
|
27
37
|
|
|
28
38
|
// validate exports
|
package/src/node/watch.ts
CHANGED
|
@@ -30,8 +30,9 @@ export async function watch(options: {
|
|
|
30
30
|
throw new Error('missing package.json')
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
const pkg = await loadPkgWithReporting({cwd, logger, strict})
|
|
34
33
|
const config = await loadConfig({cwd})
|
|
34
|
+
const legacyExports = config?.legacyExports ?? false
|
|
35
|
+
const pkg = await loadPkgWithReporting({cwd, logger, strict, legacyExports})
|
|
35
36
|
const tsconfig = tsconfigOption || config?.tsconfig || 'tsconfig.json'
|
|
36
37
|
|
|
37
38
|
return resolveBuildContext({config, cwd, logger, pkg, strict, tsconfig})
|