New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Supports ES2015 modules #10
Conversation
Hi, Great PR, but what is purpose of compiling to es2015? PS it's better call it es2015 =) |
Because it is a current standard for a year. I don't know what AMD, commonJS and whatever else is, W3C has no connection to them. JS = ES2015 and in 2016 you have to use it. |
@Elfet Most realistically, bundlers like rollup can aggressively analyze and remove unused codes and collapse all scopes into a single one, greatly improving its performance. With CommonJS bundlers can only play it safe and wrap everything up. For Tumblr, walking through the dependency tree takes a whopping 400ms. This is not a issue with bundled ES2015 modules because there is no tree to begin with. ES2015 modules also supports circular dependencies and live binding for imported/exported variables, which is always a plus. |
Some note: my browser (Chrome) isn’t very happy with |
I'm going to merge this PR, but i'd like to make a few changes before: like naming conventions and option param name (i'd like to see what other libraries like webpack or typescript using for same purpose).
This is some kind of easter eggs do you have problems with it? |
@Elfet My test suites wouldn’t run, but that’s it. |
@alexlur do you run test with |
@Elfet Yeah. Is it a bug with |
What king of bug you getting? Because it's work good for me. |
|
@Elfet Looks good. |
"babel-preset-es2015": "^6.9.0", | ||
"jasmine": "^2.4.1", | ||
"jison": "^0.4.17", | ||
"phantomjs-prebuilt": "^2.1.7", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't run tests without explicitly installing phantomjs.
I'n going to implement it myself based if this pr. |
I believe '-t' option is not yet in master? Also could you please make a main monkberry.js itself with ES6 export so it would be possible to import it as ES6 with Rollup like there is lodash-es repo for example? node build.js script: var rollup = require('rollup');
var npm = require('rollup-plugin-node-resolve');
rollup.rollup({
entry: 'app.js',
plugins: [
npm(),
]
}).then(function(bundle) {
return bundle.write({
dest: 'dist/app.js'
});
}).then(function() {
console.log('Rollup bundle created');
}).catch(function(e) {
console.error(e);
}); I have manually added ES6 imports/exports to monkberry and compiled template. Everything worked fine. app.js import Monkberry from './monkberry';
import Template from './view';
const view = Monkberry.render(Template, document.body);
view.update({title: 'Test'}); template.monk compiled into view.js via <div>
<h1>{{ title }}</h1>
</div> It also would be very nice to have a JavaScript API to compile templates via build scripts and not only via CLI. |
This pull requests adds the cli option
--ecma-version
to support producing ES6 outputs for use of either modern browsers or for ES6 module aware transpilers, such as rollup and Webpack 2.