Skip to content

Latest commit

 

History

History
41 lines (28 loc) · 1.35 KB

readme.md

File metadata and controls

41 lines (28 loc) · 1.35 KB

mini JS bundler image

A simple js bundler with no config but the main file as a unique argument, works with commonjs and ES modules. Totally commonjs complaint (see doc). It also supports the ES modules syntax (pre 2020), a good description of them is done here.

Example about how works

How works

  • It resolves the DFS three of requires dependencies by using the Babel parser and the Babel translator.
  • It overrides the exports attribute and the require method for each file and it creates a unique scope for each of them.
  • Concat all the modules!
  • Execute the main one!
  • ???
  • Profit

How to use it (CLI)

It only accepts a main file:

// using the main file directly
npm start ../other-things/my-file-with-requires.js
// or...
npm start --main='../other-things/my-file-with-requires.js'

By default, the generated file is stored in dist/output.js, but you could modify it by using the --output argument:

npm start ../other-things/my-file-with-requires.js --output='./other-output-name.js'

Check it!

This command compares the bundler output against the node.js output without concatenating the files:

npm test