rsnext/packages
Ngô Đức Anh 821c251a61
Fix(typedRoutes): replaced readFile + replaceAll, hid utils types, fixed duplication in type Route, fixed route groups on Windows (#46378)
Fixes #46401

This PR fixes route groups not working with Windows by handling slashes properly by replacing RegEx expressions with `ensureLeadingSlash`, `getPageFromPath` (which uses `normalizePathSep`),... It also adds a test that ensures `typedRoutes` works with route groups to `app-types.test.js`.

It also replaces `fs.readFile` and String's `replaceAll` that were used to augment `next` in PR 46332 (which were rather overkill and inefficient in my opinion) with a `export * from "next/types/index.d.ts"`.

I've also converted `edgeRouteTypes` and `nodeRouteTypes` to 2 Sets so as to avoid duplications. When we write type `Route`, we also check if a route in `nodeRouteTypes` is already defined in `edgeRouteTypes`.

Types like `SearchOrHash`, `Suffix`, `SafeSlug`,... have also been made private to module "next" (before this PR users could access to these types anywhere in their workspace, which doesn't seem like an expected behaviour in my opinion).

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] [e2e](https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs) tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm build && pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
2023-02-25 14:50:14 +00:00
..
create-next-app v13.2.2-canary.0 2023-02-24 16:58:01 -08:00
eslint-config-next v13.2.2-canary.0 2023-02-24 16:58:01 -08:00
eslint-plugin-next v13.2.2-canary.0 2023-02-24 16:58:01 -08:00
font v13.2.2-canary.0 2023-02-24 16:58:01 -08:00
next Fix(typedRoutes): replaced readFile + replaceAll, hid utils types, fixed duplication in type Route, fixed route groups on Windows (#46378) 2023-02-25 14:50:14 +00:00
next-bundle-analyzer v13.2.2-canary.0 2023-02-24 16:58:01 -08:00
next-codemod v13.2.2-canary.0 2023-02-24 16:58:01 -08:00
next-env v13.2.2-canary.0 2023-02-24 16:58:01 -08:00
next-mdx v13.2.2-canary.0 2023-02-24 16:58:01 -08:00
next-plugin-storybook v13.2.2-canary.0 2023-02-24 16:58:01 -08:00
next-polyfill-module v13.2.2-canary.0 2023-02-24 16:58:01 -08:00
next-polyfill-nomodule v13.2.2-canary.0 2023-02-24 16:58:01 -08:00
next-swc Fix SWC error wrongly formatted (#46412) 2023-02-25 14:00:06 +00:00
react-dev-overlay v13.2.2-canary.0 2023-02-24 16:58:01 -08:00
react-refresh-utils v13.2.2-canary.0 2023-02-24 16:58:01 -08:00