https://github.com/fabiosantoscode/ecmacomp
https://github.com/fabiosantoscode/ecmacomp
Last synced: 6 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/fabiosantoscode/ecmacomp
- Owner: fabiosantoscode
- Created: 2018-12-17T16:13:09.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-03-06T22:45:08.000Z (almost 7 years ago)
- Last Synced: 2025-03-18T07:17:25.661Z (11 months ago)
- Language: JavaScript
- Size: 346 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ecmacomp [](https://travis-ci.org/fabiosantoscode/ecmacomp)
Compile javascript modules, optimize them with prepack and terser if `NODE_ENV` is `production`, and do more optimisations from this project. Reduce your code in production today!
Further optimizations are coming up:
- Caching React elements in variables and modifying them before passing them to React.createElement
- Turning fs.readFileSync and other sync APIs into their Promise counterparts, and turning every function above the call into an async function
- Removing react completely using rawact
- Reducing GC allocations
- Caching some function results
- ...And other amazing optimizations
## Usage (CLI)
You can disable rollup or prepack (to disable terser, use the `NODE_ENV` environment variable `NODE_ENV=production ecmacomp ...`)
```bash
$ ecmacomp input.js [--norollup] [--noprepack] [--public dir] [--output file]
```
## Usage (JS API)
```javascript
const code = await require('ecmacomp')({ filename: 'input.js' })
const code2 = await require('ecmacomp')('function code() {}')
```
## Hacking `ecmacomp`
To hack on ecmacomp, clone this repository (`git clone https://github.com/fabiosantoscode/ecmacomp`), `cd` to it, run `npm i`, write a test in the appropriate place, respect the lint (`npm run lint`) and start hacking :)
This CLI command reveals the bytecode for a piece of javascript:
```bash
$ ecmacomp --parse input.js
```
You can use this bytecode as reference because it's the bytecode used in all the optimisations.