Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convenience injection of rewrites & exportPathMap #1155

Closed
adam-rocska opened this issue Jun 28, 2024 · 3 comments
Closed

Convenience injection of rewrites & exportPathMap #1155

adam-rocska opened this issue Jun 28, 2024 · 3 comments
Labels
enhancement New feature or request unconfirmed Needs triage.

Comments

@adam-rocska
Copy link

Is your feature request related to a problem? Please describe.

When using next-intl with:

  • output: "export"
  • basePath (this might be a red herring)
  • Localized Pathnames

Both the built routing, and the dev served routing don't recognize the localized paths.

Describe the solution you'd like

NextJS supports exportPathMap and rewrites in its config.
We could provide such utility functions which could automagically populate the routes according to rational dev expectations.

I'd sugest a wrapper / currying / composition instead of a simple utility function, since library users may already have exportPathMaps or rewrites in place.

If this sounds like a good idea, let me know in the comments and I'll open a PR.
I've got a rough implementation of this solution.

Describe alternatives you've considered

This combination of settings to the best of my knowledge can't be tackled in any other way 🫤

@adam-rocska adam-rocska added enhancement New feature or request unconfirmed Needs triage. labels Jun 28, 2024
@amannn
Copy link
Owner

amannn commented Jun 28, 2024

Hey @adam-rocska, thanks for the feature request!

Yep, localized pathnames are known to not work with Next.js' static export since they rely on middleware.

I've honestly not heard of exportPathMap before. It's an interesting feature though that could be really useful for this use case. However, the Next.js docs mention that this feature is deprecated, so I guess it will be removed at some point. Due to this, I think it doesn't make much sense for next-intl to support this in a built-in way.

That said, I guess this could be solved in userland while the feature is available, right? You mentioned that you already have a rough implementation working, mind sharing it in case it could be helpful for others? I'm wondering if in case Next.js removes this feature, this could be implemented via a postbuild script that moves files around appropriately to respect localized pathnames.

@adam-rocska
Copy link
Author

@amannn Thanks for the quick reply!

Moving files around post-build makes me a bit edgy 😅 But sure, if this feature no longer will be around at some point, it might smell like it's the only option there.

As of the workaround (deprecated) functions, sure, I'll generalize them later today & have it posted here on the thread.

I wonder what the nextjs team might have in mind for this stuff.

@amannn
Copy link
Owner

amannn commented Jun 28, 2024

Sounds great thanks! I'll move this to a discussion for now, as I think built-in support in next-intl is off the radar for now.

Repository owner locked and limited conversation to collaborators Jun 28, 2024
@amannn amannn converted this issue into discussion #1156 Jun 28, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
enhancement New feature or request unconfirmed Needs triage.
Projects
None yet
Development

No branches or pull requests

2 participants