I have a project that include a gulp task for building and packaging the sources and release in a directory called dist
. My goal is publish it as a npm package, but only my dist folder. The npm documentation says that I can use the files
tag to specify files to export. It works. But, documentation also says that:
If you name a folder in the array, then it will also include the files inside that folder
The result, is a npm package, which node_modules looks like:
But I'd like to see all my files at the package's root (without that dist
folder). My index.js
file is inside the dist
folder, but should be at root. I've tried to set tag files
as /dist/**/*
but it didn't work.
How can I achieve it?
I have the same desire but I think there is no way of accomplishing this with only using npm tooling. Another script/tool could be used to arrange your package.
Currently I am copying my package.json
into the dist
folder and then running npm pack
inside the dist
folder. I think this essentially provides the desired arrangement of our package.
Here is some relevant reading on this npm design: Why no Directories.lib in Node.
It's also interesting to note that jspm DOES respect the directories.lib
option in package.json
and rearranges the files when resolving the npm package. This all has come about for me because I am wanting to build a common library which can be consumed by jspm or npm/webpack.