DEV Community

Discussion on: How Pros Get Rid of Relative Imports

Collapse
richardeschloss profile image
Richard Schloss • Edited on

subpath patterns can also be used in package.json. I like to think of it as a cool free feature baked right in to nodejs.

For example:

{
  "exports": {
    "./features/*": "./src/features/*.js"
  },
  "imports": {
    "#internal/*": "./src/internal/*.js",
    "#root/*": "./"
  }
}
Enter fullscreen mode Exit fullscreen mode

This way, it's tied to the node project, which will work no matter what the IDE is.

Collapse
ruppysuppy profile image
Tapajyoti Bose Author

Thanks a lot for sharing! I wasn't aware of this feature