Top "Es6-modules" questions

The standard module system for JavaScript, introduced in ECMAScript 6 (2015).

Alternative for __dirname in node when using the --experimental-modules flag

I use the flag --experimental-modules when running my node application in order to use ES6 modules. However when I use …

node.js ecmascript-6 es6-modules
ts-jest does not recognize es6 imports

I'm adding typescript support to a react codebase, and while the app is working ok, jest tests are failing all …

typescript babeljs jestjs es6-modules
How can I import Jest?

I would like to get rid of global variables in my Jest test code. Specifically describe, it and expect: describe(…

jestjs es6-modules
using brackets with javascript import syntax

I came across a javascript library that uses the following syntax to import libraries: import React, { Component, PropTypes } from 'react'; …

javascript ecmascript-6 es6-modules
Why and when to use default export over named exports in es6 Modules?

I have referred all the questions in stackoverflow. But none of the suggested why and when to use default export. …

javascript es6-modules
Destructuring a default export object

Can I destructure a default export object on import? Given the following export syntax (export default) const foo = ... function bar() { ... } …

javascript es6-modules
Jest mocking default exports - require vs import

I have seen questions referring to the mocking of default exports with jest around here, but I don't think this …

javascript jestjs es6-modules
Conditional export in ES2015

Let's say you're developing a polyfill and don't want to shim a class if it already exists in the browser. …

javascript ecmascript-6 es6-class es6-modules
async function or async => when exporting default?

export default async function () { }; or export default async () => { }; Which one is preferred when exporting a default function and why?

javascript node.js async-await arrow-functions es6-modules
Are ES6 module imports hoisted?

I know that in the new ES6 module syntax, the JavaScript engine will not have to evaluate the code to …

javascript ecmascript-6 hoisting es6-modules