Skip to content

Commit 6e191fd

Browse files
fix: account for exports being a string (#4859)
fixes #4858
1 parent 75615f3 commit 6e191fd

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

packages/react-start-plugin/src/index.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,23 @@ export type {
1212
WithReactPlugin,
1313
} from './schema'
1414

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+
1532
export function TanStackStartVitePlugin(
1633
opts?: TanStackStartInputConfig & WithReactPlugin,
1734
): Array<PluginOption> {
@@ -104,11 +121,7 @@ export default createStartHandler({
104121
if (opts.name === '@tanstack/react-router-devtools') {
105122
return 'exclude'
106123
}
107-
if (
108-
opts.exports &&
109-
'.' in opts.exports &&
110-
'react' in opts.peerDependencies
111-
) {
124+
if (hasRootExport(opts.exports) && 'react' in opts.peerDependencies) {
112125
return 'include'
113126
}
114127
return undefined

packages/start-plugin-core/src/plugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export interface TanStackStartVitePluginCoreOptions {
4747
crawlPackages?: (opts: {
4848
name: string
4949
peerDependencies: Record<string, any>
50-
exports?: Record<string, any>
50+
exports?: Record<string, any> | string
5151
}) => 'include' | 'exclude' | undefined
5252
}
5353
// this needs to live outside of the TanStackStartVitePluginCore since it will be invoked multiple times by vite

0 commit comments

Comments
 (0)