https://github.com/taxigy/try-prepack
Try Prepack (https://prepack.io)
https://github.com/taxigy/try-prepack
experiment prepack
Last synced: about 1 year ago
JSON representation
Try Prepack (https://prepack.io)
- Host: GitHub
- URL: https://github.com/taxigy/try-prepack
- Owner: taxigy
- Created: 2017-05-04T15:15:59.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-05-04T15:16:20.000Z (about 9 years ago)
- Last Synced: 2025-02-04T21:46:58.300Z (over 1 year ago)
- Topics: experiment, prepack
- Language: JavaScript
- Size: 45.9 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Try Prepack with Webpack
This is a tryout of [Prepack](/facebook/prepack), a tool to minimize the JS code via partial evaluation, so that instead of
```javascript
const MINUTE = 1000 * 60;
```
the result contains evaluated code:
```javascript
const MINUTE = 60000;
```
I was curious if it is applicable to React code, and looks like it is only partially applicable due to lots of unsupported breaking things in highly complex React code. For one, I found that
```javascript
import { renderToStaticMarkup } from 'react-dom/server';
```
would throw an exception and never proceed. Webpack would never output anything. So this stub is very basic because of that as well.
## Result
Just as expected: what can be evaluated, is evaluated, and Webpack's IIFE gets reduced into a little line of code, giving significant win in the output:
```bash
$ # without Prepack
$ yarn webpack > /dev/null; du -sh ./build/index.js
148K ./build/index.js
$ # with Prepack
$ ENABLE_PREPACK=true yarn webpack > /dev/null; du -sh ./build/index.js
4.0K ./build/index.js
```
with some insignificant increase in processing time.