File tree Expand file tree Collapse file tree 2 files changed +19
-6
lines changed Expand file tree Collapse file tree 2 files changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,23 @@ export type {
12
12
WithReactPlugin ,
13
13
} from './schema'
14
14
15
+ function hasRootExport (
16
+ exportsField ?: Record < string , unknown > | string ,
17
+ ) : boolean {
18
+ if ( ! exportsField ) return false
19
+
20
+ if ( typeof exportsField === 'string' ) {
21
+ // shorthand form: "exports": "./index.js"
22
+ return true
23
+ }
24
+
25
+ if ( typeof exportsField === 'object' ) {
26
+ return '.' in exportsField
27
+ }
28
+
29
+ return false
30
+ }
31
+
15
32
export function TanStackStartVitePlugin (
16
33
opts ?: TanStackStartInputConfig & WithReactPlugin ,
17
34
) : Array < PluginOption > {
@@ -104,11 +121,7 @@ export default createStartHandler({
104
121
if ( opts . name === '@tanstack/react-router-devtools' ) {
105
122
return 'exclude'
106
123
}
107
- if (
108
- opts . exports &&
109
- '.' in opts . exports &&
110
- 'react' in opts . peerDependencies
111
- ) {
124
+ if ( hasRootExport ( opts . exports ) && 'react' in opts . peerDependencies ) {
112
125
return 'include'
113
126
}
114
127
return undefined
Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ export interface TanStackStartVitePluginCoreOptions {
47
47
crawlPackages ?: ( opts : {
48
48
name : string
49
49
peerDependencies : Record < string , any >
50
- exports ?: Record < string , any >
50
+ exports ?: Record < string , any > | string
51
51
} ) => 'include' | 'exclude' | undefined
52
52
}
53
53
// this needs to live outside of the TanStackStartVitePluginCore since it will be invoked multiple times by vite
You can’t perform that action at this time.
0 commit comments