javascript - How to flatten file structure of published NPM module -


i have typescript project publishing npm module. output of compiling project in directory {mymodule}/dist/src/... means when publish, npm module takes above file structure.

the drawback when individual modules needs required, this:

var individualmodule = require('/dist/src'); 

i flatten output of published module, files in published module {mymodule}/... instead of {mymodule}/dist/src/...

in opinion correct way of doing intentionally expose modules package via module.exports (or import/export) in root file.

const exposableone = require('/dist/src/ex-1.js'); const exposabletwo = require('/dist/src/ex-2.js');  // ...  module.exports = { mymodule, exposableone, exposabletwo }; 

you can take @ main express framework file - doing same thing using exports. directive.

not typescript stuff idea quite common.

update:

if need without binding via require/exports, use symlinks approach. i'm not sure option works on platforms, example can check solved issue , this repository on github. aliases directory in latter contains files symlinked recipes directory modules.


Comments

Popular posts from this blog

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -

python - Error while using APScheduler: 'NoneType' object has no attribute 'now' -