import { PluginItem } from "@babel/core"; import { OptimizeLodashOptions } from "@optimize-lodash/rollup-plugin"; import { PkgExport, PkgExports, PkgExports as PkgExports$1 } from "@sanity/parse-package-json"; import { Options } from "@vanilla-extract/rollup-plugin"; import { PluginOptions } from "babel-plugin-react-compiler"; import { NormalizedOutputOptions, Plugin, Plugin as RollupPlugin, TreeshakingOptions } from "rollup"; type ToggleType = 'error' | 'warn' | 'off'; /** * @public */ interface StrictOptions { /** * Disallows a top level `typings` field in `package.json` if it is equal to `exports['.'].source`. * @defaultValue 'error' */ noPackageJsonTypings: ToggleType; /** * Requires specifying `sideEffects` in `package.json`. * @defaultValue 'warn' */ noImplicitSideEffects: ToggleType; /** * Requires specifying `browserslist` in `package.json`, instead of relying on it implicitly being: * @example * ``` * "browserslist": "extends @sanity/browserslist-config" * ``` * @defaultValue 'warn' */ noImplicitBrowsersList: ToggleType; /** * If typescript is used then `types` in `package.json` should be specified for npm listings to show the TS icon. * @defaultValue 'error' */ alwaysPackageJsonTypes: ToggleType; /** * Using `.npmignore` is error prone, it's best practice to always declare `files` instead * @defaultValue 'error' */ alwaysPackageJsonFiles: ToggleType; /** * It's slow to perform type checking while generating dts files, so it's best practice to disable it with a `"noCheck": true` in the tsconfig.json file used by `package.config.ts` * @defaultValue 'warn' */ noCheckTypes: ToggleType; /** * Disallows the `browser` field in `package.json` as the `browser` condition in `exports` is better supported. * @defaultValue 'warn' */ noPackageJsonBrowser: ToggleType; /** * Disallows the `typesVersions` field in `package.json` as TypeScript has long supported conditional exports and the `types` condition. * @defaultValue 'warn' */ noPackageJsonTypesVersions: ToggleType; /** * Warns if `type` field is missing or set to `commonjs`. Future versions will require `"type": "module"`. * @defaultValue 'warn' */ preferModuleType: ToggleType; /** * Warns if `publishConfig.exports` is missing when `source`, `development`, or `monorepo` conditions are used in exports. * @defaultValue 'warn' */ noPublishConfigExports: ToggleType; } /** @public */ type PkgFormat = 'commonjs' | 'esm'; /** @public */ type PkgRuntime = '*' | 'browser' | 'node'; /** @public */ type PkgConfigPropertyResolver = (prev: T) => T; /** @public */ type PkgConfigProperty = PkgConfigPropertyResolver | T; /** @public */ interface PkgBundle { source: string; import?: string; require?: string; runtime?: PkgRuntime; } /** @public */ type PkgRuleLevel = 'error' | 'warn' | 'info' | 'off'; /** @public */ interface TSDocCustomTag { name: string; syntaxKind: 'block' | 'modifier'; allowMultiple?: boolean; } type DtsType = 'api-extractor' | 'rolldown'; /** @public */ interface PkgConfigOptions { /** @alpha */ babel?: { plugins?: PluginItem[] | null | undefined; /** @alpha */ reactCompiler?: boolean; /** @alpha */ styledComponents?: boolean | { /** @defaultValue true */displayName?: boolean; /** * @defaultValue [] * @example ["\@xstyled/styled-components", "\@xstyled/styled-components/*"] */ topLevelImportPaths?: string[]; /** @defaultValue true */ ssr?: boolean; /** @defaultValue fale */ fileName?: boolean; /** @defaultValue ["index"] */ meaninglessFileNames?: string[]; /** @defaultValue true */ minify?: boolean; /** @defaultValue false */ transpileTemplateLiterals?: boolean; namespace?: string; /** @defaultValue true */ pure?: boolean; }; }; /** * Configure the React Compiler. * To enable it set `babel.reactCompiler` to `true` * @beta */ reactCompilerOptions?: Partial; bundles?: PkgBundle[]; /** @alpha */ define?: Record; /** * Directory of distributed & bundled files. */ dist?: string; exports?: PkgConfigProperty; /** * Runs `@microsoft/api-extractor` to check that TSDoc tags are valid, and release tags are correct. * This is useful for packages that need to be consumed by TSDoc-based tooling. * It's enabled by default, it can be disabled by setting `extract: {enabled: false}` */ extract?: { /** * @defaultValue true */ enabled?: boolean; /** * When set to false, disables type checking during type definition generation. * This is equivalent to setting `"noCheck": true` in tsconfig.json but can be * controlled from package.config.ts without needing multiple tsconfig files. * @defaultValue undefined (uses tsconfig.json settings) */ checkTypes?: boolean; /** * Packages in `devDependencies` that are not in `external` are automatically added to the `bundledPackages` config. * You can exclude a package from being bundled by using a callback: * ``` * bundledPackages: (prev) => prev.filter(package => package !== 'sanity') * ``` */ bundledPackages?: PkgConfigProperty; customTags?: TSDocCustomTag[]; rules?: { /** * @deprecated as it's no longer needed since TypeScript 5.5 https://github.com/microsoft/TypeScript/issues/42873 */ 'ae-forgotten-export'?: never; 'ae-incompatible-release-tags'?: PkgRuleLevel; 'ae-internal-missing-underscore'?: PkgRuleLevel; 'ae-missing-release-tag'?: PkgRuleLevel; 'tsdoc-link-tag-unescaped-text'?: PkgRuleLevel; 'tsdoc-undefined-tag'?: PkgRuleLevel; 'tsdoc-unsupported-tag'?: PkgRuleLevel; }; }; /** * Packages to exclude from bundles. * Provide an array to merge with default exclusions, use a function to replace them: * ``` * exclude: (prev) => prev.filter(package => package !== 'foo') * ``` */ external?: PkgConfigProperty; /** * Defaults to `"automatic"` */ jsx?: 'transform' | 'preserve' | 'automatic'; /** * Defaults to `"createElement"` */ jsxFactory?: string; /** * Defaults to `"Fragment"` */ jsxFragment?: string; /** * Defaults to `"react"` */ jsxImportSource?: string; /** * @deprecated no longer supported */ legacyExports?: never; minify?: boolean; /** @alpha */ rollup?: { plugins?: PkgConfigProperty; output?: Partial; /** * Default options are `preset: 'recommended'` and `propertyReadSideEffects: false` * @alpha */ treeshake?: TreeshakingOptions; /** @alpha */ experimentalLogSideEffects?: boolean; /** * Adds [hash] to chunk filenames, generally only useful if `@sanity/pkg-utils` is used to deploy a package directly to a CDN. * It's not needed when publishing to npm for consumption by other libraries, bundlers and frameworks. * @defaultValue false */ hashChunkFileNames?: boolean; /** * Optimizes lodash imports using `@optimize-lodash/rollup-plugin` when set to `true`. * It's enabled if `lodash` is found in `dependencies` or `peerDependencies`. * It will use `lodash-es` for ESM targets if found in `dependencies` or `peerDependencies`. * @defaultValue true * @alpha */ optimizeLodash?: boolean | OptimizeLodashOptions; /** * Enables \@vanilla-extract/rollup-plugin to extract CSS into a separate file, with support for minifying the extracted CSS. * @alpha */ vanillaExtract?: boolean | (Options & { minify?: boolean; browserslist?: string | string[]; }); }; /** * Default runtime of package exports */ runtime?: PkgRuntime; sourcemap?: boolean; /** * Directory of source files. */ src?: string; tsconfig?: string; /** * Configure what checks are made when running `--strict` builds and checks */ strictOptions?: Partial; /** * .d.ts files can be generated either by using `@microsoft/api-extractor` or `rolldown`. * `rolldown` is the faster option, but is not yet stable. * @defaultValue 'api-extractor' */ dts?: DtsType; /** * When using `dts: 'rolldown'`, enables the use of `@typescript/native-preview` for type generation. * By default, `tsgo` is automatically enabled if `@typescript/native-preview` is found in `devDependencies`. * Set to `true` to explicitly enable or `false` to explicitly disable. * @alpha */ tsgo?: boolean; } /** @public */ declare function defineConfig(configOptions: T): T; /** @alpha */ declare function loadConfig(options: { cwd: string; pkgPath: string; }): Promise; /** @public */ declare const DEFAULT_BROWSERSLIST_QUERY: string[]; /** @public */ interface PkgTemplateStringOption { name: string; type: 'string'; description: string; initial?: T | ((options: Record) => T); parse?: (v: string) => T | null; validate?: (v: string) => string | true; } /** @public */ type PkgTemplateOption = PkgTemplateStringOption; /** @public */ declare function defineTemplateOption(option: PkgTemplateOption): PkgTemplateOption; export { DEFAULT_BROWSERSLIST_QUERY, type PkgBundle, type PkgConfigOptions, type PkgConfigProperty, type PkgConfigPropertyResolver, type PkgExport, type PkgExports, type PkgFormat, type PkgRuleLevel, type PkgRuntime, type RollupPlugin, type TSDocCustomTag, defineConfig, defineTemplateOption, loadConfig }; //# sourceMappingURL=index.d.ts.map