Skip to content

Commit

Permalink
chore: add warn message for new plugin namings
Browse files Browse the repository at this point in the history
  • Loading branch information
rush committed Jul 11, 2024
1 parent 105d241 commit 926ec2e
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ import { buildRoutesMap } from './utils/build-route-maps'

let server: ViteDevServer

const routesCode = (imports: string | undefined, routesObject: string) => `

Check failure on line 11 in src/index.ts

View workflow job for this annotation

GitHub Actions / lint

Top-level functions should be declared with function keyword
${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 function invalidateVirtualModule(server: ViteDevServer): void {
const { moduleGraph, ws } = server
const module = moduleGraph.getModuleById('virtual:routes')
Expand Down Expand Up @@ -60,17 +71,13 @@ export const unpluginFactory: UnpluginFactory<Options | undefined> = options =>
.replace(/SpreadEnd"/g, ')')
// console.log(JSON.stringify(routesObject, null, 2))

const routesCode = `
${imports}
function moduleFactory(module) {
const { default: Component, clientLoader: loader, actionLoader: action, loader: _loader, action: _action, Component: _Component, ...rest } = module;
return { Component, loader, action, ...rest };
}
console.log(`

Check failure on line 74 in src/index.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement
[Warn] You are using unplugin-remix-router v2.
you should export Component as default, loader as clientLoader and action as clientAction.
see example in https://github.com/ws-rush/unplugin-remix-router#readme
`)

export const routes = ${routesObject}
`
return routesCode
return routesCode(imports, routesObject)
}
},
vite: {
Expand Down

0 comments on commit 926ec2e

Please sign in to comment.