@sanity/pkg-utils 6.10.2-canary.0 → 6.10.2
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 +14 -2
- package/dist/_chunks-cjs/consoleSpy.cjs.map +1 -1
- package/dist/cli.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +14 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/node/core/config/types.ts +1 -1
- package/src/node/resolveBuildContext.ts +20 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/pkg-utils",
|
|
3
|
-
"version": "6.10.2
|
|
3
|
+
"version": "6.10.2",
|
|
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.2
|
|
149
|
+
"@sanity/pkg-utils": "6.10.2"
|
|
150
150
|
},
|
|
151
151
|
"peerDependencies": {
|
|
152
152
|
"typescript": "5.4.x || 5.5.x"
|
|
@@ -180,7 +180,7 @@ export interface PkgConfigOptions {
|
|
|
180
180
|
exports?: PkgConfigProperty<PkgExports>
|
|
181
181
|
extract?: {
|
|
182
182
|
/**
|
|
183
|
-
* Packages in `external` are automatically added to the `bundledPackages` config.
|
|
183
|
+
* Packages in `devDependencies` that are not in `external` are automatically added to the `bundledPackages` config.
|
|
184
184
|
* You can exclude a package from being bundled by using a callback:
|
|
185
185
|
* ```
|
|
186
186
|
* bundledPackages: (prev) => prev.filter(package => package !== 'sanity')
|
|
@@ -117,9 +117,13 @@ export async function resolveBuildContext(options: {
|
|
|
117
117
|
? [...parsedExternal, ...config.external]
|
|
118
118
|
: resolveConfigProperty(config?.external, parsedExternal)
|
|
119
119
|
// Merge bundledPackages with dev deps, replace if it's a function
|
|
120
|
+
const externalWithTypes = new Set([pkg.name, ...external, ...external.map(transformPackageName)])
|
|
120
121
|
const bundledDependencies = [
|
|
121
122
|
...(pkg.devDependencies ? Object.keys(pkg.devDependencies) : []),
|
|
122
|
-
].filter(
|
|
123
|
+
].filter(
|
|
124
|
+
// Do not bundle anything that is marked as external
|
|
125
|
+
(_) => !externalWithTypes.has(_),
|
|
126
|
+
)
|
|
123
127
|
const bundledPackages =
|
|
124
128
|
config && Array.isArray(config.extract?.bundledPackages)
|
|
125
129
|
? [...bundledDependencies, ...config.extract.bundledPackages]
|
|
@@ -193,3 +197,18 @@ export async function resolveBuildContext(options: {
|
|
|
193
197
|
|
|
194
198
|
return ctx
|
|
195
199
|
}
|
|
200
|
+
|
|
201
|
+
function transformPackageName(packageName: string): string {
|
|
202
|
+
if (packageName.startsWith('@types/')) {
|
|
203
|
+
// If it already starts with @types, return it as is
|
|
204
|
+
return packageName
|
|
205
|
+
} else if (packageName.startsWith('@')) {
|
|
206
|
+
// Handle scoped packages
|
|
207
|
+
const [scope, name] = packageName.split('/')
|
|
208
|
+
|
|
209
|
+
return `@types/${scope.slice(1)}__${name}`
|
|
210
|
+
} else {
|
|
211
|
+
// Handle regular packages
|
|
212
|
+
return `@types/${packageName}`
|
|
213
|
+
}
|
|
214
|
+
}
|