Skip to content

Commit

Permalink
docs(changeset): fix order of built routers based on base length
Browse files Browse the repository at this point in the history
  • Loading branch information
nksaraf committed Oct 23, 2023
1 parent f35dc0a commit e87800e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/six-experts-confess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"vinxi": patch
---

fix order of built routers based on base length
1 change: 0 additions & 1 deletion packages/vinxi/lib/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export function createApp({
devtools = true,
root = process.cwd(),
}) {
console.log("devtools", devtools);
if (devtools) {
routers = [devtoolsClient(), devtoolsRpc(), ...routers];
}
Expand Down
4 changes: 3 additions & 1 deletion packages/vinxi/lib/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ export async function createBuild(app, buildConfig) {
...(app.config.server.plugins ?? []),
],
handlers: [
...app.config.routers
...[...app.config.routers]
.sort((a, b) => a.base.length - b.base.length)
.reverse()
.map((router) => {
if (router.mode === "handler") {
invariant(router.handler, "Missing router.handler");
Expand Down
2 changes: 1 addition & 1 deletion packages/vinxi/lib/plugins/tree-shake.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import plugin from "./tree-shake.babel.js";
* @returns {import("../vite-dev.d.ts").Plugin}
*/
export function treeShake() {
/** @type {import('../vite-dev.d.ts').ViteConfig} */
let config;
let cache = {};
let server;
Expand All @@ -19,7 +20,6 @@ export function treeShake() {
const babel = await import("@babel/core");
const transformed = babel.transform(code, {
plugins: [
...(config.router.build?.babel?.plugins ?? []),
jsx,
[typescript, { isTSX: true }],
[plugin, { pick: query.getAll("pick") }],
Expand Down

0 comments on commit e87800e

Please sign in to comment.