@@ -20,15 +20,9 @@ export type BabelOptions = Omit<
20
20
> ;
21
21
22
22
export interface PreactPluginOptions {
23
- /**
24
- * Inject devtools bridge in production bundle instead of only in development mode.
25
- * @default false
26
- */
27
- devtoolsInProd ?: boolean ;
28
-
29
23
/**
30
24
* Whether to use Preact devtools
31
- * @default true
25
+ * @default !isProduction
32
26
*/
33
27
devToolsEnabled ?: boolean ;
34
28
@@ -97,7 +91,6 @@ export interface PreactBabelOptions extends BabelOptions {
97
91
98
92
// Taken from https://github.com/vitejs/vite/blob/main/packages/plugin-react/src/index.ts
99
93
function preactPlugin ( {
100
- devtoolsInProd,
101
94
devToolsEnabled,
102
95
prefreshEnabled,
103
96
reactAliasesEnabled,
@@ -131,7 +124,6 @@ function preactPlugin({
131
124
exclude || [ / n o d e _ m o d u l e s / ] ,
132
125
) ;
133
126
134
- devToolsEnabled = devToolsEnabled ?? true ;
135
127
prefreshEnabled = prefreshEnabled ?? true ;
136
128
reactAliasesEnabled = reactAliasesEnabled ?? true ;
137
129
prerender = prerender ?? { enabled : false } ;
@@ -158,6 +150,7 @@ function preactPlugin({
158
150
} ,
159
151
configResolved ( resolvedConfig ) {
160
152
config = resolvedConfig ;
153
+ devToolsEnabled ??= ! config . isProduction ;
161
154
} ,
162
155
async transform ( code , url ) {
163
156
// Ignore query parameters, as in Vue SFC virtual modules.
@@ -200,7 +193,7 @@ function preactPlugin({
200
193
importSource : jsxImportSource ?? "preact" ,
201
194
} ,
202
195
] ,
203
- ...( devToolsEnabled && ! config . isProduction ? [ "babel-plugin-transform-hook-names" ] : [ ] ) ,
196
+ ...( devToolsEnabled ? [ "babel-plugin-transform-hook-names" ] : [ ] ) ,
204
197
] ,
205
198
sourceMaps : true ,
206
199
inputSourceMap : false as any ,
@@ -235,14 +228,7 @@ function preactPlugin({
235
228
]
236
229
: [ ] ) ,
237
230
jsxPlugin ,
238
- ...( devToolsEnabled
239
- ? [
240
- preactDevtoolsPlugin ( {
241
- injectInProd : devtoolsInProd ,
242
- shouldTransform,
243
- } ) ,
244
- ]
245
- : [ ] ) ,
231
+ preactDevtoolsPlugin ( { shouldTransform } ) ,
246
232
...( prefreshEnabled
247
233
? [ prefresh ( { include, exclude, parserPlugins : baseParserOptions } ) ]
248
234
: [ ] ) ,
0 commit comments