Reserved word usage "import" in javascript

Asked

Viewed 219 times

1

Reading the Ghost code, CMS platform based on Nodejs found a file with the following statement:

import Ember from 'ember';
import Resolver from 'ember/resolver';
import loadInitializers from 'ember/load-initializers';
import 'ghost/utils/link-component';
import 'ghost/utils/text-field';
import config from './config/environment';

I’ve already found something on the Internet about being ES6. But it is an application that is being used in production, an environment not very favorable to experiments like ES6. Now comes the doubts

They use some external library or it is on account of some already active Feature that enables the use of ES6?

PS: The ghost uses Ember as we can already see in this import and the file if you want to consult is this one, code for Ghost on Github

  • 1

    Ghost supports Node 0.12 and IO.js which are already (almost 100%) ES6. But possibly using one ES6-transpiler (ES6 to ES5 converter)

1 answer

1

ES6 is no longer experimental, has been renamed ES2015, and has been approved since June.

Most browsers are already implementing the vast majority of their specifications, and there are already very reliable transpilers so you can already use the vast majority of their Features, which will be compiled and translated into Javascript (ES5).

The largest transpilers that exist today are Babel (formerly called 6to5) and Traceur (by Google). I prefer Babel, since it already has 73% of the "breathable Features".

You can see the ES6 compat-table: http://kangax.github.io/compat-table/es6/

There are some Javascript frameworks, such as Aurelia which have already been made 100% developed in ES6 (and some ES7 things up, like the decorators and the declaration of properties outside the builder).


ES6 is very interesting, and we will probably have all the Sites implemented in the Evergreen Browsers by the end of this year/beginning of next year - so I suggest you start studying it right away.

As for "import", it is something that has been used for a long time in ES5 through Libraries like Require, and nowadays the library that follows the specifications of ES6 is the System.JS

  • I have already studied ES6, but it was more by curiosity to know that the Ghost using and answer on Node 0.12, was very objective.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.