hozana / next-translate-routes

Flexible and translated routes for Next.js without custom server
MIT License
116 stars 30 forks source link

Fix: Module not found exception #81

Closed sdk1990 closed 10 months ago

sdk1990 commented 1 year ago

Fixes issue #80:

cvolant commented 1 year ago

Thank you @sdk1990 ; I will try to have a closer look soon. 2 quick comments though:

sdk1990 commented 1 year ago

Thank you @sdk1990 ; I will try to have a closer look soon. 2 quick comments though:

  • There is conflicts, I don't know why. Could you try to rebase your branch on master?
  • If you import RouterContext like this, won't it break for earlier version of Next?

You are totally right @cvolant, I just had a better look and will pay more attention in the future :) Just fixed the conflicts and also implemented dynamic loading of the module with a fallback pointing to the original import path.

Kiliusz commented 1 year ago

Please merge this :)

cvolant commented 1 year ago

Thank you for the fixes. Did you succeed to run it with next 11.0.0 ? I tried but it did not work. I fought with it for a while : not an easy one. I tried another approach using Webpack fallback instead of dynamic loading, but did not succeed. I am only a Webpack padawan though, not sure I did it right...


      if (!config.resolve) {
        config.resolve = {}
      }
      if (!config.resolve.fallback) {
        config.resolve.fallback = {
          ['next/dist/shared/lib/router-context.shared-runtime']: 'next/dist/next-server/lib/router-context',
        }
      } else if (Array.isArray(config.resolve.fallback)) {
        config.resolve.fallback.push({
          alias: 'next/dist/shared/lib/router-context.shared-runtime',
          name: 'next/dist/next-server/lib/router-context',
        })
      } else {
        config.resolve.fallback['next/dist/shared/lib/router-context.shared-runtime'] =
          'next/dist/next-server/lib/router-context'
      }
cvolant commented 1 year ago

I did not try with next > 11.0.0. If it work with 11.1.0 for example, we could merely change next peer dependency from 11.0.0 to 11.1.0...

sdk1990 commented 1 year ago

I did not try with next > 11.0.0. If it work with 11.1.0 for example, we could merely change next peer dependency from 11.0.0 to 11.1.0...

I can't get 11.0.0 and 11.10.0 to work unfortunately. Maybe release the fix in this PR as a major change? In that way, older projects can use v1.10.2 of this package.

cvolant commented 1 year ago

Maybe release the fix in this PR as a major change?

:thinking: I am not found of it, but if it is the only option, I will have to. But then the dynamic import would not be needed anymore...

But I think it is probably possible to tackle this with some Webpack magic, either with the fallback config, or maybe we could use a conditionnal resolve config depending on Next version... I will try to take some time to try it again.

cvolant commented 1 year ago

@sdk1990, I fought with it way longer than I should, be I finally get it working in this new PR. Could you take a look at it? Would it be ok for you?

AndresGX commented 11 months ago

any update of this?

juliolz30 commented 11 months ago

hello, any update status of this ?

chrisomana commented 11 months ago

hello, any update status of this ?

facurubint commented 11 months ago

Please merge this :)

JedBh commented 10 months ago

Hey is there an update on this?

cvolant commented 8 months ago

Yes, at last! I just release 1.11.0-5, that basically does what this PR did: dropping support for old next version (<13.5.0). I tried hard to maintain the support, as reflected in the version number, without success unfortunately. I hope everything is is ok now. If yes, I will release 1.11.0.