@vitejs/plugin-react 4.3.3 → 4.4.0-beta.1

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.
@@ -0,0 +1,647 @@
1
+ /* global window */
2
+ /* eslint-disable eqeqeq, prefer-const, @typescript-eslint/no-empty-function */
3
+
4
+ /*! Copyright (c) Meta Platforms, Inc. and affiliates. **/
5
+ /**
6
+ * This is simplified pure-js version of https://github.com/facebook/react/blob/main/packages/react-refresh/src/ReactFreshRuntime.js
7
+ * without IE11 compatibility and verbose isDev checks.
8
+ * Some utils are appended at the bottom for HMR integration.
9
+ */
10
+
11
+ const REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref')
12
+ const REACT_MEMO_TYPE = Symbol.for('react.memo')
13
+
14
+ // We never remove these associations.
15
+ // It's OK to reference families, but use WeakMap/Set for types.
16
+ let allFamiliesByID = new Map()
17
+ let allFamiliesByType = new WeakMap()
18
+ let allSignaturesByType = new WeakMap()
19
+
20
+ // This WeakMap is read by React, so we only put families
21
+ // that have actually been edited here. This keeps checks fast.
22
+ const updatedFamiliesByType = new WeakMap()
23
+
24
+ // This is cleared on every performReactRefresh() call.
25
+ // It is an array of [Family, NextType] tuples.
26
+ let pendingUpdates = []
27
+
28
+ // This is injected by the renderer via DevTools global hook.
29
+ const helpersByRendererID = new Map()
30
+
31
+ const helpersByRoot = new Map()
32
+
33
+ // We keep track of mounted roots so we can schedule updates.
34
+ const mountedRoots = new Set()
35
+ // If a root captures an error, we remember it so we can retry on edit.
36
+ const failedRoots = new Set()
37
+
38
+ // We also remember the last element for every root.
39
+ // It needs to be weak because we do this even for roots that failed to mount.
40
+ // If there is no WeakMap, we won't attempt to do retrying.
41
+ let rootElements = new WeakMap()
42
+ let isPerformingRefresh = false
43
+
44
+ function computeFullKey(signature) {
45
+ if (signature.fullKey !== null) {
46
+ return signature.fullKey
47
+ }
48
+
49
+ let fullKey = signature.ownKey
50
+ let hooks
51
+ try {
52
+ hooks = signature.getCustomHooks()
53
+ } catch (err) {
54
+ // This can happen in an edge case, e.g. if expression like Foo.useSomething
55
+ // depends on Foo which is lazily initialized during rendering.
56
+ // In that case just assume we'll have to remount.
57
+ signature.forceReset = true
58
+ signature.fullKey = fullKey
59
+ return fullKey
60
+ }
61
+
62
+ for (let i = 0; i < hooks.length; i++) {
63
+ const hook = hooks[i]
64
+ if (typeof hook !== 'function') {
65
+ // Something's wrong. Assume we need to remount.
66
+ signature.forceReset = true
67
+ signature.fullKey = fullKey
68
+ return fullKey
69
+ }
70
+ const nestedHookSignature = allSignaturesByType.get(hook)
71
+ if (nestedHookSignature === undefined) {
72
+ // No signature means Hook wasn't in the source code, e.g. in a library.
73
+ // We'll skip it because we can assume it won't change during this session.
74
+ continue
75
+ }
76
+ const nestedHookKey = computeFullKey(nestedHookSignature)
77
+ if (nestedHookSignature.forceReset) {
78
+ signature.forceReset = true
79
+ }
80
+ fullKey += '\n---\n' + nestedHookKey
81
+ }
82
+
83
+ signature.fullKey = fullKey
84
+ return fullKey
85
+ }
86
+
87
+ function haveEqualSignatures(prevType, nextType) {
88
+ const prevSignature = allSignaturesByType.get(prevType)
89
+ const nextSignature = allSignaturesByType.get(nextType)
90
+
91
+ if (prevSignature === undefined && nextSignature === undefined) {
92
+ return true
93
+ }
94
+ if (prevSignature === undefined || nextSignature === undefined) {
95
+ return false
96
+ }
97
+ if (computeFullKey(prevSignature) !== computeFullKey(nextSignature)) {
98
+ return false
99
+ }
100
+ if (nextSignature.forceReset) {
101
+ return false
102
+ }
103
+
104
+ return true
105
+ }
106
+
107
+ function isReactClass(type) {
108
+ return type.prototype && type.prototype.isReactComponent
109
+ }
110
+
111
+ function canPreserveStateBetween(prevType, nextType) {
112
+ if (isReactClass(prevType) || isReactClass(nextType)) {
113
+ return false
114
+ }
115
+ if (haveEqualSignatures(prevType, nextType)) {
116
+ return true
117
+ }
118
+ return false
119
+ }
120
+
121
+ function resolveFamily(type) {
122
+ // Only check updated types to keep lookups fast.
123
+ return updatedFamiliesByType.get(type)
124
+ }
125
+
126
+ // This is a safety mechanism to protect against rogue getters and Proxies.
127
+ function getProperty(object, property) {
128
+ try {
129
+ return object[property]
130
+ } catch (err) {
131
+ // Intentionally ignore.
132
+ return undefined
133
+ }
134
+ }
135
+
136
+ function performReactRefresh() {
137
+ if (pendingUpdates.length === 0) {
138
+ return null
139
+ }
140
+ if (isPerformingRefresh) {
141
+ return null
142
+ }
143
+
144
+ isPerformingRefresh = true
145
+ try {
146
+ const staleFamilies = new Set()
147
+ const updatedFamilies = new Set()
148
+
149
+ const updates = pendingUpdates
150
+ pendingUpdates = []
151
+ updates.forEach(([family, nextType]) => {
152
+ // Now that we got a real edit, we can create associations
153
+ // that will be read by the React reconciler.
154
+ const prevType = family.current
155
+ updatedFamiliesByType.set(prevType, family)
156
+ updatedFamiliesByType.set(nextType, family)
157
+ family.current = nextType
158
+
159
+ // Determine whether this should be a re-render or a re-mount.
160
+ if (canPreserveStateBetween(prevType, nextType)) {
161
+ updatedFamilies.add(family)
162
+ } else {
163
+ staleFamilies.add(family)
164
+ }
165
+ })
166
+
167
+ // TODO: rename these fields to something more meaningful.
168
+ const update = {
169
+ updatedFamilies, // Families that will re-render preserving state
170
+ staleFamilies, // Families that will be remounted
171
+ }
172
+
173
+ helpersByRendererID.forEach((helpers) => {
174
+ // Even if there are no roots, set the handler on first update.
175
+ // This ensures that if *new* roots are mounted, they'll use the resolve handler.
176
+ helpers.setRefreshHandler(resolveFamily)
177
+ })
178
+
179
+ let didError = false
180
+ let firstError = null
181
+
182
+ // We snapshot maps and sets that are mutated during commits.
183
+ // If we don't do this, there is a risk they will be mutated while
184
+ // we iterate over them. For example, trying to recover a failed root
185
+ // may cause another root to be added to the failed list -- an infinite loop.
186
+ const failedRootsSnapshot = new Set(failedRoots)
187
+ const mountedRootsSnapshot = new Set(mountedRoots)
188
+ const helpersByRootSnapshot = new Map(helpersByRoot)
189
+
190
+ failedRootsSnapshot.forEach((root) => {
191
+ const helpers = helpersByRootSnapshot.get(root)
192
+ if (helpers === undefined) {
193
+ throw new Error(
194
+ 'Could not find helpers for a root. This is a bug in React Refresh.',
195
+ )
196
+ }
197
+ if (!failedRoots.has(root)) {
198
+ // No longer failed.
199
+ }
200
+ if (rootElements === null) {
201
+ return
202
+ }
203
+ if (!rootElements.has(root)) {
204
+ return
205
+ }
206
+ const element = rootElements.get(root)
207
+ try {
208
+ helpers.scheduleRoot(root, element)
209
+ } catch (err) {
210
+ if (!didError) {
211
+ didError = true
212
+ firstError = err
213
+ }
214
+ // Keep trying other roots.
215
+ }
216
+ })
217
+ mountedRootsSnapshot.forEach((root) => {
218
+ const helpers = helpersByRootSnapshot.get(root)
219
+ if (helpers === undefined) {
220
+ throw new Error(
221
+ 'Could not find helpers for a root. This is a bug in React Refresh.',
222
+ )
223
+ }
224
+ if (!mountedRoots.has(root)) {
225
+ // No longer mounted.
226
+ }
227
+ try {
228
+ helpers.scheduleRefresh(root, update)
229
+ } catch (err) {
230
+ if (!didError) {
231
+ didError = true
232
+ firstError = err
233
+ }
234
+ // Keep trying other roots.
235
+ }
236
+ })
237
+ if (didError) {
238
+ throw firstError
239
+ }
240
+ return update
241
+ } finally {
242
+ isPerformingRefresh = false
243
+ }
244
+ }
245
+
246
+ function register(type, id) {
247
+ if (type === null) {
248
+ return
249
+ }
250
+ if (typeof type !== 'function' && typeof type !== 'object') {
251
+ return
252
+ }
253
+
254
+ // This can happen in an edge case, e.g. if we register
255
+ // return value of a HOC but it returns a cached component.
256
+ // Ignore anything but the first registration for each type.
257
+ if (allFamiliesByType.has(type)) {
258
+ return
259
+ }
260
+ // Create family or remember to update it.
261
+ // None of this bookkeeping affects reconciliation
262
+ // until the first performReactRefresh() call above.
263
+ let family = allFamiliesByID.get(id)
264
+ if (family === undefined) {
265
+ family = { current: type }
266
+ allFamiliesByID.set(id, family)
267
+ } else {
268
+ pendingUpdates.push([family, type])
269
+ }
270
+ allFamiliesByType.set(type, family)
271
+
272
+ // Visit inner types because we might not have registered them.
273
+ if (typeof type === 'object' && type !== null) {
274
+ switch (getProperty(type, '$$typeof')) {
275
+ case REACT_FORWARD_REF_TYPE:
276
+ register(type.render, id + '$render')
277
+ break
278
+ case REACT_MEMO_TYPE:
279
+ register(type.type, id + '$type')
280
+ break
281
+ }
282
+ }
283
+ }
284
+
285
+ function setSignature(type, key, forceReset, getCustomHooks) {
286
+ if (!allSignaturesByType.has(type)) {
287
+ allSignaturesByType.set(type, {
288
+ forceReset,
289
+ ownKey: key,
290
+ fullKey: null,
291
+ getCustomHooks: getCustomHooks || (() => []),
292
+ })
293
+ }
294
+ // Visit inner types because we might not have signed them.
295
+ if (typeof type === 'object' && type !== null) {
296
+ switch (getProperty(type, '$$typeof')) {
297
+ case REACT_FORWARD_REF_TYPE:
298
+ setSignature(type.render, key, forceReset, getCustomHooks)
299
+ break
300
+ case REACT_MEMO_TYPE:
301
+ setSignature(type.type, key, forceReset, getCustomHooks)
302
+ break
303
+ }
304
+ }
305
+ }
306
+
307
+ // This is lazily called during first render for a type.
308
+ // It captures Hook list at that time so inline requires don't break comparisons.
309
+ function collectCustomHooksForSignature(type) {
310
+ const signature = allSignaturesByType.get(type)
311
+ if (signature !== undefined) {
312
+ computeFullKey(signature)
313
+ }
314
+ }
315
+
316
+ export function injectIntoGlobalHook(globalObject) {
317
+ // For React Native, the global hook will be set up by require('react-devtools-core').
318
+ // That code will run before us. So we need to monkeypatch functions on existing hook.
319
+
320
+ // For React Web, the global hook will be set up by the extension.
321
+ // This will also run before us.
322
+ let hook = globalObject.__REACT_DEVTOOLS_GLOBAL_HOOK__
323
+ if (hook === undefined) {
324
+ // However, if there is no DevTools extension, we'll need to set up the global hook ourselves.
325
+ // Note that in this case it's important that renderer code runs *after* this method call.
326
+ // Otherwise, the renderer will think that there is no global hook, and won't do the injection.
327
+ let nextID = 0
328
+ globalObject.__REACT_DEVTOOLS_GLOBAL_HOOK__ = hook = {
329
+ renderers: new Map(),
330
+ supportsFiber: true,
331
+ inject: (injected) => nextID++,
332
+ onScheduleFiberRoot: (id, root, children) => {},
333
+ onCommitFiberRoot: (id, root, maybePriorityLevel, didError) => {},
334
+ onCommitFiberUnmount() {},
335
+ }
336
+ }
337
+
338
+ if (hook.isDisabled) {
339
+ // This isn't a real property on the hook, but it can be set to opt out
340
+ // of DevTools integration and associated warnings and logs.
341
+ // Using console['warn'] to evade Babel and ESLint
342
+ console['warn'](
343
+ 'Something has shimmed the React DevTools global hook (__REACT_DEVTOOLS_GLOBAL_HOOK__). ' +
344
+ 'Fast Refresh is not compatible with this shim and will be disabled.',
345
+ )
346
+ return
347
+ }
348
+
349
+ // Here, we just want to get a reference to scheduleRefresh.
350
+ const oldInject = hook.inject
351
+ hook.inject = function (injected) {
352
+ const id = oldInject.apply(this, arguments)
353
+ if (
354
+ typeof injected.scheduleRefresh === 'function' &&
355
+ typeof injected.setRefreshHandler === 'function'
356
+ ) {
357
+ // This version supports React Refresh.
358
+ helpersByRendererID.set(id, injected)
359
+ }
360
+ return id
361
+ }
362
+
363
+ // Do the same for any already injected roots.
364
+ // This is useful if ReactDOM has already been initialized.
365
+ // https://github.com/facebook/react/issues/17626
366
+ hook.renderers.forEach((injected, id) => {
367
+ if (
368
+ typeof injected.scheduleRefresh === 'function' &&
369
+ typeof injected.setRefreshHandler === 'function'
370
+ ) {
371
+ // This version supports React Refresh.
372
+ helpersByRendererID.set(id, injected)
373
+ }
374
+ })
375
+
376
+ // We also want to track currently mounted roots.
377
+ const oldOnCommitFiberRoot = hook.onCommitFiberRoot
378
+ const oldOnScheduleFiberRoot = hook.onScheduleFiberRoot || (() => {})
379
+ hook.onScheduleFiberRoot = function (id, root, children) {
380
+ if (!isPerformingRefresh) {
381
+ // If it was intentionally scheduled, don't attempt to restore.
382
+ // This includes intentionally scheduled unmounts.
383
+ failedRoots.delete(root)
384
+ if (rootElements !== null) {
385
+ rootElements.set(root, children)
386
+ }
387
+ }
388
+ return oldOnScheduleFiberRoot.apply(this, arguments)
389
+ }
390
+ hook.onCommitFiberRoot = function (id, root, maybePriorityLevel, didError) {
391
+ const helpers = helpersByRendererID.get(id)
392
+ if (helpers !== undefined) {
393
+ helpersByRoot.set(root, helpers)
394
+
395
+ const current = root.current
396
+ const alternate = current.alternate
397
+
398
+ // We need to determine whether this root has just (un)mounted.
399
+ // This logic is copy-pasted from similar logic in the DevTools backend.
400
+ // If this breaks with some refactoring, you'll want to update DevTools too.
401
+
402
+ if (alternate !== null) {
403
+ const wasMounted =
404
+ alternate.memoizedState != null &&
405
+ alternate.memoizedState.element != null &&
406
+ mountedRoots.has(root)
407
+
408
+ const isMounted =
409
+ current.memoizedState != null && current.memoizedState.element != null
410
+
411
+ if (!wasMounted && isMounted) {
412
+ // Mount a new root.
413
+ mountedRoots.add(root)
414
+ failedRoots.delete(root)
415
+ } else if (wasMounted && isMounted) {
416
+ // Update an existing root.
417
+ // This doesn't affect our mounted root Set.
418
+ } else if (wasMounted && !isMounted) {
419
+ // Unmount an existing root.
420
+ mountedRoots.delete(root)
421
+ if (didError) {
422
+ // We'll remount it on future edits.
423
+ failedRoots.add(root)
424
+ } else {
425
+ helpersByRoot.delete(root)
426
+ }
427
+ } else if (!wasMounted && !isMounted) {
428
+ if (didError) {
429
+ // We'll remount it on future edits.
430
+ failedRoots.add(root)
431
+ }
432
+ }
433
+ } else {
434
+ // Mount a new root.
435
+ mountedRoots.add(root)
436
+ }
437
+ }
438
+
439
+ // Always call the decorated DevTools hook.
440
+ return oldOnCommitFiberRoot.apply(this, arguments)
441
+ }
442
+ }
443
+
444
+ // This is a wrapper over more primitive functions for setting signature.
445
+ // Signatures let us decide whether the Hook order has changed on refresh.
446
+ //
447
+ // This function is intended to be used as a transform target, e.g.:
448
+ // var _s = createSignatureFunctionForTransform()
449
+ //
450
+ // function Hello() {
451
+ // const [foo, setFoo] = useState(0);
452
+ // const value = useCustomHook();
453
+ // _s(); /* Call without arguments triggers collecting the custom Hook list.
454
+ // * This doesn't happen during the module evaluation because we
455
+ // * don't want to change the module order with inline requires.
456
+ // * Next calls are noops. */
457
+ // return <h1>Hi</h1>;
458
+ // }
459
+ //
460
+ // /* Call with arguments attaches the signature to the type: */
461
+ // _s(
462
+ // Hello,
463
+ // 'useState{[foo, setFoo]}(0)',
464
+ // () => [useCustomHook], /* Lazy to avoid triggering inline requires */
465
+ // );
466
+ export function createSignatureFunctionForTransform() {
467
+ let savedType
468
+ let hasCustomHooks
469
+ let didCollectHooks = false
470
+ return function (type, key, forceReset, getCustomHooks) {
471
+ if (typeof key === 'string') {
472
+ // We're in the initial phase that associates signatures
473
+ // with the functions. Note this may be called multiple times
474
+ // in HOC chains like _s(hoc1(_s(hoc2(_s(actualFunction))))).
475
+ if (!savedType) {
476
+ // We're in the innermost call, so this is the actual type.
477
+ // $FlowFixMe[escaped-generic] discovered when updating Flow
478
+ savedType = type
479
+ hasCustomHooks = typeof getCustomHooks === 'function'
480
+ }
481
+ // Set the signature for all types (even wrappers!) in case
482
+ // they have no signatures of their own. This is to prevent
483
+ // problems like https://github.com/facebook/react/issues/20417.
484
+ if (
485
+ type != null &&
486
+ (typeof type === 'function' || typeof type === 'object')
487
+ ) {
488
+ setSignature(type, key, forceReset, getCustomHooks)
489
+ }
490
+ return type
491
+ } else {
492
+ // We're in the _s() call without arguments, which means
493
+ // this is the time to collect custom Hook signatures.
494
+ // Only do this once. This path is hot and runs *inside* every render!
495
+ if (!didCollectHooks && hasCustomHooks) {
496
+ didCollectHooks = true
497
+ collectCustomHooksForSignature(savedType)
498
+ }
499
+ }
500
+ }
501
+ }
502
+
503
+ function isLikelyComponentType(type) {
504
+ switch (typeof type) {
505
+ case 'function': {
506
+ // First, deal with classes.
507
+ if (type.prototype != null) {
508
+ if (type.prototype.isReactComponent) {
509
+ // React class.
510
+ return true
511
+ }
512
+ const ownNames = Object.getOwnPropertyNames(type.prototype)
513
+ if (ownNames.length > 1 || ownNames[0] !== 'constructor') {
514
+ // This looks like a class.
515
+ return false
516
+ }
517
+
518
+ if (type.prototype.__proto__ !== Object.prototype) {
519
+ // It has a superclass.
520
+ return false
521
+ }
522
+ // Pass through.
523
+ // This looks like a regular function with empty prototype.
524
+ }
525
+ // For plain functions and arrows, use name as a heuristic.
526
+ const name = type.name || type.displayName
527
+ return typeof name === 'string' && /^[A-Z]/.test(name)
528
+ }
529
+ case 'object': {
530
+ if (type != null) {
531
+ switch (getProperty(type, '$$typeof')) {
532
+ case REACT_FORWARD_REF_TYPE:
533
+ case REACT_MEMO_TYPE:
534
+ // Definitely React components.
535
+ return true
536
+ default:
537
+ return false
538
+ }
539
+ }
540
+ return false
541
+ }
542
+ default: {
543
+ return false
544
+ }
545
+ }
546
+ }
547
+
548
+ /**
549
+ * Plugin utils
550
+ */
551
+
552
+ export function getRefreshReg(filename) {
553
+ return (type, id) => register(type, filename + ' ' + id)
554
+ }
555
+
556
+ // Taken from https://github.com/pmmmwh/react-refresh-webpack-plugin/blob/main/lib/runtime/RefreshUtils.js#L141
557
+ // This allows to resister components not detected by SWC like styled component
558
+ export function registerExportsForReactRefresh(filename, moduleExports) {
559
+ for (const key in moduleExports) {
560
+ if (key === '__esModule') continue
561
+ const exportValue = moduleExports[key]
562
+ if (isLikelyComponentType(exportValue)) {
563
+ // 'export' is required to avoid key collision when renamed exports that
564
+ // shadow a local component name: https://github.com/vitejs/vite-plugin-react/issues/116
565
+ // The register function has an identity check to not register twice the same component,
566
+ // so this is safe to not used the same key here.
567
+ register(exportValue, filename + ' export ' + key)
568
+ }
569
+ }
570
+ }
571
+
572
+ function debounce(fn, delay) {
573
+ let handle
574
+ return () => {
575
+ clearTimeout(handle)
576
+ handle = setTimeout(fn, delay)
577
+ }
578
+ }
579
+
580
+ const hooks = []
581
+ window.__registerBeforePerformReactRefresh = (cb) => {
582
+ hooks.push(cb)
583
+ }
584
+ const enqueueUpdate = debounce(async () => {
585
+ if (hooks.length) await Promise.all(hooks.map((cb) => cb()))
586
+ performReactRefresh()
587
+ }, 16)
588
+
589
+ export function validateRefreshBoundaryAndEnqueueUpdate(
590
+ id,
591
+ prevExports,
592
+ nextExports,
593
+ ) {
594
+ const ignoredExports = window.__getReactRefreshIgnoredExports?.({ id }) ?? []
595
+ if (
596
+ predicateOnExport(
597
+ ignoredExports,
598
+ prevExports,
599
+ (key) => key in nextExports,
600
+ ) !== true
601
+ ) {
602
+ return 'Could not Fast Refresh (export removed)'
603
+ }
604
+ if (
605
+ predicateOnExport(
606
+ ignoredExports,
607
+ nextExports,
608
+ (key) => key in prevExports,
609
+ ) !== true
610
+ ) {
611
+ return 'Could not Fast Refresh (new export)'
612
+ }
613
+
614
+ let hasExports = false
615
+ const allExportsAreComponentsOrUnchanged = predicateOnExport(
616
+ ignoredExports,
617
+ nextExports,
618
+ (key, value) => {
619
+ hasExports = true
620
+ if (isLikelyComponentType(value)) return true
621
+ return prevExports[key] === nextExports[key]
622
+ },
623
+ )
624
+ if (hasExports && allExportsAreComponentsOrUnchanged === true) {
625
+ enqueueUpdate()
626
+ } else {
627
+ return `Could not Fast Refresh ("${allExportsAreComponentsOrUnchanged}" export is incompatible). Learn more at __README_URL__#consistent-components-exports`
628
+ }
629
+ }
630
+
631
+ function predicateOnExport(ignoredExports, moduleExports, predicate) {
632
+ for (const key in moduleExports) {
633
+ if (key === '__esModule') continue
634
+ if (ignoredExports.includes(key)) continue
635
+ const desc = Object.getOwnPropertyDescriptor(moduleExports, key)
636
+ if (desc && desc.get) return key
637
+ if (!predicate(key, moduleExports[key])) return key
638
+ }
639
+ return true
640
+ }
641
+
642
+ // Hides vite-ignored dynamic import so that Vite can skip analysis if no other
643
+ // dynamic import is present (https://github.com/vitejs/vite/pull/12732)
644
+ export const __hmr_import = (module) => import(/* @vite-ignore */ module)
645
+
646
+ // For backwards compatibility with @vitejs/plugin-react.
647
+ export default { injectIntoGlobalHook }
package/package.json CHANGED
@@ -1,8 +1,17 @@
1
1
  {
2
2
  "name": "@vitejs/plugin-react",
3
- "version": "4.3.3",
3
+ "version": "4.4.0-beta.1",
4
4
  "license": "MIT",
5
5
  "author": "Evan You",
6
+ "description": "The default Vite plugin for React projects",
7
+ "keywords": [
8
+ "vite",
9
+ "vite-plugin",
10
+ "react",
11
+ "babel",
12
+ "react-refresh",
13
+ "fast refresh"
14
+ ],
6
15
  "contributors": [
7
16
  "Alec Larson",
8
17
  "Arnaud Barré"
@@ -10,6 +19,7 @@
10
19
  "files": [
11
20
  "dist"
12
21
  ],
22
+ "type": "module",
13
23
  "main": "./dist/index.cjs",
14
24
  "module": "./dist/index.mjs",
15
25
  "types": "./dist/index.d.ts",
@@ -21,7 +31,7 @@
21
31
  },
22
32
  "scripts": {
23
33
  "dev": "unbuild --stub",
24
- "build": "unbuild && pnpm run patch-cjs && tsx scripts/copyRefreshUtils.ts",
34
+ "build": "unbuild && pnpm run patch-cjs && tsx scripts/copyRefreshRuntime.ts",
25
35
  "patch-cjs": "tsx ../../scripts/patchCJS.ts",
26
36
  "prepublishOnly": "npm run build"
27
37
  },
@@ -38,16 +48,17 @@
38
48
  },
39
49
  "homepage": "https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react#readme",
40
50
  "dependencies": {
41
- "@babel/core": "^7.25.2",
42
- "@babel/plugin-transform-react-jsx-self": "^7.24.7",
43
- "@babel/plugin-transform-react-jsx-source": "^7.24.7",
51
+ "@babel/core": "^7.26.0",
52
+ "@babel/plugin-transform-react-jsx-self": "^7.25.9",
53
+ "@babel/plugin-transform-react-jsx-source": "^7.25.9",
44
54
  "@types/babel__core": "^7.20.5",
45
55
  "react-refresh": "^0.14.2"
46
56
  },
47
57
  "peerDependencies": {
48
- "vite": "^4.2.0 || ^5.0.0"
58
+ "vite": "^4.2.0 || ^5.0.0 || ^6.0.0"
49
59
  },
50
60
  "devDependencies": {
51
- "unbuild": "^2.0.0"
61
+ "@vitejs/react-common": "workspace:*",
62
+ "unbuild": "^3.5.0"
52
63
  }
53
64
  }