Necessitates Proper Modularity
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

@nathanfaucett/comn

0.0.13 • Public • Published

comn

comn is a commonjs compiler

$ comn -f ./path/to/file -o ./path/to/out
var comn = require("comn");
 
 
var out = comn("path/to/index.js", {
    parseAsync: false,
    builtin: {},
    mappings: {},
    packageType: "main"
});
 
// single file output
fs.writeFileSync("path/to/out/file.js", out.entry().source);
 
// if parsed async deps
out.each(function(chunk) {
    fs.writeFileSync("path/to/out/file.js", "//# sourceMappingURL=./path/to/sourceMap\n" + chunk.source);
});
 
// will generate source maps for each entry
out.generateSourceMaps();
 
out.each(function(chunk) {
    fs.writeFileSync("path/to/out/file.js.map", chunk.sourceMap.toJSON());
});
 

Async Parsing

// can load node modules or files parses path/to/file into separate file unless
// the parseAsync option is false
require.async("path/to/file", function(file) {
    console.log(file);
});

Keywords

install

npm i @nathanfaucett/comn

Downloadsweekly downloads

32

version

0.0.13

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability