A little bundler for resolving dependencies graphs into a single concatenated file.
npm install -g minipacco
This tool reimplements one of the features of the super bloated pacco.
In some sense it's a tiny language-agnostic bundler, it works like this:
- It expects an entry-point file, which can be any textual file.
- It resolves dependencies from that, recursively, building the dependency graph.
- A dependency on another file is defined by putting a special
@require ./other_file.js
string inside the requiring file, perhaps inside a comment. - Each file can depend on any number of other files, it just has to use multiple of those strings.
- After the dependency graph has been built a single output file will be generated which concatenates all files in the graph in the right order.
The utility of this is pretty niche, but for example this is used in Cash as it gets rid of all the overhead associated with modules and it also simplifies the codebase since a million imports and exports statements become unnecessary, basically there are no boundaries between modules, because each file is not a module, and that's pretty nice in some cases, like if each little file you have is supposed to extend some object or interface when imported, like it's the case in Cash.
A bundle
command is provided for bundling, it just accepts an entry file and outputs the concatenated string.
minipacco bundle src/index.js
A graph
command is provided for outputting the dot
-encoded dependency graph.
minipacco graph src/index.js
MIT © Fabio Spampinato