Skip to content
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

Change translations file cause app full reload instead of hot reload (lazy: true) #1252

Closed
1 of 2 tasks
bahung1221 opened this issue Aug 2, 2021 · 9 comments
Closed
1 of 2 tasks
Labels

Comments

@bahung1221
Copy link

bahung1221 commented Aug 2, 2021

Version

nuxt-i18n: 6.20.6 and 6.28.0
nuxt: 2.14.5

Nuxt configuration

mode:

  • universal
  • spa

Nuxt-i18n configuration

i18n: {
lazy: true,
      langDir: 'lang/',
      defaultLocale: 'fr',
      locales: [
        {
          code: 'fr',
          file: 'fr-FR.js',
          name: 'Français'
        }
      ],
      strategy: 'no_prefix'
}

Reproduction Link

https://github.com/bahung1221/nuxt-i18n-hmr

Steps to reproduce

Change any text inside a translation file

What is Expected?

The app will be updated by hot reload

What is actually happening?

The app updated by full app reload

Screen Shot 2021-08-02 at 20 09 55

@rchl
Copy link
Collaborator

rchl commented Aug 2, 2021

I doubt this can be fixed. Probably reloading the page is the best we can do here.

@bahung1221
Copy link
Author

It seems this is a known issue, so I will close it.

Thanks 🍺

@appinteractive
Copy link

I doubt this can be fixed. Probably reloading the page is the best we can do here.

Why do you think that it's not possible? 🤔 is it not possible to rerun the import and replace the reactive values?

@rchl
Copy link
Collaborator

rchl commented Aug 29, 2021

It's webpack that does import reloading and in that specific case, since it's an async import, the best it can do is reload the page since it wouldn't know how to reload that data.

I believe that the only way that this could be made to work is if webpack would provide some hooks to override reloading behavior for specific imports but:
a) I don't think there is such a hook (feel free to prove me wrong)
b) even if there would be a hook, I don't know if I'd really would want to have this extra code and complexity to make this (IMO trivial) case work

Also, I guess a simple fix could be to just not use lazy during development.

@appinteractive
Copy link

Also, I guess a simple fix could be to just not use lazy during development.

So if that would be really a fix (can`t validate that now) shouldn't that be mentioned with a hint in the documentation?

@tvld
Copy link

tvld commented Sep 3, 2021

6.28.1 Solved it for me; even with lazy: true ! :-)

@tvld
Copy link

tvld commented Sep 13, 2021

And the issue is back. And that without changing anything in nuxt.config.js ... weird ((

@tvld
Copy link

tvld commented Sep 13, 2021

I updated nuxt.config.js with the following and now lazy loading seems to work again... but I am still investigating...::

   build: {
  
    extend (config, ctx) {
      // to solve You are using the runtime-only build of Vue where the template
      // used to render links in information-base articles
      config.resolve.alias.vue = 'vue/dist/vue.common'

      config.devtool = ctx.isClient ? 'source-map' : 'inline-source-map'

      // for language compilation we use .coffee files: these are the least overhead so easy to change for non-developers
      config.module.rules.push({
        test: /\.coffee$/,
        loader: 'coffee-loader'
      },
      {
        test: /\.js$/,
        loader: 'babel-loader',
        exclude: /(node_modules)/
      })
    }
  }

@paidge
Copy link

paidge commented Jan 7, 2022

I saw how to implement Hot Reload in the official documentation of vue-i18n but I don't know where to put the if (module.hot) section in a nuxt app because I'm a newbee with nuxt :p

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants