sanity-codegen
sanity-codegen copied to clipboard
Add ignore packages option
From #59, it seems like the best option is to allow the ability to no-op packages while executing schema extraction.
The config might look like this:
import { SanityCodegenConfig } from 'sanity-codegen';
const config: SanityCodegenConfig = {
// 👇 this will prevent errors from importing this package during schema extraction
ignorePackages: ['sanity-plugin-tabs'],
// ...
};
export default config;
This issue is a todo item for myself.
One issue with this approach is that if you're no-oping a package that's used in generation of a type, you can't then use any functions from that package. eg, with orderable-document-list
:
import { orderRankField } from '@sanity/orderable-document-list';
export const projectDoc = {
// ...
fields: [
name,
orderRankField({ type: 'project' }),
],
} as const;
Which then results in the Cannot convert object to primitive value
thrown from validatePropertyName
because the sanityTypeName
is indeed a function, and it can't be called to resolve it because it's no-op 😢