Currently, I am in the process of developing a new NPM package. The repository includes an examples
directory containing some JavaScript code that is compiled and served locally (or potentially through github.io).
The configuration is reminiscent of the setup in react-menu. If you examine any of the JavaScript files within the examples directory, you'll notice that they import the package as if it was just installed using npm install react-menu
:
import Menu, { SubMenu, Item as MenuItem } from 'rc-menu';
Surprisingly, the package is not listed under dependencies in the package.json file.
I am aware that I can import my own module by specifying something like
import myThing from '../../../index.js'
, but I prefer not having to deal with multiple relative directories. I attempted to import my module using import myThing from 'my-thing'
, but the package was not found and the import failed.
How exactly is react-menu accomplishing this?