If the alternative to:
var Foo = require('foo');
is:
import Foo from 'foo';
What is the alternative to:
var Bar = require('foo').batz
Could it be:
import {batz} from 'foo' ?
Nearly. It does however depend on how you are exporting them.
named exports (export var batz = …):
export var batz = …
import {batz as Bar} from 'foo';
default-exported object (export default {batz: …};) - should not be used:
export default {batz: …};
import Foo from 'foo'; var Bar = Foo.batz;
1.4m articles
1.4m replys
5 comments
57.0k users