next-transpile-modules: Watching doesn't work on top level imports
I understand that watching seems to work because it works in the sample repo linked here https://github.com/martpie/next-plugin-transpile-modules/issues/5#issuecomment-442516611
The thing is that if you import from a top level file in the package i.e. /shared/index.js watching doesn’t work on that file. It’s really odd, that is the case with yarn workspaces and file linking.
See https://github.com/masad-frost/monorepo-typescript-next-the-sane-way/compare/a5d89d844eba37231586f85564d7d47d433cdd04...master updating the contents of shared/index (index can be anything by the way) doesn’t trigger a recompilation, it has to be an import from a subfolder of the module
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 47 (17 by maintainers)
Hello! I created a demo repository for my situation with yarn workspaces: https://github.com/otroboe/next-transpile-modules-demo
Basically a “main app” with a shared lib. Not even a specific babel configuration. When I change the code in the lib, my app doesn’t reload, I have to restart it to have the change.
I hope it can help you, and maybe others!
I’m on Ubuntu 18.04.
Could reproduce it on Linux. Investigating.
Hi!
@martpie I think you can use official with-yarn-workspaces example from next.js repo. In this case
config.resolve.symlinks = truesolution works just fine.Right now I have similar issue, but with TypeScript. If you’re using
ts/tsxfiles you can’t useconfig.resolve.symlinks = truebecause you will get error about missing webpack loader for ts/tsx file.After few trys I came with quite simple solution (no idea if it’s correct, but it works).
My project
As you can see the biggest change is that I’m not providing package names but folder names.
Hope it helps 😃
References:
Can’t do much for now, I’ll check again why I enabled the
resolve.symlinksrule, it seems to be working without, but I know I had trouble without it before.Not sure if what I’m doing is wrong but setting
resolve.symlinksback totrueseems to fix it.I will think about adding a configuration option to change this. I may have time to work on this this week-end 😃
Sidenode @merrywhether, if you are transpiling npm packages, what is the problem with watching? You’re not changing those files yourself 🤔
this
config.resolve.symlinksis apparently a problem for many. I could probably make it opt-out in a future release. Would that solve everyone’s problem?Hello guys, I have a lot on my plate right now, but I will try to work on it, it’s a bit hard to debug as my development machine is a Mac, but I’ll do my best. I have a couple of ideas I would like to try.
Having a reproduction repo would help a lot.
Yes please! I am investigating on my side as well, did not face any error so far, but I know I added it for a reason I can’t remember ><