Sha256: 8afd8afc6e3b30b65e8ba3000a352e9c500586a32f02513989dcac3fe619c8d2

Contents?: true

Size: 1.27 KB

Versions: 24

Compression:

Stored size: 1.27 KB

Contents

# ES6


## Babel

Webpacker ships with [babel](https://babeljs.io/) - a JavaScript compiler so
you can use next generation JavaScript, today. The Webpacker installer sets up a
standard `.babelrc` file in your app root, which will work great in most cases
because of [babel-env-preset](https://github.com/babel/babel-preset-env).

Following ES6/7 features are supported out of the box:

* Async/await.
* Object Rest/Spread Properties.
* Exponentiation Operator.
* Dynamic import() - useful for route level code-splitting
* Class Fields and Static Properties.

We have also included [babel polyfill](https://babeljs.io/docs/usage/polyfill/)
that includes a custom regenerator runtime and core-js.

Don't forget to import `babel-polyfill` in your main entry point like so:

```js
import "babel-polyfill"
```


## Module import() vs require()

While you are free to use `require()` and `module.exports`, we encourage you
to use `import` and `export` instead since it reads and looks much better.

```js
import Button from 'react-bootstrap/lib/Button'

// or
import { Button } from 'react-bootstrap'

class Foo {
  // code...
}

export default Foo
import Foo from './foo'
```

You can also use named export and import

```js
export const foo = () => console.log('hello world')
import { foo } from './foo'
```

Version data entries

24 entries across 24 versions & 3 rubygems

Version Path
webpacker-3.6.0 docs/es6.md
webpacker-jets-3.2.101 docs/es6.md
webpacker-jets-3.2.100 docs/es6.md
webpacker-3.5.5 docs/es6.md
webpacker-3.5.3 docs/es6.md
webpacker-3.5.2 docs/es6.md
webpacker-3.5.1 docs/es6.md
webpacker-3.5.0 docs/es6.md
webpacker-3.4.3 docs/es6.md
webpacker-4.0.0.pre.pre.2 docs/es6.md
webpacker-4.0.0.pre.pre.1 docs/es6.md
webpacker-3.4.1 docs/es6.md
webpacker-3.4.0 docs/es6.md
webpacker-3.3.1 docs/es6.md
webpacker-3.3.0 docs/es6.md
webpacker-3.2.2 docs/es6.md
webpacker-3.2.1 docs/es6.md
webpacker-3.2.0 docs/es6.md
webpacker-3.1.1 docs/es6.md
webpacker-3.1.0 docs/es6.md