Skip to content

Commit

Permalink
add local @sanity-typed/types to sanity-studio, trigger 'no export na…
Browse files Browse the repository at this point in the history
…med ...' error
  • Loading branch information
waspeer committed Dec 5, 2023
1 parent 2147524 commit 167576d
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 7 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ Reproduction for https://github.com/saiichihashimoto/sanity-typed/issues/394

- I used a [NPM Workspace](https://docs.npmjs.com/cli/v7/using-npm/workspaces) to be able to use the local dependencies of @sanity-typed/types. I just included the folders `tsconfig`, `types` and `utils` to keep it minimal.
- I built the `types` package by running `npm run build` inside the `types` folder. I used the same `tsup.config.ts` that's in the original repository.
- I created a sanity-studio package with `pnpm create sanity@latest` and installed dependencies with `pnpm`.
- I created a sanity-studio package with `pnpm create sanity@latest` and installed dependencies with `pnpm`.
- I installed the local `types` package running `pnpm add ../sanity-typed/types` inside the `sanity-studio` folder and added [the schema provided in the readme](https://github.com/saiichihashimoto/sanity-typed/tree/main/packages/types#usage).
- This results in the following error: `Uncaught error: The requested module '/@fs/Users/wannes/Projecten/Web/waspeer/sanity-typed-issue/sanity-typed/types/dist/index.js?t=1701806909825' does not provide an export named 'defineArrayMember'`
1 change: 1 addition & 0 deletions sanity-studio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"sanity"
],
"dependencies": {
"@sanity-typed/types": "link:../sanity-typed/types",
"@sanity/vision": "^3.21.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down
3 changes: 3 additions & 0 deletions sanity-studio/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 44 additions & 6 deletions sanity-studio/sanity.config.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,53 @@
import {defineConfig} from 'sanity'
import {deskTool} from 'sanity/desk'
import {visionTool} from '@sanity/vision'
import {schemaTypes} from './schemas'

export default defineConfig({
// import {defineConfig} from 'sanity'
import {defineConfig} from '@sanity-typed/types'
import type {InferSchemaValues} from '@sanity-typed/types'

// import {defineArrayMember, defineField, defineType} from 'sanity'
import {defineArrayMember, defineField, defineType} from '@sanity-typed/types'

const product = defineType({
name: 'product',
type: 'document',
title: 'Product',
fields: [
defineField({
name: 'productName',
type: 'string',
title: 'Product name',
validation: (Rule) => Rule.required(),
}),
defineField({
name: 'tags',
type: 'array',
title: 'Tags for item',
of: [
defineArrayMember({
type: 'object',
name: 'tag',
fields: [
defineField({type: 'string', name: 'label'}),
defineField({type: 'string', name: 'value'}),
],
}),
],
}),
],
})

/** No changes using defineConfig */
const config = defineConfig({
projectId: '59t1ed5o',
dataset: 'production',

plugins: [deskTool(), visionTool()],

schema: {
types: schemaTypes,
types: [product],
},
})

export default config

/** Typescript type of all types! */
export type SanityValues = InferSchemaValues<typeof config>

0 comments on commit 167576d

Please sign in to comment.