javascript - How to set relative path resolution based on 'dist' folder -
when creating npm package, quite common , convenient structure so: root / dist / src / package.json where package.json : { "main": "dist/index.js" "files": [ "dist" ] } the drawback of approach is, when consumer wants require files using relative path, needs include dist folder. e.g. const abc = require('my-package/dist/x/y/abc'); is there way tell nodejs resolve relative path based on path.dirname(main) or similar? update: clarify, related relative/deep resolution, not export hoisting in es6. controversial subject should done @ all, consumer coupled internal folder structure of package. update 2: want achieve concept of "sub-module" (similar namespacing). example, folder structure looks this: root / dist / testutil.js / index.js testutil.js contains useful functions testing. since not used in normal use, don't want export them @ top-level. i.e., instead of: // index.js export...