boopathi / babel-minify Goto Github PK
View Code? Open in Web Editor NEW:rotating_light: Project is Discontinued and I'm contributing here -
Home Page: https://github.com/babel/babili
:rotating_light: Project is Discontinued and I'm contributing here -
Home Page: https://github.com/babel/babili
var x = 5;
if (0) var x = 0;
1st pass:
var x = 5; var x;
2nd pass:
var x = 5, x;
expression ? true : false
expression ? false : true
a === b ? !1 : !0
a ? true : false // to !!a
x ? -1 : -1 // -1
FunctionDeclarations inside Block Statements are let
instead of var
Related discussion: https://phabricator.babeljs.io/T7475
In "use strict"
environments,
{
function a() {}
}
a()
is like
{
let a = function a() {};
}
b();
Bug in conditionals and mangle names. Should we detect strict environments and handle them separately or assume (for this bug alone) to be use strict.
How should this be done ? What should be considered ?
{
var x = 5;
function a() {}
}
var x = 6;
returns
{ var b = 5; function b() {} } var a = 6;
The function name a
(or something that the mangler will assign) gives this error, doesn't happen for other function names.
babel-minify options
Change from npasses
to just passes
.
escompress uses a similar strategy of building a minifier on top of babel transforms. It may be worth consolidating your efforts.
I posted a similar issue in escompress's issue tracker here - https://github.com/escompress/escompress/issues/10
As an example, I tried unminified React code on Chrome Canary with the browser version of the minifier and the time taken was around 19s
in the worker thread.
var a = function () { function b() { this } }
can be transformed to
var a = () => { function b() { this } }
eg:
function foo() {
var bar; // this can be mangled
(1, eval)("bar = 0");
}
function-to-arrow should take keep_fnames argument and transform even more functions to arrows when keep_fnames is false.
Related - https://phabricator.babeljs.io/T7470
When a global var already exists, there is no binding, and mangler fails to check this.
var x = 1;
var y = a + 1;
and the output is
var a=1,b=a+1;
Hi, i have problem when i transpiling es6 with using babel-preset-min and plugins babel-add-module-exports
src/index.js
export default (tree, a = {}) => {
console.log(a, tree);
return () => {};
};
babel config
"babel": {
"presets": [
"es2015",
"min"
],
"plugins": [
"add-module-exports"
],
"comments": true,
"compact": true,
"minified": true
}
after run $ babel src/ -d lib/
i get:
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.default=function(b){var c=arguments.length<=1||arguments[1]===void 0?{}:arguments[1];console.log(c,b);return function(){}};
see in end line
else run without presets min
i get:
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=function(tree){var a=arguments.length<=1||arguments[1]===undefined?{}:arguments[1];console.log(a,tree);return function(){}};module.exports=exports["default"];
see in end line
i have a broken build after update to v0.1.9
Plugin for global definitions
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.