alloc / saus

Vite SSR/SSG framework that aspires to be a layer for opinionated web frameworks to build upon
Other
38 stars 1 forks source link

Reduce duplication in client routes map #75

Open aleclarson opened 2 years ago

aleclarson commented 2 years ago

https://github.com/novemberborn/common-path-prefix/blob/master/index.js

If multiple routes have the same route module, we can avoid duplication in client routes map.

// Before
export default {
  "default": "/assets/entry.8ae2ce2d.js",
  "/": "/assets/entry.8ae2ce2d.js",
  "/about": "/assets/entry.ba4aa235.js",
}

// After
import {buildRouteMap} from '/@id/saus/src/client/helpers.ts'
export default buildRouteMap({
  "/assets/entry.": {
    "8ae2ce2d.js": ["default", "/"],
    "ba4aa235.js": ["/about"],
  },
})

The exported object would look the same as before, but the paths would be deduplicated.

Q: Does gzip make this a non-problem?