I'm publishing an npm package named foo
to the npm registry.
I wrote the package using a compile-to-js language.
For sanity, I put the compiled output into the dist/
folder of the project directory.
My package.json
lists the entrypoint as dist/entry.js
:
{
"name": "foo",
"main": "dist/entry.js",
}
Sometimes, I want to use files within the package that are not part of the entry point. For example, there is a very useful export called whatever
inside of dist/util.js
:
import { whatever } from "foo/dist/util";
This works, but forcing the users of my package to type dist/
in all import
statements is inconvenient.
Furthermore, re-exporting every possible util function is not DRY. I do not want to re-export from the entrypoint.
Ideally, I would like to import files from dist/
using the following syntax:
import { whatever } from "foo/util"
How do I configure my package.json
to search for files in the dist/
folder of my project?