@sanity/pkg-utils 6.12.3 → 6.13.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/dist/_chunks-cjs/index.cjs +26 -4
- package/dist/_chunks-cjs/index.cjs.map +1 -1
- package/dist/cli.cjs +1 -1
- package/dist/index.d.cts +25 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.js +26 -4
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/node/core/config/types.ts +25 -0
- package/src/node/tasks/rollup/resolveRollupConfig.ts +28 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/pkg-utils",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.13.0",
|
|
4
4
|
"description": "Simple utilities for modern npm packages.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity-io",
|
|
@@ -146,7 +146,7 @@
|
|
|
146
146
|
"typescript": "5.7.2",
|
|
147
147
|
"vitest": "^2.1.8",
|
|
148
148
|
"vitest-github-actions-reporter": "^0.11.1",
|
|
149
|
-
"@sanity/pkg-utils": "6.
|
|
149
|
+
"@sanity/pkg-utils": "6.13.0"
|
|
150
150
|
},
|
|
151
151
|
"peerDependencies": {
|
|
152
152
|
"babel-plugin-react-compiler": "*",
|
|
@@ -170,6 +170,31 @@ export interface PkgConfigOptions {
|
|
|
170
170
|
plugins?: BabelPluginItem[] | null | undefined
|
|
171
171
|
/** @alpha */
|
|
172
172
|
reactCompiler?: boolean
|
|
173
|
+
/** @alpha */
|
|
174
|
+
styledComponents?:
|
|
175
|
+
| boolean
|
|
176
|
+
| {
|
|
177
|
+
/** @defaultValue true */
|
|
178
|
+
displayName?: boolean
|
|
179
|
+
/**
|
|
180
|
+
* @defaultValue []
|
|
181
|
+
* @example ["@xstyled/styled-components", "@xstyled/styled-components/*"]
|
|
182
|
+
*/
|
|
183
|
+
topLevelImportPaths?: string[]
|
|
184
|
+
/** @defaultValue true */
|
|
185
|
+
ssr?: boolean
|
|
186
|
+
/** @defaultValue fale */
|
|
187
|
+
fileName?: boolean
|
|
188
|
+
/** @defaultValue ["index"] */
|
|
189
|
+
meaninglessFileNames?: string[]
|
|
190
|
+
/** @defaultValue true */
|
|
191
|
+
minify?: boolean
|
|
192
|
+
/** @defaultValue false */
|
|
193
|
+
transpileTemplateLiterals?: boolean
|
|
194
|
+
namespace?: string
|
|
195
|
+
/** @defaultValue true */
|
|
196
|
+
pure?: boolean
|
|
197
|
+
}
|
|
173
198
|
}
|
|
174
199
|
/**
|
|
175
200
|
* Configure the React Compiler.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
2
|
|
|
3
|
+
import type {PluginItem} from '@babel/core'
|
|
3
4
|
import {optimizeLodashImports} from '@optimize-lodash/rollup-plugin'
|
|
4
5
|
import alias from '@rollup/plugin-alias'
|
|
5
6
|
import {babel, getBabelOutputPlugin} from '@rollup/plugin-babel'
|
|
@@ -96,13 +97,35 @@ export function resolveRollupConfig(
|
|
|
96
97
|
}),
|
|
97
98
|
commonjs(),
|
|
98
99
|
json(),
|
|
99
|
-
(isReactCompiler || config?.babel?.reactCompiler) &&
|
|
100
|
+
(isReactCompiler || config?.babel?.reactCompiler || config?.babel?.styledComponents) &&
|
|
100
101
|
babel({
|
|
101
102
|
babelrc: false,
|
|
102
103
|
presets: ['@babel/preset-typescript'],
|
|
103
104
|
babelHelpers: 'bundled',
|
|
104
105
|
extensions: ['.ts', '.tsx', '.js', '.jsx'],
|
|
105
|
-
plugins: [
|
|
106
|
+
plugins: [
|
|
107
|
+
// The styled-components plugin needs to run before the react-compiler plugin, in case the css prop is used
|
|
108
|
+
config?.babel?.styledComponents && [
|
|
109
|
+
'babel-plugin-styled-components',
|
|
110
|
+
{
|
|
111
|
+
// Unnecessary, as the way we use styled-components in Sanity is usually by wrapping `@sanity/ui` primitives, not declaring new ones like "const Button = styled.button``"
|
|
112
|
+
fileName: false,
|
|
113
|
+
// Native template literals take less space than this transpilation
|
|
114
|
+
transpileTemplateLiterals: false,
|
|
115
|
+
// Massively helps dead code elimination and tree-shaking
|
|
116
|
+
pure: true,
|
|
117
|
+
// disabled, as pkg-utils tends to be used for npm publishing, while other tooling, like `sanity dev`, `next dev`, etc are used for testing
|
|
118
|
+
cssProp: false,
|
|
119
|
+
...(typeof config.babel.styledComponents === 'object'
|
|
120
|
+
? config.babel.styledComponents
|
|
121
|
+
: {}),
|
|
122
|
+
},
|
|
123
|
+
],
|
|
124
|
+
(isReactCompiler || config?.babel?.reactCompiler) && [
|
|
125
|
+
'babel-plugin-react-compiler',
|
|
126
|
+
config?.reactCompilerOptions || {},
|
|
127
|
+
],
|
|
128
|
+
].filter(Boolean) as PluginItem[],
|
|
106
129
|
}),
|
|
107
130
|
esbuild({
|
|
108
131
|
jsx: config?.jsx ?? 'automatic',
|
|
@@ -131,7 +154,8 @@ export function resolveRollupConfig(
|
|
|
131
154
|
}),
|
|
132
155
|
minify &&
|
|
133
156
|
terser({
|
|
134
|
-
compress: {directives: false},
|
|
157
|
+
compress: {directives: false, passes: 10},
|
|
158
|
+
ecma: 2020,
|
|
135
159
|
output: {
|
|
136
160
|
comments: (_node, comment) => {
|
|
137
161
|
const text = comment.value
|
|
@@ -145,6 +169,7 @@ export function resolveRollupConfig(
|
|
|
145
169
|
|
|
146
170
|
return false
|
|
147
171
|
},
|
|
172
|
+
preserve_annotations: true,
|
|
148
173
|
},
|
|
149
174
|
}),
|
|
150
175
|
].filter(Boolean) as Plugin[]
|