Skip to content

A simple js bundler with no config but the main file as a unique argument works with commonjs modules

License

Notifications You must be signed in to change notification settings

frankcortes/mini-js-bundler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

A simple js bundler with no config but the main file as a unique argument works with commonjs modules

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published