javascript - How change require to import with key in ES6? -


this question has answer here:

i whant write require es6 import. in case without key it's pretty ease do

var args2 = require('yargs2'); -> import foo 'bar';

but key, can't find appropriate syntax:

var foo = require('bar').key; 

how can that?

the syntax importing member of module aliased name is:

import {key foo} 'bar'; 

this equivalent var foo = require('bar').key;

if want import member without aliasing it, syntax simpler:

import {foo} 'bar'; 

is equivalent to:

 var foo = require('bar').foo; 

mdn article import statement


Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -