@sanity/pkg-utils 6.8.19 → 6.8.20-canary.0

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": "6.8.19",
3
+ "version": "6.8.20-canary.0",
4
4
  "description": "Simple utilities for modern npm packages.",
5
5
  "keywords": [
6
6
  "sanity-io",
@@ -68,6 +68,7 @@
68
68
  "prettier": "@sanity/prettier-config",
69
69
  "dependencies": {
70
70
  "@babel/core": "^7.24.6",
71
+ "@babel/preset-typescript": "^7.24.6",
71
72
  "@babel/types": "^7.24.6",
72
73
  "@microsoft/api-extractor": "7.46.2",
73
74
  "@microsoft/tsdoc-config": "0.17.0",
@@ -144,11 +145,17 @@
144
145
  "typescript": "5.4.5",
145
146
  "vitest": "^1.6.0",
146
147
  "vitest-github-actions-reporter": "^0.11.1",
147
- "@sanity/pkg-utils": "6.8.19"
148
+ "@sanity/pkg-utils": "6.8.20-canary.0"
148
149
  },
149
150
  "peerDependencies": {
151
+ "babel-plugin-react-compiler": "*",
150
152
  "typescript": "5.4.x"
151
153
  },
154
+ "peerDependenciesMeta": {
155
+ "babel-plugin-react-compiler": {
156
+ "optional": true
157
+ }
158
+ },
152
159
  "engines": {
153
160
  "node": ">=18.17.0"
154
161
  },
@@ -72,6 +72,14 @@ export interface PkgConfigOptions {
72
72
  /** @alpha */
73
73
  babel?: {
74
74
  plugins?: BabelPluginItem[] | null | undefined
75
+ /** @alpha */
76
+ reactCompiler?:
77
+ | boolean
78
+ | {
79
+ compilationMode: 'infer' | 'annotation' | 'all'
80
+ panicThreshold: 'all_errors' | 'critical_errors' | 'none'
81
+ sources?: Array<string> | ((filename: string) => boolean) | null
82
+ }
75
83
  }
76
84
  bundles?: PkgBundle[]
77
85
  /** @alpha */
@@ -2,7 +2,7 @@ import path from 'node:path'
2
2
 
3
3
  import {optimizeLodashImports} from '@optimize-lodash/rollup-plugin'
4
4
  import alias from '@rollup/plugin-alias'
5
- import {getBabelOutputPlugin} from '@rollup/plugin-babel'
5
+ import {babel, getBabelOutputPlugin} from '@rollup/plugin-babel'
6
6
  import commonjs from '@rollup/plugin-commonjs'
7
7
  import json from '@rollup/plugin-json'
8
8
  import {nodeResolve} from '@rollup/plugin-node-resolve'
@@ -95,6 +95,23 @@ export function resolveRollupConfig(
95
95
  }),
96
96
  commonjs(),
97
97
  json(),
98
+ config?.babel?.reactCompiler &&
99
+ babel({
100
+ babelrc: false,
101
+ presets: ['@babel/preset-typescript'],
102
+ babelHelpers: 'bundled',
103
+ extensions: ['.ts', '.tsx', '.js', '.jsx'],
104
+ plugins: [
105
+ [
106
+ 'babel-plugin-react-compiler',
107
+ {
108
+ ...(typeof config?.babel?.reactCompiler === 'object'
109
+ ? config?.babel?.reactCompiler
110
+ : {}),
111
+ },
112
+ ],
113
+ ],
114
+ }),
98
115
  esbuild({
99
116
  jsx: config?.jsx ?? 'automatic',
100
117
  jsxFactory: config?.jsxFactory ?? 'createElement',