@sanity/pkg-utils 6.10.1 → 6.10.2-canary.0
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 +4 -1
- package/dist/_chunks-cjs/consoleSpy.cjs.map +1 -1
- package/dist/_chunks-cjs/index.cjs +2 -2
- package/dist/_chunks-cjs/index.cjs.map +1 -1
- package/dist/cli.cjs +1 -1
- package/dist/index.d.cts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/node/core/config/types.ts +8 -1
- package/src/node/core/contexts/buildContext.ts +1 -0
- package/src/node/resolveBuildContext.ts +9 -0
- package/src/node/tasks/dts/doExtract.ts +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/pkg-utils",
|
|
3
|
-
"version": "6.10.
|
|
3
|
+
"version": "6.10.2-canary.0",
|
|
4
4
|
"description": "Simple utilities for modern npm packages.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity-io",
|
|
@@ -146,7 +146,7 @@
|
|
|
146
146
|
"typescript": "5.5.3",
|
|
147
147
|
"vitest": "^1.6.0",
|
|
148
148
|
"vitest-github-actions-reporter": "^0.11.1",
|
|
149
|
-
"@sanity/pkg-utils": "6.10.
|
|
149
|
+
"@sanity/pkg-utils": "6.10.2-canary.0"
|
|
150
150
|
},
|
|
151
151
|
"peerDependencies": {
|
|
152
152
|
"typescript": "5.4.x || 5.5.x"
|
|
@@ -179,7 +179,14 @@ export interface PkgConfigOptions {
|
|
|
179
179
|
dist?: string
|
|
180
180
|
exports?: PkgConfigProperty<PkgExports>
|
|
181
181
|
extract?: {
|
|
182
|
-
|
|
182
|
+
/**
|
|
183
|
+
* Packages in `external` are automatically added to the `bundledPackages` config.
|
|
184
|
+
* You can exclude a package from being bundled by using a callback:
|
|
185
|
+
* ```
|
|
186
|
+
* bundledPackages: (prev) => prev.filter(package => package !== 'sanity')
|
|
187
|
+
* ```
|
|
188
|
+
*/
|
|
189
|
+
bundledPackages?: PkgConfigProperty<string[]>
|
|
183
190
|
customTags?: TSDocCustomTag[]
|
|
184
191
|
rules?: {
|
|
185
192
|
'ae-forgotten-export'?: PkgRuleLevel
|
|
@@ -116,6 +116,14 @@ export async function resolveBuildContext(options: {
|
|
|
116
116
|
config && Array.isArray(config.external)
|
|
117
117
|
? [...parsedExternal, ...config.external]
|
|
118
118
|
: resolveConfigProperty(config?.external, parsedExternal)
|
|
119
|
+
// Merge bundledPackages with dev deps, replace if it's a function
|
|
120
|
+
const bundledDependencies = [
|
|
121
|
+
...(pkg.devDependencies ? Object.keys(pkg.devDependencies) : []),
|
|
122
|
+
].filter((_) => !parsedExternal.includes(_) && _ !== pkg.name)
|
|
123
|
+
const bundledPackages =
|
|
124
|
+
config && Array.isArray(config.extract?.bundledPackages)
|
|
125
|
+
? [...bundledDependencies, ...config.extract.bundledPackages]
|
|
126
|
+
: resolveConfigProperty(config?.extract?.bundledPackages, bundledDependencies)
|
|
119
127
|
|
|
120
128
|
const outputPaths = Object.values(exports)
|
|
121
129
|
.flatMap((exportEntry) => {
|
|
@@ -170,6 +178,7 @@ export async function resolveBuildContext(options: {
|
|
|
170
178
|
emitDeclarationOnly,
|
|
171
179
|
exports,
|
|
172
180
|
external,
|
|
181
|
+
bundledPackages,
|
|
173
182
|
files: [],
|
|
174
183
|
logger,
|
|
175
184
|
pkg,
|
|
@@ -18,7 +18,7 @@ export async function doExtract(
|
|
|
18
18
|
ctx: BuildContext,
|
|
19
19
|
task: DtsTask | DtsWatchTask,
|
|
20
20
|
): Promise<DtsResult> {
|
|
21
|
-
const {config, cwd, files, logger, strict, ts} = ctx
|
|
21
|
+
const {config, cwd, files, logger, strict, ts, bundledPackages} = ctx
|
|
22
22
|
|
|
23
23
|
if (!ts.config || !ts.configPath) {
|
|
24
24
|
return {type: 'dts', messages: [], results: []}
|
|
@@ -48,7 +48,7 @@ export async function doExtract(
|
|
|
48
48
|
const targetPaths = entry.targetPaths.map((targetPath) => path.resolve(cwd, targetPath))
|
|
49
49
|
const filePaths = targetPaths.map((targetPath) => path.relative(outDir, targetPath))
|
|
50
50
|
const result = await extractTypes({
|
|
51
|
-
bundledPackages:
|
|
51
|
+
bundledPackages: bundledPackages || [],
|
|
52
52
|
customTags: config?.extract?.customTags,
|
|
53
53
|
cwd,
|
|
54
54
|
distPath: outDir,
|