Each answer requires a change in import statements.
If you want to be able to use:
import {a} from './my-module' // a === 1 import * as myModule from './my-module' // myModule.a === 1
as in the question, and in your my-module you have everything that you need to export in one object (which may be useful, for example, if you want to check the exported values ββusing Joi or JSON Schema), then your my-module will have to be either:
let values = { a: 1, b: 2, c: 3 } let {a, b, c} = values; export {a, b, c};
Or:
let values = { a: 1, b: 2, c: 3 } export let {a, b, c} = values;
Not pretty, but it matches what you need.
See Babel example
rsp Jul 26 '18 at 11:53 2018-07-26 11:53
source share