pnpm: `dependenciesMeta:injected` breaks hmr

I am on macos.

Here is my setup:

  • module @nativescript-community/template-snippet with dependencies like this:
"dependencies":{
"@nativescript-community/ui-material-bottomnavigationbar": "file:../packages/bottomnavigationbar"
}, 
"dependenciesMeta": {
        "@nativescript-community/ui-material-bottomnavigationbar": {
            "injected": true
        }
}
  • application using @nativescript-community/template-snippet like this:
"dependencies": {
        "@nativescript-community/template-snippet": "file:../demo-snippets",
},
"dependenciesMeta": {
        "@nativescript-community/template-snippet": {
            "injected": true
        }
    }

The idea behind this is to have @nativescript-community/ui-material-bottomnavigationbar as a “direct” dependency in hoist mode in my app (which i need).

It works in the sense that i do see @nativescript-community/ui-material-bottomnavigationbar in my app “node_modules” However HMR is broken for the file inside that package (node_modules/@nativescript-community/ui-material-bottomnavigationbar). I have realized that the file modified at this path is changed but the HMR only picks it up once i “open” or access that file. wondering if it comes from the way injected are “linked”? Screenshot 2022-03-04 at 13 24 02

Also as shown in the screenshot the full absolute path is used for the injected module “path name”. It is thus really long and could create issues like on Windows. Wouldn’t it be best to use the relative path?

EDIT: if i use touch on the real path with all the ++ then HMR (webpack) also picks it up.

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 24 (11 by maintainers)

Most upvoted comments

Is there an update on this by any chance? I am hitting this case where I need to use the dependenciesMeta.*.injected feature, but when doing so get an awful developer experience due to the HMR breaking. I’m trying to find some type of work around but am not finding one yet.

UPDATE - I think I found a workaround for this issue with Vite by combining the dependenciesMeta.*.injected feature with Vite’s server-watch functionality. So while I might have found something that works with Vite, I’m not sure about other build tools, and ideally a pnpm native solution can be figured out.