rari 0.2.6 → 0.2.7
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/client.d.ts +1 -1
- package/dist/client.js +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +4 -4
- package/dist/{runtime-client-P4vvSVPV.d.ts → runtime-client-BEWMJWMx.d.ts} +0 -1
- package/dist/{runtime-client-CcEhh-F7.js → runtime-client-CC4YQweh.js} +18 -48
- package/dist/{server-Ph4oyo0B.d.ts → server-MY0-nRif.d.ts} +2 -47
- package/dist/{server-MkYb94pQ.js → server-_LR44Mbg.js} +34 -258
- package/dist/server-build-CLt2Us53.js +3 -0
- package/dist/{server-build-DaBgiV55.js → server-build-DyMLcQhk.js} +6 -3
- package/dist/server.d.ts +3 -3
- package/dist/server.js +4 -4
- package/package.json +7 -12
- package/src/client.ts +10 -3
- package/src/router/index.ts +6 -12
- package/src/router/router.tsx +45 -101
- package/src/router/types.ts +1 -2
- package/src/server.ts +14 -5
- package/src/vite/index.ts +25 -242
- package/dist/client-dev.d.ts +0 -2
- package/dist/client-dev.js +0 -3
- package/dist/server-build-Cp6_RdeA.js +0 -3
- package/src/client-dev.ts +0 -59
package/src/router/router.tsx
CHANGED
|
@@ -47,9 +47,10 @@ export function RouterProvider({
|
|
|
47
47
|
}),
|
|
48
48
|
[config],
|
|
49
49
|
)
|
|
50
|
+
const [currentRoute, setCurrentRoute] = useState<RouteMatch | null>(null)
|
|
50
51
|
|
|
51
|
-
const
|
|
52
|
-
(url: string)
|
|
52
|
+
const updateCurrentRoute = useCallback(
|
|
53
|
+
(url: string) => {
|
|
53
54
|
const { pathname, search, hash, searchParams } = parseUrl(url)
|
|
54
55
|
const normalizedPathname = normalizePathname(pathname)
|
|
55
56
|
|
|
@@ -63,56 +64,17 @@ export function RouterProvider({
|
|
|
63
64
|
hash,
|
|
64
65
|
}
|
|
65
66
|
|
|
66
|
-
enhancedMatch.childMatch = findDeepestChildMatch(
|
|
67
|
-
enhancedMatch,
|
|
68
|
-
normalizedPathname,
|
|
69
|
-
)
|
|
70
|
-
return enhancedMatch
|
|
71
|
-
}
|
|
67
|
+
enhancedMatch.childMatch = findDeepestChildMatch(enhancedMatch, normalizedPathname)
|
|
72
68
|
|
|
73
|
-
|
|
69
|
+
setCurrentRoute(enhancedMatch)
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
setCurrentRoute(null)
|
|
73
|
+
}
|
|
74
74
|
},
|
|
75
75
|
[routes],
|
|
76
76
|
)
|
|
77
77
|
|
|
78
|
-
const [routerState, setRouterState] = useState<{
|
|
79
|
-
currentRoute: RouteMatch | null
|
|
80
|
-
isReady: boolean
|
|
81
|
-
}>(() => {
|
|
82
|
-
if (typeof window === 'undefined') {
|
|
83
|
-
return { currentRoute: null, isReady: false }
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const url = mergedConfig.useHash
|
|
87
|
-
? window.location.hash.slice(1) || '/'
|
|
88
|
-
: window.location.pathname
|
|
89
|
-
+ window.location.search
|
|
90
|
-
+ window.location.hash
|
|
91
|
-
|
|
92
|
-
let initialRoute
|
|
93
|
-
try {
|
|
94
|
-
initialRoute = resolveRoute(url)
|
|
95
|
-
}
|
|
96
|
-
catch (error) {
|
|
97
|
-
console.error('Error resolving initial route:', error)
|
|
98
|
-
initialRoute = null
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
const isReady = true
|
|
102
|
-
return { currentRoute: initialRoute, isReady }
|
|
103
|
-
})
|
|
104
|
-
|
|
105
|
-
const currentRoute = routerState.currentRoute
|
|
106
|
-
const isReady = routerState.isReady
|
|
107
|
-
|
|
108
|
-
const updateCurrentRoute = useCallback(
|
|
109
|
-
(url: string) => {
|
|
110
|
-
const route = resolveRoute(url)
|
|
111
|
-
setRouterState({ currentRoute: route, isReady: true })
|
|
112
|
-
},
|
|
113
|
-
[resolveRoute],
|
|
114
|
-
)
|
|
115
|
-
|
|
116
78
|
useEffect(() => {
|
|
117
79
|
const handleLocationChange = () => {
|
|
118
80
|
const url = mergedConfig.useHash
|
|
@@ -124,6 +86,8 @@ export function RouterProvider({
|
|
|
124
86
|
updateCurrentRoute(url)
|
|
125
87
|
}
|
|
126
88
|
|
|
89
|
+
handleLocationChange()
|
|
90
|
+
|
|
127
91
|
const handlePopState = () => {
|
|
128
92
|
handleLocationChange()
|
|
129
93
|
}
|
|
@@ -211,8 +175,8 @@ export function RouterProvider({
|
|
|
211
175
|
[currentRoute],
|
|
212
176
|
)
|
|
213
177
|
|
|
214
|
-
const contextValue: IRouterContext = useMemo(
|
|
215
|
-
|
|
178
|
+
const contextValue: IRouterContext = useMemo(
|
|
179
|
+
() => ({
|
|
216
180
|
currentRoute,
|
|
217
181
|
routes,
|
|
218
182
|
navigate,
|
|
@@ -221,19 +185,18 @@ export function RouterProvider({
|
|
|
221
185
|
replace,
|
|
222
186
|
isActive,
|
|
223
187
|
config: mergedConfig,
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
])
|
|
188
|
+
}),
|
|
189
|
+
[
|
|
190
|
+
currentRoute,
|
|
191
|
+
routes,
|
|
192
|
+
navigate,
|
|
193
|
+
back,
|
|
194
|
+
forward,
|
|
195
|
+
replace,
|
|
196
|
+
isActive,
|
|
197
|
+
mergedConfig,
|
|
198
|
+
],
|
|
199
|
+
)
|
|
237
200
|
|
|
238
201
|
return <RouterContext value={contextValue}>{children}</RouterContext>
|
|
239
202
|
}
|
|
@@ -281,7 +244,8 @@ export function useParams() {
|
|
|
281
244
|
}
|
|
282
245
|
|
|
283
246
|
export function useSearchParams() {
|
|
284
|
-
const { currentRoute
|
|
247
|
+
const { currentRoute } = useRouter()
|
|
248
|
+
const { navigate } = useRouter()
|
|
285
249
|
|
|
286
250
|
const searchParams = currentRoute?.searchParams || {}
|
|
287
251
|
|
|
@@ -290,7 +254,7 @@ export function useSearchParams() {
|
|
|
290
254
|
params:
|
|
291
255
|
| Record<string, string | string[]>
|
|
292
256
|
| ((
|
|
293
|
-
prev: Record<string, string | string[]
|
|
257
|
+
prev: Record<string, string | string[]>
|
|
294
258
|
) => Record<string, string | string[]>),
|
|
295
259
|
options: NavigationOptions = DEFAULT_CONFIG,
|
|
296
260
|
) => {
|
|
@@ -393,25 +357,16 @@ export function Outlet() {
|
|
|
393
357
|
return null
|
|
394
358
|
}
|
|
395
359
|
|
|
396
|
-
return
|
|
397
|
-
<ChildComponent
|
|
398
|
-
{...childRoute.params}
|
|
399
|
-
searchParams={childRoute.searchParams}
|
|
400
|
-
/>
|
|
401
|
-
)
|
|
360
|
+
return <ChildComponent {...childRoute.params} searchParams={childRoute.searchParams} />
|
|
402
361
|
}
|
|
403
362
|
|
|
404
|
-
function findChildRouteForCurrentLevel(
|
|
405
|
-
currentRoute: RouteMatch,
|
|
406
|
-
): RouteMatch | null {
|
|
363
|
+
function findChildRouteForCurrentLevel(currentRoute: RouteMatch): RouteMatch | null {
|
|
407
364
|
if (currentRoute.childMatch) {
|
|
408
365
|
return currentRoute.childMatch
|
|
409
366
|
}
|
|
410
367
|
|
|
411
368
|
if (currentRoute.route.children) {
|
|
412
|
-
const indexRoute = currentRoute.route.children.find(
|
|
413
|
-
child => child.isIndex,
|
|
414
|
-
)
|
|
369
|
+
const indexRoute = currentRoute.route.children.find(child => child.isIndex)
|
|
415
370
|
if (indexRoute) {
|
|
416
371
|
return {
|
|
417
372
|
route: indexRoute,
|
|
@@ -430,26 +385,14 @@ function findChildRouteForCurrentLevel(
|
|
|
430
385
|
export function RouteRenderer({ routeMatch }: { routeMatch: RouteMatch }) {
|
|
431
386
|
if (!routeMatch.layouts || routeMatch.layouts.length === 0) {
|
|
432
387
|
const Component = routeMatch.route.component
|
|
433
|
-
return Component
|
|
434
|
-
? (
|
|
435
|
-
<Component
|
|
436
|
-
{...routeMatch.params}
|
|
437
|
-
searchParams={routeMatch.searchParams}
|
|
438
|
-
/>
|
|
439
|
-
)
|
|
440
|
-
: null
|
|
388
|
+
return Component ? <Component {...routeMatch.params} searchParams={routeMatch.searchParams} /> : null
|
|
441
389
|
}
|
|
442
390
|
|
|
443
391
|
let rendered: ReactNode = null
|
|
444
392
|
const Component = routeMatch.route.component
|
|
445
393
|
|
|
446
394
|
if (Component) {
|
|
447
|
-
rendered =
|
|
448
|
-
<Component
|
|
449
|
-
{...routeMatch.params}
|
|
450
|
-
searchParams={routeMatch.searchParams}
|
|
451
|
-
/>
|
|
452
|
-
)
|
|
395
|
+
rendered = <Component {...routeMatch.params} searchParams={routeMatch.searchParams} />
|
|
453
396
|
}
|
|
454
397
|
|
|
455
398
|
for (let i = routeMatch.layouts.length - 1; i >= 0; i--) {
|
|
@@ -457,9 +400,7 @@ export function RouteRenderer({ routeMatch }: { routeMatch: RouteMatch }) {
|
|
|
457
400
|
const LayoutComponent = layout.component
|
|
458
401
|
|
|
459
402
|
if (LayoutComponent) {
|
|
460
|
-
rendered =
|
|
461
|
-
<LayoutComponent route={routeMatch}>{rendered}</LayoutComponent>
|
|
462
|
-
)
|
|
403
|
+
rendered = <LayoutComponent route={routeMatch}>{rendered}</LayoutComponent>
|
|
463
404
|
}
|
|
464
405
|
}
|
|
465
406
|
|
|
@@ -487,10 +428,7 @@ export function Navigate({
|
|
|
487
428
|
export default RouterProvider
|
|
488
429
|
export { RouterContext }
|
|
489
430
|
|
|
490
|
-
function findDeepestChildMatch(
|
|
491
|
-
routeMatch: RouteMatch,
|
|
492
|
-
pathname: string,
|
|
493
|
-
): RouteMatch | null {
|
|
431
|
+
function findDeepestChildMatch(routeMatch: RouteMatch, pathname: string): RouteMatch | null {
|
|
494
432
|
if (!routeMatch.route.children || routeMatch.route.children.length === 0) {
|
|
495
433
|
return null
|
|
496
434
|
}
|
|
@@ -548,12 +486,18 @@ export function Link({
|
|
|
548
486
|
)
|
|
549
487
|
|
|
550
488
|
const isLinkActive = isActive(to, exact)
|
|
551
|
-
const finalClassName = [
|
|
552
|
-
|
|
553
|
-
|
|
489
|
+
const finalClassName = [
|
|
490
|
+
className,
|
|
491
|
+
isLinkActive && activeClassName,
|
|
492
|
+
].filter(Boolean).join(' ')
|
|
554
493
|
|
|
555
494
|
return (
|
|
556
|
-
<a
|
|
495
|
+
<a
|
|
496
|
+
href={to}
|
|
497
|
+
className={finalClassName}
|
|
498
|
+
onClick={handleClick}
|
|
499
|
+
{...props}
|
|
500
|
+
>
|
|
557
501
|
{children}
|
|
558
502
|
</a>
|
|
559
503
|
)
|
package/src/router/types.ts
CHANGED
|
@@ -75,7 +75,6 @@ export interface RouterContext {
|
|
|
75
75
|
replace: (path: string, options?: Omit<NavigationOptions, 'replace'>) => void
|
|
76
76
|
isActive: (path: string, exact?: boolean) => boolean
|
|
77
77
|
config: RouterConfig
|
|
78
|
-
isReady: boolean
|
|
79
78
|
}
|
|
80
79
|
|
|
81
80
|
export interface NavigationState {
|
|
@@ -123,7 +122,7 @@ export type RouteGenerator = (
|
|
|
123
122
|
options: RouteGenerationOptions,
|
|
124
123
|
) => Promise<Route[]>
|
|
125
124
|
|
|
126
|
-
export interface UseRouterReturn extends RouterContext {}
|
|
125
|
+
export interface UseRouterReturn extends RouterContext { }
|
|
127
126
|
|
|
128
127
|
export interface UseNavigationReturn extends NavigationState {
|
|
129
128
|
navigate: RouterContext['navigate']
|
package/src/server.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export {
|
|
2
|
+
Link,
|
|
3
|
+
} from './router'
|
|
2
4
|
|
|
3
5
|
export {
|
|
4
6
|
buildSearchString,
|
|
@@ -59,12 +61,19 @@ export {
|
|
|
59
61
|
watchFileRoutes,
|
|
60
62
|
} from './router/file-routes'
|
|
61
63
|
|
|
62
|
-
export {
|
|
64
|
+
export {
|
|
65
|
+
getRoutePriority,
|
|
66
|
+
} from './router/utils'
|
|
63
67
|
|
|
64
68
|
export { rariRouter } from './router/vite-plugin'
|
|
65
69
|
|
|
66
|
-
export {
|
|
70
|
+
export {
|
|
71
|
+
createHttpRuntimeClient,
|
|
72
|
+
HttpRuntimeClient,
|
|
73
|
+
} from './runtime-client'
|
|
67
74
|
|
|
68
|
-
export type {
|
|
75
|
+
export type {
|
|
76
|
+
RuntimeClient,
|
|
77
|
+
} from './runtime-client'
|
|
69
78
|
|
|
70
|
-
export {
|
|
79
|
+
export { defineRariConfig, rari } from './vite'
|
package/src/vite/index.ts
CHANGED
|
@@ -151,10 +151,7 @@ export function rari(options: RariOptions = {}): Plugin[] {
|
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
-
function hasTopLevelDirective(
|
|
155
|
-
code: string,
|
|
156
|
-
directive: 'use client' | 'use server',
|
|
157
|
-
): boolean {
|
|
154
|
+
function hasTopLevelDirective(code: string, directive: 'use client' | 'use server'): boolean {
|
|
158
155
|
try {
|
|
159
156
|
const ast = acorn.parse(code, {
|
|
160
157
|
ecmaVersion: 2024,
|
|
@@ -373,47 +370,30 @@ if (import.meta.hot) {
|
|
|
373
370
|
config(config: UserConfig, { command }) {
|
|
374
371
|
config.resolve = config.resolve || {}
|
|
375
372
|
const existingDedupe = Array.isArray((config.resolve as any).dedupe)
|
|
376
|
-
? (
|
|
373
|
+
? (config.resolve as any).dedupe as string[]
|
|
377
374
|
: []
|
|
378
|
-
const toAdd = ['react', 'react-dom']
|
|
379
|
-
|
|
375
|
+
const toAdd = ['react', 'react-dom']
|
|
376
|
+
; (config.resolve as any).dedupe = Array.from(
|
|
380
377
|
new Set([...(existingDedupe || []), ...toAdd]),
|
|
381
378
|
)
|
|
382
379
|
|
|
383
|
-
const
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
const existingAlias: Array<{
|
|
390
|
-
find: string | RegExp
|
|
391
|
-
replacement: string
|
|
392
|
-
}> = Array.isArray((config.resolve as any).alias)
|
|
393
|
-
? (config.resolve as any).alias
|
|
394
|
-
: []
|
|
380
|
+
const existingAlias: Array<{ find: string | RegExp, replacement: string }>
|
|
381
|
+
= Array.isArray((config.resolve as any).alias)
|
|
382
|
+
? (config.resolve as any).alias
|
|
383
|
+
: []
|
|
395
384
|
const aliasFinds = new Set(existingAlias.map(a => String(a.find)))
|
|
396
385
|
try {
|
|
397
386
|
const reactPath = require.resolve('react')
|
|
398
387
|
const reactDomClientPath = require.resolve('react-dom/client')
|
|
399
388
|
const reactJsxRuntimePath = require.resolve('react/jsx-runtime')
|
|
400
|
-
const aliasesToAppend: Array<{ find: string, replacement: string }>
|
|
401
|
-
= []
|
|
389
|
+
const aliasesToAppend: Array<{ find: string, replacement: string }> = []
|
|
402
390
|
if (!aliasFinds.has('react/jsx-runtime')) {
|
|
403
|
-
aliasesToAppend.push({
|
|
404
|
-
find: 'react/jsx-runtime',
|
|
405
|
-
replacement: reactJsxRuntimePath,
|
|
406
|
-
})
|
|
391
|
+
aliasesToAppend.push({ find: 'react/jsx-runtime', replacement: reactJsxRuntimePath })
|
|
407
392
|
}
|
|
408
393
|
try {
|
|
409
|
-
const reactJsxDevRuntimePath = require.resolve(
|
|
410
|
-
'react/jsx-dev-runtime',
|
|
411
|
-
)
|
|
394
|
+
const reactJsxDevRuntimePath = require.resolve('react/jsx-dev-runtime')
|
|
412
395
|
if (!aliasFinds.has('react/jsx-dev-runtime')) {
|
|
413
|
-
aliasesToAppend.push({
|
|
414
|
-
find: 'react/jsx-dev-runtime',
|
|
415
|
-
replacement: reactJsxDevRuntimePath,
|
|
416
|
-
})
|
|
396
|
+
aliasesToAppend.push({ find: 'react/jsx-dev-runtime', replacement: reactJsxDevRuntimePath })
|
|
417
397
|
}
|
|
418
398
|
}
|
|
419
399
|
catch { }
|
|
@@ -421,16 +401,10 @@ if (import.meta.hot) {
|
|
|
421
401
|
aliasesToAppend.push({ find: 'react', replacement: reactPath })
|
|
422
402
|
}
|
|
423
403
|
if (!aliasFinds.has('react-dom/client')) {
|
|
424
|
-
aliasesToAppend.push({
|
|
425
|
-
find: 'react-dom/client',
|
|
426
|
-
replacement: reactDomClientPath,
|
|
427
|
-
})
|
|
404
|
+
aliasesToAppend.push({ find: 'react-dom/client', replacement: reactDomClientPath })
|
|
428
405
|
}
|
|
429
406
|
if (aliasesToAppend.length > 0) {
|
|
430
|
-
(config.resolve as any).alias = [
|
|
431
|
-
...existingAlias,
|
|
432
|
-
...aliasesToAppend,
|
|
433
|
-
]
|
|
407
|
+
(config.resolve as any).alias = [...existingAlias, ...aliasesToAppend]
|
|
434
408
|
}
|
|
435
409
|
}
|
|
436
410
|
catch { }
|
|
@@ -463,22 +437,12 @@ if (import.meta.hot) {
|
|
|
463
437
|
if (!config.optimizeDeps.include.includes('react-dom/server')) {
|
|
464
438
|
config.optimizeDeps.include.push('react-dom/server')
|
|
465
439
|
}
|
|
466
|
-
if (!config.optimizeDeps.include.includes('react')) {
|
|
467
|
-
config.optimizeDeps.include.push('react')
|
|
468
|
-
}
|
|
469
|
-
if (!config.optimizeDeps.include.includes('react-dom/client')) {
|
|
470
|
-
config.optimizeDeps.include.push('react-dom/client')
|
|
471
|
-
}
|
|
472
|
-
config.optimizeDeps.exclude = config.optimizeDeps.exclude || []
|
|
473
|
-
if (!config.optimizeDeps.exclude.includes('virtual:rsc-integration')) {
|
|
474
|
-
config.optimizeDeps.exclude.push('virtual:rsc-integration')
|
|
475
|
-
}
|
|
476
440
|
|
|
477
441
|
if (command === 'build') {
|
|
478
442
|
for (const envName of ['rsc', 'ssr', 'client']) {
|
|
479
443
|
const env = config.environments[envName]
|
|
480
444
|
if (env && env.build) {
|
|
481
|
-
env.build.
|
|
445
|
+
env.build.rollupOptions = env.build.rollupOptions || {}
|
|
482
446
|
}
|
|
483
447
|
}
|
|
484
448
|
}
|
|
@@ -514,219 +478,38 @@ if (import.meta.hot) {
|
|
|
514
478
|
|
|
515
479
|
if (command === 'build') {
|
|
516
480
|
config.build = config.build || {}
|
|
517
|
-
config.build.
|
|
481
|
+
config.build.rollupOptions = config.build.rollupOptions || {}
|
|
518
482
|
|
|
519
|
-
if (!config.build.
|
|
520
|
-
config.build.
|
|
483
|
+
if (!config.build.rollupOptions.input) {
|
|
484
|
+
config.build.rollupOptions.input = {
|
|
521
485
|
main: './index.html',
|
|
522
486
|
}
|
|
523
487
|
}
|
|
524
|
-
|
|
525
|
-
config.build.rolldownOptions.output
|
|
526
|
-
= config.build.rolldownOptions.output || {}
|
|
527
|
-
const outputConfig = Array.isArray(config.build.rolldownOptions.output)
|
|
528
|
-
? config.build.rolldownOptions.output[0] || {}
|
|
529
|
-
: config.build.rolldownOptions.output
|
|
530
|
-
|
|
531
|
-
outputConfig.manualChunks
|
|
532
|
-
= outputConfig.manualChunks
|
|
533
|
-
|| ((id) => {
|
|
534
|
-
if (id.includes('react-dom')) {
|
|
535
|
-
return 'react-dom'
|
|
536
|
-
}
|
|
537
|
-
if (id.includes('react') && !id.includes('react-dom')) {
|
|
538
|
-
return 'react'
|
|
539
|
-
}
|
|
540
|
-
if (id.includes('markdown-it') || id.includes('shiki')) {
|
|
541
|
-
return 'vendor'
|
|
542
|
-
}
|
|
543
|
-
if (id.includes('node_modules')) {
|
|
544
|
-
return 'vendor'
|
|
545
|
-
}
|
|
546
|
-
})
|
|
547
|
-
|
|
548
|
-
config.build.rolldownOptions.treeshake = config.build.rolldownOptions
|
|
549
|
-
.treeshake || {
|
|
550
|
-
moduleSideEffects: (id) => {
|
|
551
|
-
if (id.includes('.css') || id.includes('polyfill')) {
|
|
552
|
-
return true
|
|
553
|
-
}
|
|
554
|
-
if (
|
|
555
|
-
id.includes('react-dom')
|
|
556
|
-
|| id.includes('react')
|
|
557
|
-
|| id.includes('scheduler')
|
|
558
|
-
) {
|
|
559
|
-
return false
|
|
560
|
-
}
|
|
561
|
-
return false
|
|
562
|
-
},
|
|
563
|
-
unknownGlobalSideEffects: false,
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
const existingExternal = config.build.rolldownOptions.external || []
|
|
567
|
-
const reactDomExternals = [
|
|
568
|
-
'react-dom/profiling',
|
|
569
|
-
'react-dom/test-utils',
|
|
570
|
-
'react-dom/server',
|
|
571
|
-
'react-dom/server.browser',
|
|
572
|
-
'react-dom/server.node',
|
|
573
|
-
'react/jsx-dev-runtime',
|
|
574
|
-
'scheduler/tracing',
|
|
575
|
-
'scheduler/unstable_mock',
|
|
576
|
-
'react/cjs/react.development.js',
|
|
577
|
-
'react/cjs/react.production.min.js',
|
|
578
|
-
'react-dom/cjs/react-dom.development.js',
|
|
579
|
-
'react-dom/cjs/react-dom.production.min.js',
|
|
580
|
-
]
|
|
581
|
-
|
|
582
|
-
if (Array.isArray(existingExternal)) {
|
|
583
|
-
const external = [...existingExternal]
|
|
584
|
-
external.push(
|
|
585
|
-
...reactDomExternals.filter(dep => !external.includes(dep)),
|
|
586
|
-
)
|
|
587
|
-
config.build.rolldownOptions.external = external
|
|
588
|
-
}
|
|
589
|
-
else if (typeof existingExternal === 'function') {
|
|
590
|
-
const originalExternal = existingExternal
|
|
591
|
-
config.build.rolldownOptions.external = (id, parentId, isResolved) => {
|
|
592
|
-
if (reactDomExternals.includes(id))
|
|
593
|
-
return true
|
|
594
|
-
return originalExternal(id, parentId, isResolved)
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
else {
|
|
598
|
-
config.build.rolldownOptions.external = [
|
|
599
|
-
...(Array.isArray(existingExternal)
|
|
600
|
-
? existingExternal
|
|
601
|
-
: [existingExternal]),
|
|
602
|
-
...reactDomExternals,
|
|
603
|
-
].filter(Boolean)
|
|
604
|
-
}
|
|
605
|
-
|
|
606
|
-
config.build.minify = config.build.minify !== false ? 'terser' : false
|
|
607
|
-
config.build.target = config.build.target || [
|
|
608
|
-
'es2020',
|
|
609
|
-
'edge88',
|
|
610
|
-
'firefox78',
|
|
611
|
-
'chrome87',
|
|
612
|
-
'safari14',
|
|
613
|
-
]
|
|
614
|
-
config.build.cssMinify
|
|
615
|
-
= config.build.cssMinify !== false ? 'esbuild' : false
|
|
616
|
-
config.build.sourcemap
|
|
617
|
-
= config.build.sourcemap !== undefined ? config.build.sourcemap : false
|
|
618
|
-
|
|
619
|
-
config.build.terserOptions = config.build.terserOptions || {
|
|
620
|
-
compress: {
|
|
621
|
-
drop_console: true,
|
|
622
|
-
drop_debugger: true,
|
|
623
|
-
pure_funcs: ['console.log', 'console.info', 'console.debug'],
|
|
624
|
-
passes: 2,
|
|
625
|
-
},
|
|
626
|
-
mangle: {
|
|
627
|
-
safari10: true,
|
|
628
|
-
},
|
|
629
|
-
format: {
|
|
630
|
-
comments: false,
|
|
631
|
-
},
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
outputConfig.format = outputConfig.format || 'es'
|
|
635
|
-
outputConfig.minify = true
|
|
636
|
-
|
|
637
|
-
if (Array.isArray(config.build.rolldownOptions.output)) {
|
|
638
|
-
config.build.rolldownOptions.output[0] = outputConfig
|
|
639
|
-
}
|
|
640
|
-
else {
|
|
641
|
-
config.build.rolldownOptions.output = outputConfig
|
|
642
|
-
}
|
|
643
488
|
}
|
|
644
489
|
|
|
645
490
|
if (config.environments && config.environments.client) {
|
|
646
491
|
if (!config.environments.client.build) {
|
|
647
492
|
config.environments.client.build = {}
|
|
648
493
|
}
|
|
649
|
-
if (!config.environments.client.build.
|
|
650
|
-
config.environments.client.build.
|
|
494
|
+
if (!config.environments.client.build.rollupOptions) {
|
|
495
|
+
config.environments.client.build.rollupOptions = {}
|
|
651
496
|
}
|
|
652
|
-
if (!config.environments.client.build.
|
|
653
|
-
config.environments.client.build.
|
|
497
|
+
if (!config.environments.client.build.rollupOptions.input) {
|
|
498
|
+
config.environments.client.build.rollupOptions.input = {}
|
|
654
499
|
}
|
|
655
500
|
|
|
656
501
|
if (
|
|
657
|
-
typeof config.environments.client.build.
|
|
502
|
+
typeof config.environments.client.build.rollupOptions.input
|
|
658
503
|
=== 'object'
|
|
659
|
-
&& !Array.isArray(config.environments.client.build.
|
|
504
|
+
&& !Array.isArray(config.environments.client.build.rollupOptions.input)
|
|
660
505
|
) {
|
|
661
506
|
(
|
|
662
|
-
config.environments.client.build.
|
|
507
|
+
config.environments.client.build.rollupOptions.input as Record<
|
|
663
508
|
string,
|
|
664
509
|
string
|
|
665
510
|
>
|
|
666
511
|
)['client-components'] = 'virtual:rsc-client-components'
|
|
667
512
|
}
|
|
668
|
-
|
|
669
|
-
config.environments.client.build.minify
|
|
670
|
-
= config.environments.client.build.minify !== false ? 'esbuild' : false
|
|
671
|
-
config.environments.client.build.target = config.environments.client
|
|
672
|
-
.build
|
|
673
|
-
.target || [
|
|
674
|
-
'es2020',
|
|
675
|
-
'edge88',
|
|
676
|
-
'firefox78',
|
|
677
|
-
'chrome87',
|
|
678
|
-
'safari14',
|
|
679
|
-
]
|
|
680
|
-
config.environments.client.build.cssMinify = 'esbuild'
|
|
681
|
-
config.environments.client.build.rolldownOptions.treeshake = {
|
|
682
|
-
moduleSideEffects: false,
|
|
683
|
-
unknownGlobalSideEffects: false,
|
|
684
|
-
}
|
|
685
|
-
|
|
686
|
-
config.environments.client.build.rolldownOptions.output
|
|
687
|
-
= config.environments.client.build.rolldownOptions.output || {}
|
|
688
|
-
const clientOutputConfig = Array.isArray(
|
|
689
|
-
config.environments.client.build.rolldownOptions.output,
|
|
690
|
-
)
|
|
691
|
-
? config.environments.client.build.rolldownOptions.output[0] || {}
|
|
692
|
-
: config.environments.client.build.rolldownOptions.output
|
|
693
|
-
|
|
694
|
-
clientOutputConfig.manualChunks
|
|
695
|
-
= clientOutputConfig.manualChunks
|
|
696
|
-
|| ((id) => {
|
|
697
|
-
if (id.includes('react-dom')) {
|
|
698
|
-
return 'react-dom'
|
|
699
|
-
}
|
|
700
|
-
if (id.includes('react') && !id.includes('react-dom')) {
|
|
701
|
-
return 'react'
|
|
702
|
-
}
|
|
703
|
-
if (
|
|
704
|
-
id.includes('rari')
|
|
705
|
-
&& (id.includes('router') || id.includes('navigation'))
|
|
706
|
-
) {
|
|
707
|
-
return 'router'
|
|
708
|
-
}
|
|
709
|
-
if (id.includes('markdown-it') || id.includes('shiki')) {
|
|
710
|
-
return 'vendor'
|
|
711
|
-
}
|
|
712
|
-
if (id.includes('node_modules')) {
|
|
713
|
-
return 'vendor'
|
|
714
|
-
}
|
|
715
|
-
})
|
|
716
|
-
|
|
717
|
-
clientOutputConfig.format = clientOutputConfig.format || 'es'
|
|
718
|
-
clientOutputConfig.minify = true
|
|
719
|
-
|
|
720
|
-
if (
|
|
721
|
-
Array.isArray(config.environments.client.build.rolldownOptions.output)
|
|
722
|
-
) {
|
|
723
|
-
config.environments.client.build.rolldownOptions.output[0]
|
|
724
|
-
= clientOutputConfig
|
|
725
|
-
}
|
|
726
|
-
else {
|
|
727
|
-
config.environments.client.build.rolldownOptions.output
|
|
728
|
-
= clientOutputConfig
|
|
729
|
-
}
|
|
730
513
|
}
|
|
731
514
|
|
|
732
515
|
return config
|
package/dist/client-dev.d.ts
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { ErrorBoundaryProps, FileRouteInfo, HttpRuntimeClient, LayoutProps, Link, LinkProps, LoadingProps, Navigate, NavigationOptions, NavigationState, Outlet, PageComponent, PageProps, Route, RouteComponent, RouteGenerationOptions, RouteMatch, RouteMeta, RouteParams, RouterConfig, RouterContext, RouterProvider, RouterProviderProps, Routes, RuntimeClient, SearchParams, buildSearchString, buildUrl, createHttpRuntimeClient, extractParamNames, findMatchingRoute, isDynamicRoute, isPathActive, joinPaths, normalizePathname, parseSearchParams, parseUrl, useNavigation, useParams, usePathname, useRoute, useRouter, useSearchParams, withRouter } from "./runtime-client-P4vvSVPV.js";
|
|
2
|
-
export { type ErrorBoundaryProps, type FileRouteInfo, HttpRuntimeClient, type LayoutProps, Link, type LinkProps, type LoadingProps, Navigate, type NavigationOptions, type NavigationState, Outlet, type PageComponent, type PageProps, RouteComponent as Route, type RouteGenerationOptions, type RouteMatch, type RouteMeta, type RouteParams, type Route as RouteType, type RouterConfig, type RouterContext, RouterProvider, type RouterProviderProps, Routes, type RuntimeClient, type SearchParams, buildSearchString, buildUrl, createHttpRuntimeClient, extractParamNames, findMatchingRoute, isDynamicRoute, isPathActive, joinPaths, normalizePathname, parseSearchParams, parseUrl, useNavigation, useParams, usePathname, useRoute, useRouter, useSearchParams, withRouter };
|
package/dist/client-dev.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { HttpRuntimeClient, Link, Navigate, Outlet, RouteComponent, Routes, buildSearchString, buildUrl, createHttpRuntimeClient, extractParamNames, findMatchingRoute, isDynamicRoute, isPathActive, joinPaths, normalizePathname, parseSearchParams, parseUrl, router_default, useNavigation, useParams, usePathname, useRoute, useRouter, useSearchParams, withRouter } from "./runtime-client-CcEhh-F7.js";
|
|
2
|
-
|
|
3
|
-
export { HttpRuntimeClient, Link, Navigate, Outlet, RouteComponent as Route, router_default as RouterProvider, Routes, buildSearchString, buildUrl, createHttpRuntimeClient, extractParamNames, findMatchingRoute, isDynamicRoute, isPathActive, joinPaths, normalizePathname, parseSearchParams, parseUrl, useNavigation, useParams, usePathname, useRoute, useRouter, useSearchParams, withRouter };
|