node.js - How to define a npm module requirea babel transplie -
i have created npm module , uses babel translate es6/es7. , have defined prepublish below:
"scripts": { "build": "babel -d dist/ src/", "prepublish": "yarn run build", }, "main": "dist/index.js", when run npm publish can see runs prepublish compile code dist directory. defined main entry point dist/index.js.
but in other project has dependency on module, defined dependency below:
"devdependencies": { ... "mongo-shell-translator": "0.0.1-alpha.6", ... } when run yarn install can see dependency has been downloaded under node_modules dist directory not generated. project reports error saying error: can't resolve 'mongo-shell-translator'. how let other projects run babel during yarn install.
you don't need that, transpile source dist , add field package.json:
"files": [ "dist" ] that include folder npm repository , since main pointing pointing transpiled version.
Comments
Post a Comment