Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: debarrel sanity package (wip) #8999

Draft
wants to merge 16 commits into
base: next
Choose a base branch
from
Draft
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion dev/test-studio/sanity.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {assist} from '@sanity/assist'

Check failure on line 1 in dev/test-studio/sanity.config.ts

View workflow job for this annotation

GitHub Actions / lint

Run autofix to sort these imports!
import {colorInput} from '@sanity/color-input'
import {googleMapsInput} from '@sanity/google-maps-input'
import {BookIcon} from '@sanity/icons'
Expand All @@ -11,14 +11,14 @@
import {debugSecrets} from '@sanity/preview-url-secret/sanity-plugin-debug-secrets'
import {tsdoc} from '@sanity/tsdoc/studio'
import {visionTool} from '@sanity/vision'
import {defineConfig, definePlugin, type WorkspaceOptions} from 'sanity'

Check failure on line 14 in dev/test-studio/sanity.config.ts

View workflow job for this annotation

GitHub Actions / lint

'sanity' imported multiple times.
import {defineDocuments, defineLocations, presentationTool} from 'sanity/presentation'
import {structureTool} from 'sanity/structure'
import {imageHotspotArrayPlugin} from 'sanity-plugin-hotspot-array'
import {markdownSchema} from 'sanity-plugin-markdown'
import {media} from 'sanity-plugin-media'
import {muxInput} from 'sanity-plugin-mux-input'

import {Event} from 'sanity'

Check failure on line 21 in dev/test-studio/sanity.config.ts

View workflow job for this annotation

GitHub Actions / lint

'Event' is defined but never used.

Check failure on line 21 in dev/test-studio/sanity.config.ts

View workflow job for this annotation

GitHub Actions / lint

'sanity' imported multiple times.
import {imageAssetSource} from './assetSources'
import {
Annotation,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {type InsertMenuOptions} from '@sanity/insert-menu'
import {type InitialValueProperty, type SchemaValidationValue} from '@sanity/types'

import {type FieldReference} from '../../../validation'
import {type RuleDef, type ValidationBuilder} from '../../ruleBuilder'
import {type InitialValueProperty, type SchemaValidationValue} from '../../types'
import {
type IntrinsicDefinitions,
type IntrinsicTypeName,
Expand Down
15 changes: 8 additions & 7 deletions packages/sanity/package.bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ export default defineConfig(() => {
build: {
lib: {
entry: {
_singletons: './src/_exports/_singletons.ts',
_createContext: './src/_exports/_createContext.ts',
'_singletons': './src/_exports/_singletons.ts',
'_createContext': './src/_exports/_createContext.ts',
// 'sanity' module
index: './src/_exports/index.ts',
desk: './src/_exports/desk.ts',
presentation: './src/_exports/presentation.ts',
router: './src/_exports/router.ts',
structure: './src/_exports/structure.ts',
'index': './src/_exports/index.ts',
'desk': './src/_exports/desk.ts',
'presentation': './src/_exports/presentation.ts',
'router': './src/_exports/router.ts',
'structure': './src/_exports/structure.ts',
'ui-components': './src/_exports/ui-components.ts',
},
},
},
Expand Down
8 changes: 7 additions & 1 deletion packages/sanity/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
"require": "./lib/_internal.js",
"default": "./lib/_internal.js"
},
"./ui-components": {
"source": "./src/_exports/ui-components.ts",
"require": "./lib/ui-components.js",
"default": "./lib/ui-components.js"
},
"./_singletons": {
"source": "./src/_exports/_singletons.ts",
"import": "./lib/_singletons.mjs",
Expand Down Expand Up @@ -317,7 +322,8 @@
"rxjs-etc": "^10.6.2",
"styled-components": "^6.1.16",
"swr": "2.2.5",
"vitest": "^3.0.8"
"vitest": "^3.0.8",
"vitest-package-exports": "^0.1.1"
},
"peerDependencies": {
"react": "^18 || ^19",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {css, styled} from 'styled-components'

import {applyAll} from '../../../../src/core/form/patch/applyPatch'
import {PresenceProvider} from '../../../../src/core/form/studio/contexts/Presence'
import {type FormDocumentValue} from '../../../../src/core/form/types'
import {type FormDocumentValue} from '../../../../src/core/form/types/formDocumentValue'
import {createMockSanityClient} from '../../mocks/createMockSanityClient'

const NOOP = () => null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {Pane, PaneContent, PaneLayout} from 'sanity/structure'
import {styled} from 'styled-components'

import {PerspectiveProvider} from '../../../../src/core/perspective/PerspectiveProvider'
import {route} from '../../../../src/router'
import {route} from '../../../../src/router/route'
import {RouterProvider} from '../../../../src/router/RouterProvider'
import {createMockSanityClient} from '../../../../test/mocks/mockSanityClient'
import {getMockWorkspace} from '../../../../test/testUtils/getMockWorkspaceFromConfig'
Expand Down
Loading
Loading