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

HMR for nuxt modules #2747

Closed
Zip753 opened this issue Feb 2, 2018 · 8 comments
Closed

HMR for nuxt modules #2747

Zip753 opened this issue Feb 2, 2018 · 8 comments
Labels

Comments

@Zip753
Copy link

Zip753 commented Feb 2, 2018

Is there a way to use HMR with nuxt modules? In my specific case I'm using nuxt-i18n module, which requires a set of translations as a module param specified in nuxt.config.js directly. Now, I've tried adding dependent files to build.watch config, but the app doesn't seem to reload, and from the source code it seems that the modules aren't affected by HMR in any way.

Therefore, from my perspective, there should either be a way to rebuild modules in HMR somehow, or there should be a better way to provide module options, so that they are automatically watched by HMR.

I haven't dug into how Webpack HMR works, but I suppose there is a way to write custom plugin for that to work, still it would be a great functionality if it was done out of the box.

This question is available on Nuxt.js community (#c2384)
@mathieutu
Copy link

Exactly the same here, and I've also tried to add files in build.watch, but nothing happen when changing them...

@mathieutu
Copy link

I think I've found one part of the problem: #2983

But it's true than the modules are not reloaded during the build, so I totally agree with you.

@Zip753
Copy link
Author

Zip753 commented Mar 14, 2018

An update from my side: I'm using Nuxt in setup with Express (from nuxt-community/express-template), so Nuxt itself actually doesn't handle HMR as it's handled by Backpack. Therefore, when I added the files I wanted to track to Backpack config (via webpack-watch-files-plugin) the HMR started working as expected, refreshing the build every time I changed my translations files. Now, I haven't tested it with build.watch option in nuxt.config.js, so in my case it might actually work just fine.

As a conclusion, I can suggest that the documentation of build.watch is updated to warn that it only works when running Nuxt app via nuxt dev.

@mathieutu
Copy link

@Zip753 actually as I said, only the webpack part of the build is reloaded when adding a file in watch, so the modules are not reloaded at all, event with nuxt dev.

@manniL
Copy link
Member

manniL commented Aug 12, 2018

@mathieutu @Zip753 Does the latest nuxt-edge version fixes this issue? 🤔

@mathieutu
Copy link

Nope I don't think so, sorry.

@clarkdo
Copy link
Member

clarkdo commented Aug 13, 2018

The latest edge has introduced a new config watch, you can try to add modules into it.

Docs: https://github.com/nuxt/docs/blob/2.0/en/api/configuration-watch.md

@clarkdo clarkdo closed this as completed Aug 13, 2018
@lock
Copy link

lock bot commented Nov 1, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Nov 1, 2018
@danielroe danielroe added the 2.x label Jan 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants