-
-
Couldn't load subscription status.
- Fork 175
Closed
Description
Right now the gzipped library size is 2KB, 70% of which is path-to-regexp dependency. While path-to-regexp provides a well-known way for developer to describe routes, it seems like we could shrink it's functionality to cover the 99% of use cases.
It would be cool to reimplement a limited subset of the library, so that:
- We drop that dependency and make it a zero-dependency library π
- We reduce the size to be less than 1KB (current bundle size without a matcher is 686B).
For users who still want to use the path-to-regexp functionality and get an advanced syntax we could provide an optional entry point:
import { Router } from "wouter";
import makeMatcher from "wouter/matcher";
import pathToRegexp from "path-to-regexp";
<Router matchFn={makeMatcher(pathToRegexp)}>
...
</Router>So ideally it would be nice to define a subset of features we would like to support. Here are my ideas:
- Always case-insensitive
- Ignores a slash at the end
- Matches an entire path
- Supports named segments
/:foo/:bar - Supports modifiers:
:foo?,:foo*and:foo+ - No support for unnamed params. All params should have a name.
- No segment constraints e.g.
/:foo(\d+)/
KutnerUri and linonetwo
Metadata
Metadata
Assignees
Labels
No labels