Importing from packages sub directory

I am writing a package for npm, and I was wondering how I can setup the packages, so that people can import specifics thing from the package subdirectory.

For example, I have a package name “MyPackage” that has “myFunction” in the path lib/my/subdir.

import {myFunction} from “MyPackage” works.

I want to be able to also do this:

import { myFunction} from “MyPackage/my/subdir”

Right now, I have to write”

import {myFunction} from “MyPackage/lib/my/subdir”

The extra “lib” is due to the where npm build produce the production codes.