nuxt-modules / i18n

I18n module for Nuxt
https://i18n.nuxtjs.org
MIT License
1.71k stars 478 forks source link

feat: add new regex routing #2937

Open s00d opened 5 months ago

s00d commented 5 months ago

❓ Type of change

πŸ“š Description

The new version of this commit https://github.com/nuxt-modules/i18n/pull/2927 includes a new routing system. However, I was unable to complete the last two tests: specs/routing/prefix-and-default.spec.ts > localePath > route strategy: prefix_and_default > should be worked. These are related to link generation. Unfortunately, I still can't figure out how it works or how to fix it.

Everything is functioning now, please take a look when you have time.

The description was in the previous pull request.

πŸ“ Checklist

s00d commented 5 months ago

I've caught a memory leak when using routeToObject instead of:

Copy code
const subRoute = {
    name: route.name,
// ...

In this case, all tests start to lag. It seems like this issue might be relevant to any code where routeToObject is used

s00d commented 5 months ago

memory tests(10k requests)

regexp version

image

8.3.1

image

The bundle size on a real project with 8 locales, 20 pages, and 100 components. regexp version 387kb

image

8.3.1 436kb

image

Now there can be even 100 locales and the bundle will not keep increasing indefinitely.

s00d commented 5 months ago

Revised Routing Description:

1. Primary Route:

2. Localized Route:

3. Custom Routes:

Additional Enhancements:

Code Explanation:

Route Search Process:

s00d commented 5 months ago

I've fixed all the tests, but there are still some warnings left that I couldn't catch locally; my tests don't show them. Maybe you'll be able to catch them. The resolve function sometimes passes the locale parameter where it's not needed (to routes without a locale), but it's already possible to start reviewing and testing.

I also had to adjust two tests. One issue was related to i18n, and for the second one, I'm out of energy to fix it.

junemolison commented 2 months ago

I was wondering if there might be an update on the timeline for merging this? Thank you for your time and consideration.

BobbieGoede commented 2 months ago

I was wondering if there might be an update on the timeline for merging this? Thank you for your time and consideration.

I was a bit busy the last few months but I'm still considering this feature as we're working v9, no timeline though.