-
-
Notifications
You must be signed in to change notification settings - Fork 7.8k
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
NestJs HMR not working with "type": "module" #14331
Comments
It sounds like you didn't read the other suggestion about renaming the file to cjs? Did you? Did it not work? |
@jadejr I got below error converting to cjs
Below is my import in ts file. import { Client } from '@elastic/elasticsearch'; |
Does webpack even allow ESM bundling by default? I think your webpack configuration also need to use esbuild loader, then you can use https://github.com/privatenumber/esbuild-loader (Sorry for shallow answer here, I just want to point out missing things I see in a glance. I assume your webpack config is a Typescript file, no?) |
Is there an existing issue that is already proposing this?
Is your feature request related to a problem? Please describe it
Refer this #14312 as this is duplicate of that and action suggested on that has already been taken but it didn't help.
I have a issue with HMR when I use
"type": "module"
in package.json. Below is the full description.I followed NestJs HMR using webpack using following url.
https://docs.nestjs.com/recipes/hot-reload
It works fine when we use
"type": "commonjs"
in package.json.Unfortunately I have monorepo with client app that uses
"type": "module"
When I run
nest build --webpack --webpackPath webpack-hmr.config.js --watch
I get below error.
That is because I used require and module.exports with
"type": "module"
So I converted them to import and export default as below
Now I get following and for that part I am not sure how to solve it as I don't seem to find way to work with module type with webpack nest cli.
Have posted same on stackoverflow and also asked chatgpt if there is way to work with this but couldn't find any.
https://stackoverflow.com/questions/79269058/nestjs-hmr-not-working-with-type-module
Tried Discord too. But question simlpy got skipped. Probably there is no answer available to this yet and needs support from NestJs team itself.
https://discord.com/channels/520622812742811698/1316338004725596161
Describe the solution you'd like
Webpack HMR should work with
"type": "module"
in package.jsonTeachability, documentation, adoption, migration strategy
user should be able to use es module based webpack config.
What is the motivation / use case for changing the behavior?
HMR is quite important to be productive as it saves lots of time. Currently big server side code takes lots of time to reload entire node server.
The text was updated successfully, but these errors were encountered: