rari 0.2.1 → 0.2.3
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-dev.d.ts +2 -0
- package/dist/client-dev.js +3 -0
- package/dist/client.d.ts +1 -1
- package/dist/client.js +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/{runtime-client-CC4YQweh.js → runtime-client-CcEhh-F7.js} +48 -18
- package/dist/{runtime-client-BEWMJWMx.d.ts → runtime-client-P4vvSVPV.d.ts} +1 -0
- package/dist/{server-DeSCwqZZ.js → server-BwDou3Zb.js} +256 -33
- package/dist/{server-MY0-nRif.d.ts → server-Ph4oyo0B.d.ts} +47 -2
- package/dist/server.d.ts +3 -3
- package/dist/server.js +3 -3
- package/package.json +12 -7
- package/src/client-dev.ts +59 -0
- package/src/client.ts +3 -10
- package/src/router/index.ts +12 -6
- package/src/router/router.tsx +101 -45
- package/src/router/types.ts +2 -1
- package/src/server.ts +5 -14
- package/src/vite/index.ts +475 -48
|
@@ -0,0 +1,2 @@
|
|
|
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 };
|
|
@@ -0,0 +1,3 @@
|
|
|
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 };
|
package/dist/client.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
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-
|
|
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
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.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
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-
|
|
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
2
|
|
|
3
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
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, getRoutePriority, isDynamicRoute, isPathActive, joinPaths, normalizePathname, parseSearchParams, parseUrl, useNavigation, useParams, usePathname, useRoute, useRouter, useSearchParams, withRouter } from "./runtime-client-
|
|
2
|
-
import { FileRouteGenerator, convertFilePatternToRoutePattern, createRouteManifest, defineRariConfig, generateFileRoutes, loadRouteManifest, rari, rariRouter, validateRoutes, watchFileRoutes } from "./server-
|
|
3
|
-
export { ErrorBoundaryProps, FileRouteGenerator, FileRouteInfo, HttpRuntimeClient, LayoutProps, Link, LinkProps, LoadingProps, Navigate, NavigationOptions, NavigationState, Outlet, PageComponent, PageProps, RouteComponent as Route, RouteGenerationOptions, RouteMatch, RouteMeta, RouteParams, Route as RouteType, RouterConfig, RouterContext, RouterProvider, RouterProviderProps, Routes, RuntimeClient, SearchParams, buildSearchString, buildUrl, convertFilePatternToRoutePattern, createHttpRuntimeClient, createRouteManifest, defineRariConfig, extractParamNames, findMatchingRoute, generateFileRoutes, getRoutePriority, isDynamicRoute, isPathActive, joinPaths, loadRouteManifest, normalizePathname, parseSearchParams, parseUrl, rari, rariRouter, useNavigation, useParams, usePathname, useRoute, useRouter, useSearchParams, validateRoutes, watchFileRoutes, withRouter };
|
|
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, getRoutePriority, isDynamicRoute, isPathActive, joinPaths, normalizePathname, parseSearchParams, parseUrl, useNavigation, useParams, usePathname, useRoute, useRouter, useSearchParams, withRouter } from "./runtime-client-P4vvSVPV.js";
|
|
2
|
+
import { FileRouteGenerator, convertFilePatternToRoutePattern, createReactDOMOptimization, createRouteManifest, defineRariConfig, generateFileRoutes, loadRouteManifest, rari, rariRouter, validateRoutes, watchFileRoutes } from "./server-Ph4oyo0B.js";
|
|
3
|
+
export { ErrorBoundaryProps, FileRouteGenerator, FileRouteInfo, HttpRuntimeClient, LayoutProps, Link, LinkProps, LoadingProps, Navigate, NavigationOptions, NavigationState, Outlet, PageComponent, PageProps, RouteComponent as Route, RouteGenerationOptions, RouteMatch, RouteMeta, RouteParams, Route as RouteType, RouterConfig, RouterContext, RouterProvider, RouterProviderProps, Routes, RuntimeClient, SearchParams, buildSearchString, buildUrl, convertFilePatternToRoutePattern, createHttpRuntimeClient, createReactDOMOptimization, createRouteManifest, defineRariConfig, extractParamNames, findMatchingRoute, generateFileRoutes, getRoutePriority, isDynamicRoute, isPathActive, joinPaths, loadRouteManifest, normalizePathname, parseSearchParams, parseUrl, rari, rariRouter, useNavigation, useParams, usePathname, useRoute, useRouter, useSearchParams, validateRoutes, watchFileRoutes, withRouter };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { HttpRuntimeClient, Link, Navigate, Outlet, RouteComponent, Routes, buildSearchString, buildUrl, createHttpRuntimeClient, extractParamNames, findMatchingRoute, getRoutePriority, isDynamicRoute, isPathActive, joinPaths, normalizePathname, parseSearchParams, parseUrl, router_default, useNavigation, useParams, usePathname, useRoute, useRouter, useSearchParams, withRouter } from "./runtime-client-
|
|
2
|
-
import { FileRouteGenerator, convertFilePatternToRoutePattern, createRouteManifest, defineRariConfig, generateFileRoutes, loadRouteManifest, rari, rariRouter, validateRoutes, watchFileRoutes } from "./server-
|
|
1
|
+
import { HttpRuntimeClient, Link, Navigate, Outlet, RouteComponent, Routes, buildSearchString, buildUrl, createHttpRuntimeClient, extractParamNames, findMatchingRoute, getRoutePriority, isDynamicRoute, isPathActive, joinPaths, normalizePathname, parseSearchParams, parseUrl, router_default, useNavigation, useParams, usePathname, useRoute, useRouter, useSearchParams, withRouter } from "./runtime-client-CcEhh-F7.js";
|
|
2
|
+
import { FileRouteGenerator, convertFilePatternToRoutePattern, createReactDOMOptimization, createRouteManifest, defineRariConfig, generateFileRoutes, loadRouteManifest, rari, rariRouter, validateRoutes, watchFileRoutes } from "./server-BwDou3Zb.js";
|
|
3
3
|
import "./server-build-DaBgiV55.js";
|
|
4
4
|
|
|
5
|
-
export { FileRouteGenerator, HttpRuntimeClient, Link, Navigate, Outlet, RouteComponent as Route, router_default as RouterProvider, Routes, buildSearchString, buildUrl, convertFilePatternToRoutePattern, createHttpRuntimeClient, createRouteManifest, defineRariConfig, extractParamNames, findMatchingRoute, generateFileRoutes, getRoutePriority, isDynamicRoute, isPathActive, joinPaths, loadRouteManifest, normalizePathname, parseSearchParams, parseUrl, rari, rariRouter, useNavigation, useParams, usePathname, useRoute, useRouter, useSearchParams, validateRoutes, watchFileRoutes, withRouter };
|
|
5
|
+
export { FileRouteGenerator, HttpRuntimeClient, Link, Navigate, Outlet, RouteComponent as Route, router_default as RouterProvider, Routes, buildSearchString, buildUrl, convertFilePatternToRoutePattern, createHttpRuntimeClient, createReactDOMOptimization, createRouteManifest, defineRariConfig, extractParamNames, findMatchingRoute, generateFileRoutes, getRoutePriority, isDynamicRoute, isPathActive, joinPaths, loadRouteManifest, normalizePathname, parseSearchParams, parseUrl, rari, rariRouter, useNavigation, useParams, usePathname, useRoute, useRouter, useSearchParams, validateRoutes, watchFileRoutes, withRouter };
|
|
@@ -228,8 +228,7 @@ function RouterProvider({ config = DEFAULT_CONFIG, routes = DEFAULT_ROUTES, chil
|
|
|
228
228
|
caseSensitive: false,
|
|
229
229
|
...config
|
|
230
230
|
}), [config]);
|
|
231
|
-
const
|
|
232
|
-
const updateCurrentRoute = useCallback((url) => {
|
|
231
|
+
const resolveRoute = useCallback((url) => {
|
|
233
232
|
const { pathname, search, hash, searchParams } = parseUrl(url);
|
|
234
233
|
const normalizedPathname = normalizePathname(pathname);
|
|
235
234
|
const match = findMatchingRoute(normalizedPathname, routes);
|
|
@@ -241,15 +240,43 @@ function RouterProvider({ config = DEFAULT_CONFIG, routes = DEFAULT_ROUTES, chil
|
|
|
241
240
|
hash
|
|
242
241
|
};
|
|
243
242
|
enhancedMatch.childMatch = findDeepestChildMatch(enhancedMatch, normalizedPathname);
|
|
244
|
-
|
|
245
|
-
}
|
|
243
|
+
return enhancedMatch;
|
|
244
|
+
}
|
|
245
|
+
return null;
|
|
246
246
|
}, [routes]);
|
|
247
|
+
const [routerState, setRouterState] = useState(() => {
|
|
248
|
+
if (typeof window === "undefined") return {
|
|
249
|
+
currentRoute: null,
|
|
250
|
+
isReady: false
|
|
251
|
+
};
|
|
252
|
+
const url = mergedConfig.useHash ? window.location.hash.slice(1) || "/" : window.location.pathname + window.location.search + window.location.hash;
|
|
253
|
+
let initialRoute;
|
|
254
|
+
try {
|
|
255
|
+
initialRoute = resolveRoute(url);
|
|
256
|
+
} catch (error) {
|
|
257
|
+
console.error("Error resolving initial route:", error);
|
|
258
|
+
initialRoute = null;
|
|
259
|
+
}
|
|
260
|
+
const isReady$1 = true;
|
|
261
|
+
return {
|
|
262
|
+
currentRoute: initialRoute,
|
|
263
|
+
isReady: isReady$1
|
|
264
|
+
};
|
|
265
|
+
});
|
|
266
|
+
const currentRoute = routerState.currentRoute;
|
|
267
|
+
const isReady = routerState.isReady;
|
|
268
|
+
const updateCurrentRoute = useCallback((url) => {
|
|
269
|
+
const route = resolveRoute(url);
|
|
270
|
+
setRouterState({
|
|
271
|
+
currentRoute: route,
|
|
272
|
+
isReady: true
|
|
273
|
+
});
|
|
274
|
+
}, [resolveRoute]);
|
|
247
275
|
useEffect(() => {
|
|
248
276
|
const handleLocationChange = () => {
|
|
249
277
|
const url = mergedConfig.useHash ? window.location.hash.slice(1) || "/" : window.location.pathname + window.location.search + window.location.hash;
|
|
250
278
|
updateCurrentRoute(url);
|
|
251
279
|
};
|
|
252
|
-
handleLocationChange();
|
|
253
280
|
const handlePopState = () => {
|
|
254
281
|
handleLocationChange();
|
|
255
282
|
};
|
|
@@ -299,16 +326,19 @@ function RouterProvider({ config = DEFAULT_CONFIG, routes = DEFAULT_ROUTES, chil
|
|
|
299
326
|
if (!currentRoute) return false;
|
|
300
327
|
return isPathActive(currentRoute.pathname, path, exact);
|
|
301
328
|
}, [currentRoute]);
|
|
302
|
-
const contextValue = useMemo(() =>
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
329
|
+
const contextValue = useMemo(() => {
|
|
330
|
+
return {
|
|
331
|
+
currentRoute,
|
|
332
|
+
routes,
|
|
333
|
+
navigate,
|
|
334
|
+
back,
|
|
335
|
+
forward,
|
|
336
|
+
replace,
|
|
337
|
+
isActive,
|
|
338
|
+
config: mergedConfig,
|
|
339
|
+
isReady
|
|
340
|
+
};
|
|
341
|
+
}, [
|
|
312
342
|
currentRoute,
|
|
313
343
|
routes,
|
|
314
344
|
navigate,
|
|
@@ -316,7 +346,8 @@ function RouterProvider({ config = DEFAULT_CONFIG, routes = DEFAULT_ROUTES, chil
|
|
|
316
346
|
forward,
|
|
317
347
|
replace,
|
|
318
348
|
isActive,
|
|
319
|
-
mergedConfig
|
|
349
|
+
mergedConfig,
|
|
350
|
+
isReady
|
|
320
351
|
]);
|
|
321
352
|
return /* @__PURE__ */ jsx(RouterContext, {
|
|
322
353
|
value: contextValue,
|
|
@@ -356,8 +387,7 @@ function useParams() {
|
|
|
356
387
|
return currentRoute?.params || {};
|
|
357
388
|
}
|
|
358
389
|
function useSearchParams() {
|
|
359
|
-
const { currentRoute } = useRouter();
|
|
360
|
-
const { navigate } = useRouter();
|
|
390
|
+
const { currentRoute, navigate } = useRouter();
|
|
361
391
|
const searchParams = currentRoute?.searchParams || {};
|
|
362
392
|
const setSearchParams = useCallback((params, options = DEFAULT_CONFIG) => {
|
|
363
393
|
const newParams = typeof params === "function" ? params(searchParams) : params;
|
|
@@ -72,6 +72,7 @@ interface RouterContext {
|
|
|
72
72
|
replace: (path: string, options?: Omit<NavigationOptions, 'replace'>) => void;
|
|
73
73
|
isActive: (path: string, exact?: boolean) => boolean;
|
|
74
74
|
config: RouterConfig;
|
|
75
|
+
isReady: boolean;
|
|
75
76
|
}
|
|
76
77
|
interface NavigationState {
|
|
77
78
|
isNavigating: boolean;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { __commonJS, __require, __toESM } from "./chunk-BLXvPPr8.js";
|
|
2
|
-
import { analyzeFilePath } from "./runtime-client-
|
|
2
|
+
import { analyzeFilePath } from "./runtime-client-CcEhh-F7.js";
|
|
3
3
|
import { createServerBuildPlugin } from "./server-build-DaBgiV55.js";
|
|
4
4
|
import fs, { promises } from "node:fs";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import process$1 from "node:process";
|
|
7
7
|
import { spawn } from "node:child_process";
|
|
8
8
|
import * as acorn from "acorn";
|
|
9
|
+
import { minify } from "rollup-plugin-esbuild";
|
|
9
10
|
|
|
10
11
|
//#region ../../node_modules/.pnpm/picomatch@2.3.1/node_modules/picomatch/lib/constants.js
|
|
11
12
|
var require_constants$2 = __commonJS({ "../../node_modules/.pnpm/picomatch@2.3.1/node_modules/picomatch/lib/constants.js"(exports, module) {
|
|
@@ -5110,7 +5111,7 @@ var require_chokidar = __commonJS({ "../../node_modules/.pnpm/chokidar@3.6.0/nod
|
|
|
5110
5111
|
|
|
5111
5112
|
//#endregion
|
|
5112
5113
|
//#region src/router/file-routes.ts
|
|
5113
|
-
var import_chokidar$1 = __toESM(require_chokidar()
|
|
5114
|
+
var import_chokidar$1 = __toESM(require_chokidar());
|
|
5114
5115
|
var FileRouteGenerator = class {
|
|
5115
5116
|
pagesDir;
|
|
5116
5117
|
extensions;
|
|
@@ -5419,7 +5420,7 @@ function convertFilePatternToRoutePattern(pattern) {
|
|
|
5419
5420
|
|
|
5420
5421
|
//#endregion
|
|
5421
5422
|
//#region src/router/vite-plugin.ts
|
|
5422
|
-
var import_chokidar = __toESM(require_chokidar()
|
|
5423
|
+
var import_chokidar = __toESM(require_chokidar());
|
|
5423
5424
|
const DEFAULT_OPTIONS = {
|
|
5424
5425
|
pagesDir: "src/pages",
|
|
5425
5426
|
extensions: [
|
|
@@ -5742,7 +5743,6 @@ function rari(options = {}) {
|
|
|
5742
5743
|
}
|
|
5743
5744
|
newCode += `
|
|
5744
5745
|
|
|
5745
|
-
// HMR acceptance for server components
|
|
5746
5746
|
if (import.meta.hot) {
|
|
5747
5747
|
import.meta.hot.accept(() => {
|
|
5748
5748
|
// Server component updated, no need to reload
|
|
@@ -5832,6 +5832,14 @@ if (import.meta.hot) {
|
|
|
5832
5832
|
const existingDedupe = Array.isArray(config.resolve.dedupe) ? config.resolve.dedupe : [];
|
|
5833
5833
|
const toAdd = ["react", "react-dom"];
|
|
5834
5834
|
config.resolve.dedupe = Array.from(new Set([...existingDedupe || [], ...toAdd]));
|
|
5835
|
+
const existingResolveAlias = config.resolve.alias || {};
|
|
5836
|
+
config.resolve.alias = {
|
|
5837
|
+
...existingResolveAlias,
|
|
5838
|
+
"react-dom/server": "react-dom/server.browser",
|
|
5839
|
+
"react-dom$": "react-dom/client",
|
|
5840
|
+
"react-dom/cjs/react-dom.production.min.js": "react-dom/client",
|
|
5841
|
+
"react-dom/cjs/react-dom.development.js": "react-dom/client"
|
|
5842
|
+
};
|
|
5835
5843
|
const existingAlias = Array.isArray(config.resolve.alias) ? config.resolve.alias : [];
|
|
5836
5844
|
const aliasFinds = new Set(existingAlias.map((a) => String(a.find)));
|
|
5837
5845
|
try {
|
|
@@ -5880,13 +5888,17 @@ if (import.meta.hot) {
|
|
|
5880
5888
|
config.optimizeDeps = config.optimizeDeps || {};
|
|
5881
5889
|
config.optimizeDeps.include = config.optimizeDeps.include || [];
|
|
5882
5890
|
if (!config.optimizeDeps.include.includes("react-dom/server")) config.optimizeDeps.include.push("react-dom/server");
|
|
5891
|
+
if (!config.optimizeDeps.include.includes("react")) config.optimizeDeps.include.push("react");
|
|
5892
|
+
if (!config.optimizeDeps.include.includes("react-dom/client")) config.optimizeDeps.include.push("react-dom/client");
|
|
5893
|
+
config.optimizeDeps.exclude = config.optimizeDeps.exclude || [];
|
|
5894
|
+
if (!config.optimizeDeps.exclude.includes("virtual:rsc-integration")) config.optimizeDeps.exclude.push("virtual:rsc-integration");
|
|
5883
5895
|
if (command === "build") for (const envName of [
|
|
5884
5896
|
"rsc",
|
|
5885
5897
|
"ssr",
|
|
5886
5898
|
"client"
|
|
5887
5899
|
]) {
|
|
5888
5900
|
const env = config.environments[envName];
|
|
5889
|
-
if (env && env.build) env.build.
|
|
5901
|
+
if (env && env.build) env.build.rolldownOptions = env.build.rolldownOptions || {};
|
|
5890
5902
|
}
|
|
5891
5903
|
config.server = config.server || {};
|
|
5892
5904
|
config.server.proxy = config.server.proxy || {};
|
|
@@ -5912,19 +5924,182 @@ if (import.meta.hot) {
|
|
|
5912
5924
|
};
|
|
5913
5925
|
if (command === "build") {
|
|
5914
5926
|
config.build = config.build || {};
|
|
5915
|
-
config.build.
|
|
5916
|
-
|
|
5927
|
+
config.build.rolldownOptions = config.build.rolldownOptions || {};
|
|
5928
|
+
config.build.rolldownOptions.plugins = config.build.rolldownOptions.plugins || [];
|
|
5929
|
+
if (Array.isArray(config.build.rolldownOptions.plugins)) {
|
|
5930
|
+
config.build.rolldownOptions.plugins.push(minify());
|
|
5931
|
+
config.build.rolldownOptions.plugins.push({
|
|
5932
|
+
name: "html-css-optimizer",
|
|
5933
|
+
generateBundle(options$1, bundle) {
|
|
5934
|
+
Object.keys(bundle).forEach((fileName) => {
|
|
5935
|
+
const file = bundle[fileName];
|
|
5936
|
+
if (file.type === "asset" && fileName.endsWith(".html")) {
|
|
5937
|
+
let html = file.source;
|
|
5938
|
+
html = html.replace(/<link\s+rel="stylesheet"\s+crossorigin\s+href="([^"]+\.css)"\s*>/g, (match, href) => {
|
|
5939
|
+
return `<link rel="preload" as="style" crossorigin href="${href}" fetchpriority="high" onload="this.onload=null;this.rel='stylesheet'">
|
|
5940
|
+
<noscript><link rel="stylesheet" crossorigin href="${href}"></noscript>`;
|
|
5941
|
+
});
|
|
5942
|
+
const scriptMatch = html.match(/<script\s+type="module"\s+crossorigin\s+src="([^"]+)"\s*><\/script>/);
|
|
5943
|
+
if (scriptMatch) {
|
|
5944
|
+
const mainJsHref = scriptMatch[1];
|
|
5945
|
+
html = html.replace(scriptMatch[0], `<link rel="preload" as="script" crossorigin href="${mainJsHref}" fetchpriority="high">
|
|
5946
|
+
<script type="module" crossorigin src="${mainJsHref}" fetchpriority="high"><\/script>`);
|
|
5947
|
+
}
|
|
5948
|
+
file.source = html;
|
|
5949
|
+
}
|
|
5950
|
+
});
|
|
5951
|
+
}
|
|
5952
|
+
});
|
|
5953
|
+
}
|
|
5954
|
+
if (!config.build.rolldownOptions.input) config.build.rolldownOptions.input = { main: "./index.html" };
|
|
5955
|
+
config.build.rolldownOptions.output = config.build.rolldownOptions.output || {};
|
|
5956
|
+
const outputConfig = Array.isArray(config.build.rolldownOptions.output) ? config.build.rolldownOptions.output[0] || {} : config.build.rolldownOptions.output;
|
|
5957
|
+
outputConfig.manualChunks = (id) => {
|
|
5958
|
+
if (id.includes("node_modules/react-dom") || id.includes("react-dom/client") || id.includes("react-dom/server") || id.includes("react-dom/")) return "react-dom";
|
|
5959
|
+
if ((id.includes("node_modules/react") || id.includes("react/")) && !id.includes("react-dom")) return "react";
|
|
5960
|
+
if (id.includes("scheduler") && id.includes("node_modules")) return "scheduler";
|
|
5961
|
+
if (id.includes("markdown-it") || id.includes("shiki")) return "vendor";
|
|
5962
|
+
if (id.includes("node_modules")) return "vendor";
|
|
5963
|
+
};
|
|
5964
|
+
config.build.rolldownOptions.treeshake = config.build.rolldownOptions.treeshake || {
|
|
5965
|
+
moduleSideEffects: (id) => {
|
|
5966
|
+
if (id.includes(".css") || id.includes("polyfill")) return true;
|
|
5967
|
+
if (id.includes("react-dom") || id.includes("react") || id.includes("scheduler") || id.includes("react-dom/client") || id.includes("react-dom/server")) return false;
|
|
5968
|
+
return false;
|
|
5969
|
+
},
|
|
5970
|
+
unknownGlobalSideEffects: false
|
|
5971
|
+
};
|
|
5972
|
+
const existingExternal = config.build.rolldownOptions?.external || [];
|
|
5973
|
+
const reactDomExternals = [
|
|
5974
|
+
"react-dom/profiling",
|
|
5975
|
+
"react-dom/test-utils",
|
|
5976
|
+
"react-dom/server",
|
|
5977
|
+
"react-dom/server.browser",
|
|
5978
|
+
"react-dom/server.node",
|
|
5979
|
+
"react/jsx-dev-runtime",
|
|
5980
|
+
"scheduler/tracing",
|
|
5981
|
+
"scheduler/unstable_mock",
|
|
5982
|
+
"react/cjs/react.development.js",
|
|
5983
|
+
"react/cjs/react.production.min.js",
|
|
5984
|
+
"react-dom/cjs/react-dom.development.js",
|
|
5985
|
+
"react-dom/cjs/react-dom.production.min.js",
|
|
5986
|
+
"react-dom/src/client/ReactDOMRoot.js",
|
|
5987
|
+
"react-dom/src/events/plugins",
|
|
5988
|
+
"react-dom/src/shared/HTMLDOMPropertyConfig.js",
|
|
5989
|
+
"react-dom/src/shared/DOMPropertyOperations.js"
|
|
5990
|
+
];
|
|
5991
|
+
if (Array.isArray(existingExternal)) {
|
|
5992
|
+
const external = [...existingExternal];
|
|
5993
|
+
external.push(...reactDomExternals.filter((dep) => !external.includes(dep)));
|
|
5994
|
+
config.build.rolldownOptions.external = external;
|
|
5995
|
+
} else if (typeof existingExternal === "function") {
|
|
5996
|
+
const originalExternal = existingExternal;
|
|
5997
|
+
config.build.rolldownOptions.external = (id, parentId, isResolved) => {
|
|
5998
|
+
if (reactDomExternals.includes(id)) return true;
|
|
5999
|
+
return originalExternal(id, parentId, isResolved);
|
|
6000
|
+
};
|
|
6001
|
+
} else config.build.rolldownOptions.external = [...Array.isArray(existingExternal) ? existingExternal : [existingExternal], ...reactDomExternals].filter(Boolean);
|
|
6002
|
+
config.build.minify = true;
|
|
6003
|
+
config.build.target = config.build.target || [
|
|
6004
|
+
"es2020",
|
|
6005
|
+
"edge88",
|
|
6006
|
+
"firefox78",
|
|
6007
|
+
"chrome87",
|
|
6008
|
+
"safari14"
|
|
6009
|
+
];
|
|
6010
|
+
config.build.cssMinify = config.build.cssMinify !== false ? "esbuild" : false;
|
|
6011
|
+
config.build.cssCodeSplit = true;
|
|
6012
|
+
config.build.assetsInlineLimit = 4096;
|
|
6013
|
+
config.build.chunkSizeWarningLimit = 1e3;
|
|
6014
|
+
config.build.sourcemap = config.build.sourcemap !== void 0 ? config.build.sourcemap : true;
|
|
6015
|
+
config.build.terserOptions = config.build.terserOptions || {
|
|
6016
|
+
compress: {
|
|
6017
|
+
drop_console: true,
|
|
6018
|
+
drop_debugger: true,
|
|
6019
|
+
pure_funcs: [
|
|
6020
|
+
"console.log",
|
|
6021
|
+
"console.info",
|
|
6022
|
+
"console.debug",
|
|
6023
|
+
"console.warn",
|
|
6024
|
+
"invariant",
|
|
6025
|
+
"warning",
|
|
6026
|
+
"__DEV__",
|
|
6027
|
+
"ReactDOM.render",
|
|
6028
|
+
"ReactDOM.unmountComponentAtNode",
|
|
6029
|
+
"ReactDOM.findDOMNode",
|
|
6030
|
+
"ReactDOM.createPortal"
|
|
6031
|
+
],
|
|
6032
|
+
passes: 3,
|
|
6033
|
+
unsafe: true,
|
|
6034
|
+
unsafe_comps: true,
|
|
6035
|
+
unsafe_Function: true,
|
|
6036
|
+
unsafe_math: true,
|
|
6037
|
+
unsafe_symbols: true,
|
|
6038
|
+
unsafe_methods: true,
|
|
6039
|
+
unsafe_proto: true,
|
|
6040
|
+
unsafe_regexp: true,
|
|
6041
|
+
unsafe_undefined: true,
|
|
6042
|
+
dead_code: true,
|
|
6043
|
+
side_effects: false
|
|
6044
|
+
},
|
|
6045
|
+
mangle: {
|
|
6046
|
+
safari10: true,
|
|
6047
|
+
properties: { regex: /^_/ }
|
|
6048
|
+
},
|
|
6049
|
+
format: { comments: false }
|
|
6050
|
+
};
|
|
6051
|
+
outputConfig.format = outputConfig.format || "es";
|
|
6052
|
+
outputConfig.minify = true;
|
|
6053
|
+
if (Array.isArray(config.build.rolldownOptions.output)) config.build.rolldownOptions.output[0] = outputConfig;
|
|
6054
|
+
else config.build.rolldownOptions.output = outputConfig;
|
|
5917
6055
|
}
|
|
5918
6056
|
if (config.environments && config.environments.client) {
|
|
5919
6057
|
if (!config.environments.client.build) config.environments.client.build = {};
|
|
5920
|
-
if (!config.environments.client.build.
|
|
5921
|
-
if (!config.environments.client.build.
|
|
5922
|
-
if (typeof config.environments.client.build.
|
|
6058
|
+
if (!config.environments.client.build.rolldownOptions) config.environments.client.build.rolldownOptions = {};
|
|
6059
|
+
if (!config.environments.client.build.rolldownOptions.input) config.environments.client.build.rolldownOptions.input = {};
|
|
6060
|
+
if (typeof config.environments.client.build.rolldownOptions.input === "object" && !Array.isArray(config.environments.client.build.rolldownOptions.input)) config.environments.client.build.rolldownOptions.input["client-components"] = "virtual:rsc-client-components";
|
|
6061
|
+
config.environments.client.build.rolldownOptions.plugins = config.environments.client.build.rolldownOptions.plugins || [];
|
|
6062
|
+
if (Array.isArray(config.environments.client.build.rolldownOptions.plugins)) config.environments.client.build.rolldownOptions.plugins.push(minify());
|
|
6063
|
+
config.environments.client.build.minify = true;
|
|
6064
|
+
config.environments.client.build.target = config.environments.client.build.target || [
|
|
6065
|
+
"es2020",
|
|
6066
|
+
"edge88",
|
|
6067
|
+
"firefox78",
|
|
6068
|
+
"chrome87",
|
|
6069
|
+
"safari14"
|
|
6070
|
+
];
|
|
6071
|
+
config.environments.client.build.cssMinify = "esbuild";
|
|
6072
|
+
config.environments.client.build.cssCodeSplit = true;
|
|
6073
|
+
config.environments.client.build.assetsInlineLimit = 4096;
|
|
6074
|
+
config.environments.client.build.rolldownOptions.treeshake = {
|
|
6075
|
+
moduleSideEffects: false,
|
|
6076
|
+
unknownGlobalSideEffects: false
|
|
6077
|
+
};
|
|
6078
|
+
config.environments.client.build.rolldownOptions.output = config.environments.client.build.rolldownOptions.output || {};
|
|
6079
|
+
const clientOutputConfig = Array.isArray(config.environments.client.build.rolldownOptions.output) ? config.environments.client.build.rolldownOptions.output[0] || {} : config.environments.client.build.rolldownOptions.output;
|
|
6080
|
+
clientOutputConfig.manualChunks = (id) => {
|
|
6081
|
+
if (id.includes("node_modules/react-dom") || id.includes("react-dom/client") || id.includes("react-dom/server") || id.includes("react-dom/")) return "react-dom";
|
|
6082
|
+
if ((id.includes("node_modules/react") || id.includes("react/")) && !id.includes("react-dom")) return "react";
|
|
6083
|
+
if (id.includes("scheduler") && id.includes("node_modules")) return "scheduler";
|
|
6084
|
+
if (id.includes("rari") && (id.includes("router") || id.includes("navigation"))) return "router";
|
|
6085
|
+
if (id.includes("markdown-it") || id.includes("shiki")) return "vendor";
|
|
6086
|
+
if (id.includes("node_modules")) return "vendor";
|
|
6087
|
+
};
|
|
6088
|
+
clientOutputConfig.format = clientOutputConfig.format || "es";
|
|
6089
|
+
clientOutputConfig.minify = true;
|
|
6090
|
+
if (Array.isArray(config.environments.client.build.rolldownOptions.output)) config.environments.client.build.rolldownOptions.output[0] = clientOutputConfig;
|
|
6091
|
+
else config.environments.client.build.rolldownOptions.output = clientOutputConfig;
|
|
5923
6092
|
}
|
|
5924
6093
|
return config;
|
|
5925
6094
|
},
|
|
5926
6095
|
transform(code, id) {
|
|
5927
6096
|
if (!/\.(?:tsx?|jsx?)$/.test(id)) return null;
|
|
6097
|
+
if (code.includes("react-dom")) {
|
|
6098
|
+
code = code.replace(/import\s+ReactDOM\s+from\s+['"]react-dom\/client['"];?/g, "import { createRoot, hydrateRoot } from 'react-dom/client';");
|
|
6099
|
+
code = code.replace(/import\s+ReactDOM\s+from\s+['"]react-dom['"];?/g, "import { createRoot, hydrateRoot } from 'react-dom/client';");
|
|
6100
|
+
code = code.replace(/ReactDOM\.createRoot/g, "createRoot");
|
|
6101
|
+
code = code.replace(/ReactDOM\.hydrateRoot/g, "hydrateRoot");
|
|
6102
|
+
}
|
|
5928
6103
|
const environment = this.environment;
|
|
5929
6104
|
if (hasTopLevelDirective(code, "use client")) {
|
|
5930
6105
|
componentTypeCache.set(id, "client");
|
|
@@ -6374,7 +6549,6 @@ export const __CLIENT_REFERENCE_REGISTRY__ = clientReferenceRegistry;
|
|
|
6374
6549
|
export const __SERVER_REFERENCE_REGISTRY__ = serverReferenceRegistry;
|
|
6375
6550
|
export const __CLIENT_COMPONENT_REGISTRY__ = clientComponentRegistry;
|
|
6376
6551
|
|
|
6377
|
-
// Module map for React Server Components
|
|
6378
6552
|
export function createClientModuleMap() {
|
|
6379
6553
|
const moduleMap = {};
|
|
6380
6554
|
|
|
@@ -6397,7 +6571,6 @@ export function createClientModuleMap() {
|
|
|
6397
6571
|
if (id === "virtual:rsc-integration") return `
|
|
6398
6572
|
import React, { useState, useEffect, Suspense } from 'react';
|
|
6399
6573
|
|
|
6400
|
-
// Client component registration for RSC system compatibility
|
|
6401
6574
|
if (typeof globalThis.__clientComponents === 'undefined') {
|
|
6402
6575
|
globalThis.__clientComponents = {};
|
|
6403
6576
|
}
|
|
@@ -6415,7 +6588,6 @@ export function registerClientComponent(componentFunction, id, exportName) {
|
|
|
6415
6588
|
|
|
6416
6589
|
const componentId = componentName;
|
|
6417
6590
|
|
|
6418
|
-
// Register in global registry for RSC traversal
|
|
6419
6591
|
globalThis.__clientComponents[componentId] = {
|
|
6420
6592
|
id: componentId,
|
|
6421
6593
|
path: id,
|
|
@@ -7176,7 +7348,7 @@ class RscClient {
|
|
|
7176
7348
|
const processedChildren = value.map((child, index) => {
|
|
7177
7349
|
const result = this.reconstructElementFromRscData(child, modules);
|
|
7178
7350
|
return result;
|
|
7179
|
-
}).filter(child => child !== null && child !== undefined);
|
|
7351
|
+
}).filter(child => child !== null && child !== undefined);
|
|
7180
7352
|
|
|
7181
7353
|
if (processedChildren.length === 0) {
|
|
7182
7354
|
processed[key] = null;
|
|
@@ -7321,7 +7493,6 @@ function ServerComponentWrapper({
|
|
|
7321
7493
|
}
|
|
7322
7494
|
|
|
7323
7495
|
function createServerComponentWrapper(componentName, importPath) {
|
|
7324
|
-
// Use a global refresh counter to force re-mounting when components change
|
|
7325
7496
|
let globalRefreshCounter = 0;
|
|
7326
7497
|
|
|
7327
7498
|
if (typeof window !== 'undefined') {
|
|
@@ -7335,7 +7506,6 @@ function createServerComponentWrapper(componentName, importPath) {
|
|
|
7335
7506
|
const ServerComponent = (props) => {
|
|
7336
7507
|
const [mountKey, setMountKey] = useState(globalRefreshCounter);
|
|
7337
7508
|
|
|
7338
|
-
// Force re-mount when component is invalidated
|
|
7339
7509
|
useEffect(() => {
|
|
7340
7510
|
const handleRscInvalidate = (event) => {
|
|
7341
7511
|
const detail = event.detail;
|
|
@@ -7356,7 +7526,7 @@ function createServerComponentWrapper(componentName, importPath) {
|
|
|
7356
7526
|
return React.createElement(Suspense, {
|
|
7357
7527
|
fallback: null
|
|
7358
7528
|
}, React.createElement(ServerComponentWrapper, {
|
|
7359
|
-
key: componentName + '-' + mountKey,
|
|
7529
|
+
key: componentName + '-' + mountKey,
|
|
7360
7530
|
componentId: componentName,
|
|
7361
7531
|
props: props,
|
|
7362
7532
|
fallback: null
|
|
@@ -7373,9 +7543,7 @@ function createServerComponentWrapper(componentName, importPath) {
|
|
|
7373
7543
|
export const fetchServerComponent = (componentId, props) =>
|
|
7374
7544
|
rscClient.fetchServerComponent(componentId, props);
|
|
7375
7545
|
|
|
7376
|
-
// Helper function to check if a file is a server component (client-side)
|
|
7377
7546
|
function isServerComponent(filePath) {
|
|
7378
|
-
// Simple client-side check based on file path patterns
|
|
7379
7547
|
return filePath && (
|
|
7380
7548
|
filePath.includes('ServerWithClient') ||
|
|
7381
7549
|
filePath.includes('server') ||
|
|
@@ -7383,32 +7551,26 @@ function isServerComponent(filePath) {
|
|
|
7383
7551
|
);
|
|
7384
7552
|
}
|
|
7385
7553
|
|
|
7386
|
-
// HMR support for RSC cache invalidation
|
|
7387
7554
|
if (import.meta.hot) {
|
|
7388
|
-
// Listen for Vite's beforeFullReload event for server components
|
|
7389
7555
|
import.meta.hot.on('vite:beforeFullReload', async (data) => {
|
|
7390
7556
|
if (data?.path && isServerComponent(data.path)) {
|
|
7391
|
-
// Immediately invalidate cache and trigger re-registration before reload
|
|
7392
7557
|
await invalidateRscCache({ filePath: data.path, forceReload: true });
|
|
7393
7558
|
}
|
|
7394
7559
|
});
|
|
7395
7560
|
|
|
7396
7561
|
|
|
7397
7562
|
|
|
7398
|
-
// Helper function to invalidate RSC cache and trigger component re-registration
|
|
7399
7563
|
async function invalidateRscCache(data) {
|
|
7400
7564
|
const filePath = data?.filePath || data;
|
|
7401
7565
|
|
|
7402
|
-
// Wait for server to be ready
|
|
7403
7566
|
const waitForServerReady = async () => {
|
|
7404
|
-
for (let i = 0; i < 20; i++) {
|
|
7567
|
+
for (let i = 0; i < 20; i++) {
|
|
7405
7568
|
try {
|
|
7406
7569
|
const response = await fetch('/_rsc_status');
|
|
7407
7570
|
if (response.ok) {
|
|
7408
7571
|
return true;
|
|
7409
7572
|
}
|
|
7410
7573
|
} catch (e) {
|
|
7411
|
-
// Server not ready yet
|
|
7412
7574
|
}
|
|
7413
7575
|
await new Promise(resolve => setTimeout(resolve, 100));
|
|
7414
7576
|
}
|
|
@@ -7417,10 +7579,8 @@ if (import.meta.hot) {
|
|
|
7417
7579
|
|
|
7418
7580
|
const serverReady = await waitForServerReady();
|
|
7419
7581
|
if (serverReady) {
|
|
7420
|
-
// Clear client-side RSC cache immediately
|
|
7421
7582
|
rscClient.clearCache();
|
|
7422
7583
|
|
|
7423
|
-
// Trigger immediate server component re-registration
|
|
7424
7584
|
try {
|
|
7425
7585
|
await fetch('/api/rsc/hmr-register', {
|
|
7426
7586
|
method: 'POST',
|
|
@@ -7432,14 +7592,10 @@ if (import.meta.hot) {
|
|
|
7432
7592
|
})
|
|
7433
7593
|
});
|
|
7434
7594
|
|
|
7435
|
-
// Wait a bit for the server to re-register the component
|
|
7436
|
-
// The server now immediately reads and re-registers the component
|
|
7437
7595
|
await new Promise(resolve => setTimeout(resolve, 300));
|
|
7438
7596
|
} catch (error) {
|
|
7439
|
-
// Fallback to existing timeout-based approach
|
|
7440
7597
|
}
|
|
7441
7598
|
|
|
7442
|
-
// Trigger re-render of active server components
|
|
7443
7599
|
if (typeof window !== 'undefined') {
|
|
7444
7600
|
const event = new CustomEvent('rari:rsc-invalidate', {
|
|
7445
7601
|
detail: { filePath }
|
|
@@ -7509,6 +7665,73 @@ ${registrations.join("\n")}
|
|
|
7509
7665
|
const serverBuildPlugin = createServerBuildPlugin(options.serverBuild);
|
|
7510
7666
|
return [mainPlugin, serverBuildPlugin];
|
|
7511
7667
|
}
|
|
7668
|
+
function createReactDOMOptimization() {
|
|
7669
|
+
return { build: {
|
|
7670
|
+
rollupOptions: {
|
|
7671
|
+
output: { manualChunks: (id) => {
|
|
7672
|
+
if (id.includes("node_modules/react-dom") || id.includes("react-dom/client") || id.includes("react-dom/server") || id.includes("react-dom/")) return "react-dom";
|
|
7673
|
+
if ((id.includes("node_modules/react") || id.includes("react/")) && !id.includes("react-dom")) return "react";
|
|
7674
|
+
if (id.includes("scheduler") && id.includes("node_modules")) return "scheduler";
|
|
7675
|
+
if (id.includes("markdown-it") || id.includes("shiki")) return "vendor";
|
|
7676
|
+
if (id.includes("node_modules")) return "vendor";
|
|
7677
|
+
} },
|
|
7678
|
+
treeshake: {
|
|
7679
|
+
moduleSideEffects: (id) => {
|
|
7680
|
+
if (id.includes(".css") || id.includes("polyfill")) return true;
|
|
7681
|
+
if (id.includes("react-dom") || id.includes("react") || id.includes("scheduler") || id.includes("react-dom/client") || id.includes("react-dom/server")) return false;
|
|
7682
|
+
return false;
|
|
7683
|
+
},
|
|
7684
|
+
unknownGlobalSideEffects: false
|
|
7685
|
+
}
|
|
7686
|
+
},
|
|
7687
|
+
minify: "terser",
|
|
7688
|
+
target: [
|
|
7689
|
+
"es2020",
|
|
7690
|
+
"edge88",
|
|
7691
|
+
"firefox78",
|
|
7692
|
+
"chrome87",
|
|
7693
|
+
"safari14"
|
|
7694
|
+
],
|
|
7695
|
+
cssMinify: "esbuild",
|
|
7696
|
+
sourcemap: false,
|
|
7697
|
+
terserOptions: {
|
|
7698
|
+
compress: {
|
|
7699
|
+
drop_console: true,
|
|
7700
|
+
drop_debugger: true,
|
|
7701
|
+
pure_funcs: [
|
|
7702
|
+
"console.log",
|
|
7703
|
+
"console.info",
|
|
7704
|
+
"console.debug",
|
|
7705
|
+
"console.warn",
|
|
7706
|
+
"invariant",
|
|
7707
|
+
"warning",
|
|
7708
|
+
"__DEV__",
|
|
7709
|
+
"ReactDOM.render",
|
|
7710
|
+
"ReactDOM.unmountComponentAtNode",
|
|
7711
|
+
"ReactDOM.findDOMNode",
|
|
7712
|
+
"ReactDOM.createPortal"
|
|
7713
|
+
],
|
|
7714
|
+
passes: 3,
|
|
7715
|
+
unsafe: true,
|
|
7716
|
+
unsafe_comps: true,
|
|
7717
|
+
unsafe_Function: true,
|
|
7718
|
+
unsafe_math: true,
|
|
7719
|
+
unsafe_symbols: true,
|
|
7720
|
+
unsafe_methods: true,
|
|
7721
|
+
unsafe_proto: true,
|
|
7722
|
+
unsafe_regexp: true,
|
|
7723
|
+
unsafe_undefined: true,
|
|
7724
|
+
dead_code: true,
|
|
7725
|
+
side_effects: false
|
|
7726
|
+
},
|
|
7727
|
+
mangle: {
|
|
7728
|
+
safari10: true,
|
|
7729
|
+
properties: { regex: /^_/ }
|
|
7730
|
+
},
|
|
7731
|
+
format: { comments: false }
|
|
7732
|
+
}
|
|
7733
|
+
} };
|
|
7734
|
+
}
|
|
7512
7735
|
function defineRariConfig(config) {
|
|
7513
7736
|
return {
|
|
7514
7737
|
plugins: [rari(), ...config.plugins || []],
|
|
@@ -7517,4 +7740,4 @@ function defineRariConfig(config) {
|
|
|
7517
7740
|
}
|
|
7518
7741
|
|
|
7519
7742
|
//#endregion
|
|
7520
|
-
export { FileRouteGenerator, convertFilePatternToRoutePattern, createRouteManifest, defineRariConfig, generateFileRoutes, loadRouteManifest, rari, rariRouter, validateRoutes, watchFileRoutes };
|
|
7743
|
+
export { FileRouteGenerator, convertFilePatternToRoutePattern, createReactDOMOptimization, createRouteManifest, defineRariConfig, generateFileRoutes, loadRouteManifest, rari, rariRouter, validateRoutes, watchFileRoutes };
|