@sanity/pkg-utils 5.1.9 → 5.1.11

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/pkg-utils",
3
- "version": "5.1.9",
3
+ "version": "5.1.11",
4
4
  "description": "Simple utilities for modern npm packages.",
5
5
  "keywords": [
6
6
  "sanity-io",
@@ -132,7 +132,7 @@
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.9"
135
+ "@sanity/pkg-utils": "5.1.11"
136
136
  },
137
137
  "peerDependencies": {
138
138
  "typescript": "5.4.2"
@@ -1,6 +1,6 @@
1
- import {PkgConfigOptions} from './types'
1
+ import type {PkgConfigOptions} from './types'
2
2
 
3
3
  /** @public */
4
- export function defineConfig(configOptions: PkgConfigOptions): PkgConfigOptions {
4
+ export function defineConfig<const T extends PkgConfigOptions>(configOptions: T): T {
5
5
  return configOptions
6
6
  }
@@ -171,8 +171,8 @@ export function resolveBuildTasks(ctx: BuildContext): BuildTask[] {
171
171
  // Create rollup bundles that legacy export files will re-export
172
172
  if (config?.legacyExports) {
173
173
  for (const exp of exports) {
174
- const runtime = exp.browser?.import || exp.browser?.require ? 'browser' : ctx.runtime
175
- const output = exp.browser?.import || exp.import || exp.browser?.require || exp.require
174
+ const runtime = exp.browser?.import ? 'browser' : ctx.runtime
175
+ const output = exp.browser?.import || exp.import
176
176
 
177
177
  if (!output) continue
178
178
 
@@ -213,13 +213,7 @@ export function resolveBuildTasks(ctx: BuildContext): BuildTask[] {
213
213
  if (config?.legacyExports) {
214
214
  for (const exp of exports) {
215
215
  if (exp._exported && exp._path !== '.') {
216
- const output = (
217
- exp.browser?.import ||
218
- exp.import ||
219
- exp.browser?.require ||
220
- exp.require ||
221
- ''
222
- ).replace(fileEnding, legacyEnding)
216
+ const output = (exp.browser?.import || exp.import || '').replace(fileEnding, legacyEnding)
223
217
  const relativeTargetPath = output.replace(/\.[^/.]+$/, '')
224
218
 
225
219
  if (relativeTargetPath) {
@@ -196,6 +196,7 @@ export function resolveRollupConfig(
196
196
  treeshake: {
197
197
  preset: 'recommended',
198
198
  propertyReadSideEffects: false,
199
+ moduleSideEffects: 'no-external',
199
200
  ...config?.rollup?.treeshake,
200
201
  },
201
202
  experimentalLogSideEffects: config?.rollup?.experimentalLogSideEffects,