traceur

Get the class name of ES6 class instance

我的未来我决定 提交于 2019-12-17 05:41:19
问题 Are there any 'harmonious' ways to get the class name from ES6 class instance? Other than someClassInstance.constructor.name Currently I'm counting on Traceur implementation. And it seems that Babel has a polyfill for Function.name while Traceur doesn't. To sum it all up: there was no other way in ES6/ES2015/Harmony, and nothing is expected ATM in ES.Next. It may provide useful patterns for unminified server-side applications but is unwanted in applications meant for browser/desktop/mobile.

Run function loaded from ecmascript 6 module

时光怂恿深爱的人放手 提交于 2019-12-13 05:15:01
问题 I try to use ecmascript 6 modules system for first time. I use traceur compiler. Given two es6 files: // app.js export function row() { alert('row'); } // init.js import { row } from 'public_js/app'; row(); Traceur (I use grunt-traceur task) compiles them to: // app.js System.register("public_js/app", [], function() { "use strict"; var __moduleName = "public_js/app"; function row() { alert('row'); } return {get row() { return row; }}; }); // init.js System.register("public_js/init", [],

React and ES6 inheritance

社会主义新天地 提交于 2019-12-12 08:01:19
问题 Note: This post has been posted at the time React was NOT supporting ES6 (v12). I have an ES6 class : class BaseClass { getInitialState(){ return {message: 'Hello!'}; } render() { return ( <div> <div>{this.state.message}</div> </div> ) } } That I can export in ES6 using this expression (source : react ES6 browserify) export default React.createClass(BaseClass.prototype) This works fine. Now I would like to use ES6 inheritance to extend my BaseClass class : class ExtendedClass extends

Generating both browserify output & System.register() modules from ES6 modules?

∥☆過路亽.° 提交于 2019-12-11 09:07:55
问题 I have coded ES6 modules as per 2ality's final syntax example, without a .js suffix. I have as well organised the modules into a vendor/project directory hierarchy and module naming scheme as System.register() module format effectively places registered modules into the same namespace. The problem is as follows, if I quote 2ality's example: //------ lib.js ------ export const sqrt = Math.sqrt; export function square(x) { return x * x; } export function diag(x, y) { return sqrt(square(x) +

es6 import var not defined in code importing

六眼飞鱼酱① 提交于 2019-12-10 17:25:05
问题 For some reason when I do var sphere = new Core(); in Game, I see Core is undefined, even though I import it: Game.js import Core from 'gameUnits/Core' export class Game { constructor() { Core.js: export class Core { constructor(scene) { } } 回答1: When you make import without curly brackets you're trying to import default object of the module. So, you must add default keyword to your Core exporting: export default class Core { constructor(scene) { } } OR place your Core importing into curly

jspm does not transpile code from ES6 to ES5

两盒软妹~` 提交于 2019-12-07 08:25:18
问题 Running jspm bundle-sfx some/input some/output.js does not transpile my code from ES6 to ES5. This makes the output file unusable. Example contents of input file: [1,2,3,4].map((i)=>i*i); 回答1: As explained by jspm author here: ES6 transpilation only happens for ES6 modules, not ES6 files written in CommonJS. It means that transpilation happens only for files using module syntax ( import , export ). It can be forced though by adding "format es6"; at the top of the source file as so: "format

Using ES6 modules with traceur in single build file

我与影子孤独终老i 提交于 2019-12-05 22:42:27
I just have a simple question cant get in any place, heve been googling for it all morning. There is no much info about traceur and when there is is not so clear, at least to me. How should be implemented the ES6 modules when im transpiling with traceur a single output file and using it in the browser with traceur-runtime? import and export keeps getting Unexpected token. I am using gulp-traceur and tried already all the modules options //'commonjs' //'amd', 'commonjs', 'instantiate', 'inline', 'register'. One doubt I have is that I keep finding answers about commonjs, but my idea of using ES6

jspm does not transpile code from ES6 to ES5

北战南征 提交于 2019-12-05 15:52:14
Running jspm bundle-sfx some/input some/output.js does not transpile my code from ES6 to ES5. This makes the output file unusable. Example contents of input file: [1,2,3,4].map((i)=>i*i); As explained by jspm author here : ES6 transpilation only happens for ES6 modules, not ES6 files written in CommonJS. It means that transpilation happens only for files using module syntax ( import , export ). It can be forced though by adding "format es6"; at the top of the source file as so: "format es6"; [1,2,3,4].map((i)=>i*i); 来源: https://stackoverflow.com/questions/30720963/jspm-does-not-transpile-code

AngularJS2.0 教程系列(一)

最后都变了- 提交于 2019-12-05 03:58:21
Why Angular2 Angular1.x显然非常成功,那么,为什么要剧烈地转向Angular2? 性能的限制 AngularJS 当初是提供给设计人员用来快速构建HTML表单的一个内部工具。随着时间的推移,各种特性 被加入进去以适应不同场景下的应用开发。然而由于最初的架构限制(比如绑定和模板机制),性能的 提升已经非常困难了。 快速变化的WEB 在语言方面,ECMAScript6的标准已经完成,这意味着浏览器将很快支持例如模块、类、lambda表达式、 generator等新的特性,而这些特性将显著地改变JavaScript的开发体验。 在开发模式方面,Web组件也将很快实现。然而现有的框架,包括Angular1.x对WEB组件的支持都不够好。 移动化 想想5年前......现在的计算模式已经发生了显著地变化,到处都是手机和平板。Angular1.x没有针对移动 应用特别优化,并且缺少一些关键的特性,比如:缓存预编译的视图、触控支持等。 简单易用 说实话,Angular1.x太复杂了,学习曲线太陡峭了,这让人望而生畏。Angular团队希望在Angular2中将复杂性 封装地更好一些,让暴露出来的概念和开发接口更简单。                                                       Rob Eisenberg / Angular 2

React and ES6 inheritance

我们两清 提交于 2019-12-03 13:39:49
Note: This post has been posted at the time React was NOT supporting ES6 (v12). I have an ES6 class : class BaseClass { getInitialState(){ return {message: 'Hello!'}; } render() { return ( <div> <div>{this.state.message}</div> </div> ) } } That I can export in ES6 using this expression (source : react ES6 browserify ) export default React.createClass(BaseClass.prototype) This works fine. Now I would like to use ES6 inheritance to extend my BaseClass class : class ExtendedClass extends BaseClass{ getInitialState(){ return {message: "Hello! I'm an extension"}; } } But when I call React