Skip to content

Commit

Permalink
Switch to Babili and define browser targets.
Browse files Browse the repository at this point in the history
Resolve #321. Now Catberry uses babel-preset-env targets for last 2
browser versions and IE > 10 and Babili as a minifier.
  • Loading branch information
Denis Rechkunov committed Mar 27, 2017
1 parent 10551d3 commit 612eaf1
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 105 deletions.
17 changes: 1 addition & 16 deletions README.md
Expand Up @@ -183,22 +183,7 @@ In fact, a user gets an HTML page from the server only once and all the rest of

Thanks to Catberry's progressive rendering engine, user receives a page from the server component by component as fast as each component renders its template not waiting for the whole page is built.

All supported browsers are listed below:

| Browser | Version |
|-------------|-----------|
| IE | 9-10 (w/o client part, only server rendering), 11+ |
| IE Mobile | 11+ |
| Firefox | 4+ |
| Firefox Android | 29+ |
| Chrome | 19+ |
| Chrome Android | 35+ |
| Android Browser | 2.2+, 4.2+ |
| Safari | 6+ |
| iOS Safari | 5+ |
| Opera | 12+ |
| Opera Mobile | 11.1+ |
| Blackberry Browser| 7+ |
Catberry supports 2 last versions of modern browsers and IE 11. It depends on Babel [babel-preset-env](https://github.com/babel/babel-preset-env) preset which config you can override putting a `.babelrc` file in your project.

## Contributing

Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Expand Up @@ -908,7 +908,7 @@ const cat = catberry.create({isRelease: true});

As a summary, the difference between modes is:
* Debug mode - everything is watched for changes, the browser bundle is automatically rebuilt and all the modules are re-initialized on the server.
* Release mode - there is no watch for changes and all source code of the browser bundle is minified using [uglify-js](https://www.npmjs.org/package/uglify-js)
* Release mode - there is no watch for changes and all source code of the browser bundle is minified using [Babili](https://github.com/babel/babili)

**[↑ back to top](#table-of-contents)**

Expand Down
40 changes: 18 additions & 22 deletions lib/builders/BrowserBundleBuilder.js
Expand Up @@ -8,9 +8,9 @@ const mkdirp = require('mkdirp');
const watchify = require('watchify');
const babelify = require('babelify');
const babelEnv = require('babel-preset-env');
const babili = require('babel-preset-babili');
const browserify = require('browserify');
const hrTimeHelper = require('../helpers/hrTimeHelper');
const UglifyTransform = require('../streams/UglifyTransform');

const WORKING_DIR = process.cwd();
const DEFAULT_PUBLIC_DIRECTORY = path.join(WORKING_DIR, 'public');
Expand Down Expand Up @@ -367,34 +367,30 @@ class BrowserBundleBuilder {
_attachExtensionsToBundler(bundler) {
const isDebug = !this._isRelease;

const presets = [[
babelEnv, {
targets: {
browsers: [
'last 2 versions',
'not ie <= 10'
]
},
debug: isDebug
}
]];

if (this._isRelease) {
presets.push(babili);
}

bundler.transform(babelify, {
global: true,
ast: false,
comments: false,
presets: [[
babelEnv, {
targets: {
uglify: true // we have to transform to ES5 to make UglifyJS work
},
debug: isDebug
}
]],
presets,
sourceMap: isDebug
});

if (this._isRelease) {
bundler.transform(file => {
if (path.extname(file) !== '.js') {
return new stream.PassThrough();
}
this._eventBus.emit('trace', `Minifying code of the file "${file}"...`);
// TODO: migrate to Babili when it's ready
return new UglifyTransform();
}, {
global: true
});
}

this._setTransformations(bundler);
this._setPlugins(bundler);
}
Expand Down
65 changes: 0 additions & 65 deletions lib/streams/UglifyTransform.js

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -92,8 +92,8 @@
"entities": "^1.1.1",
"watchify": "^3.9.0",
"babelify": "^7.3.0",
"babel-preset-babili": "~0.0.12",
"babel-preset-env": "^1.2.2",
"uglify-js": "^2.8.13",
"browserify": "^14.1.0",
"promise": "^7.1.1",
"morphdom": "~2.2.0",
Expand Down

0 comments on commit 612eaf1

Please sign in to comment.