Last Updated: February 25, 2016
·
1.442K
· mruzekw

Import CommonJS modules without default export via ES6

Without default

import * as foo from "foo";

var foo = require("foo");

With default

import foo from "foo";

var foo = require("foo").default;

Complete conversion here: https://github.com/sebmck/6to5/blob/master/MODULES.md#common-default

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.

Security insights from Cside