diff --git a/playground/app/root.tsx b/playground/app/root.tsx index 7879b23..df8345c 100644 --- a/playground/app/root.tsx +++ b/playground/app/root.tsx @@ -3,8 +3,6 @@ import React from 'react' import { Outlet } from 'react-router-dom' - - export default function Component() { return ( <> diff --git a/src/index.ts b/src/index.ts index 2e0c1ed..454540d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -8,16 +8,18 @@ import { buildRoutesMap } from './utils/build-route-maps' let server: ViteDevServer -const routesCode = (imports: string | undefined, routesObject: string) => ` -${imports} - -function moduleFactory(module) { - const { default: Component, clientLoader: loader, actionLoader: action, loader: _loader, action: _action, Component: _Component, ...rest } = module; - return { Component, loader, action, ...rest }; -} +function routesCode(imports: string | undefined, routesObject: string) { + return ` + ${imports} + + function moduleFactory(module) { + const { default: Component, clientLoader: loader, actionLoader: action, loader: _loader, action: _action, Component: _Component, ...rest } = module; + return { Component, loader, action, ...rest }; + } -export const routes = ${routesObject} -` + export const routes = ${routesObject} + ` +} export function invalidateVirtualModule(server: ViteDevServer): void { const { moduleGraph, ws } = server @@ -71,6 +73,7 @@ export const unpluginFactory: UnpluginFactory = options => .replace(/SpreadEnd"/g, ')') // console.log(JSON.stringify(routesObject, null, 2)) + // eslint-disable-next-line no-console console.log(` [Warn] You are using unplugin-remix-router v2. you should export Component as default, loader as clientLoader and action as clientAction.