javascript - How change require to import with key in ES6? -
this question has answer here:
- how import part of object in es6 modules 2 answers
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;
Comments
Post a Comment