Skip to content

fix: extract webpack resolve.alias from next.config plugins (#177)#196

Open
SeolJaeHyeok wants to merge 3 commits intocloudflare:mainfrom
SeolJaeHyeok:fix/next-intl-webpack-aliases
Open

fix: extract webpack resolve.alias from next.config plugins (#177)#196
SeolJaeHyeok wants to merge 3 commits intocloudflare:mainfrom
SeolJaeHyeok:fix/next-intl-webpack-aliases

Conversation

@SeolJaeHyeok
Copy link
Contributor

Summary

  • next-intl's createNextIntlPlugin / withNextIntl registers "next-intl/config" → user's i18n/request.ts via webpack resolve.alias
  • Since vinext ignores webpack config, this alias was never applied — next-intl/config resolved to a stub that throws "Couldn't find next-intl config file"
  • Fix: probe config.webpack() with the real project root to extract string-valued aliases, then merge them into Vite's resolve.alias (vinext's own shims
    always take precedence)
  • Suppresses the spurious "webpack not yet supported" warning when alias extraction succeeds

Fixes #177

…re#177)

      Plugins like next-intl's createNextIntlPlugin / withNextIntl add module
      aliases via webpack.resolve.alias (e.g. "next-intl/config" → the user's
      i18n/request.ts). Vite never saw these aliases, so next-intl/config
      resolved to a stub that throws "Couldn't find next-intl config file".

      Fix: probe config.webpack() with the real project root to extract
      string-valued aliases, store them in ResolvedNextConfig.webpackAliases,
      and merge them into Vite's resolve.alias (vinext's own shims take
      precedence). Also suppresses the spurious "webpack not yet supported"
      warning when the webpack function was useful for alias extraction.#
@southpolesteve
Copy link
Collaborator

Thanks for the PR @SeolJaeHyeok! We're looking at this now.

- Add ecosystem E2E tests verifying SSR works for English and German locales
- Add next.config.ts with webpack alias (simulating createNextIntlPlugin)
- Update fixture to use 'use client' page component with NextIntlClientProvider
- Add 8 unit tests for extractWebpackAliases covering aliases, non-string
  values, error handling, and resolveNextConfig integration
- Add table of tested libraries with status and notes to README
- Update next-intl status in check.ts to reflect current state
- Update migration skill compatibility reference
- Reference issue cloudflare#202 for createNextIntlPlugin workaround
@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 28, 2026

Open in StackBlitz

npm i https://pkg.pr.new/vinext@196

commit: b1f82a0

@southpolesteve
Copy link
Collaborator

Thanks for fixing! Looks like there are still some sharp edges which I documented in #202 biggest of which is you have to have next installed. But can tackle those later. Sounds like this should get you unblocked when merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Issues with next-intl library

2 participants