The question is pretty self-explanatory. May I?
IMO That would be great!
You can do it like such in TypeScript:
```typescript
import * as faker from 'faker';
````
I'm not sure how this would work for ES6 though
You can do it !
I use example: import faker from 'faker'; or var faker = require('faker');
const faker = require("faker");
Bingo!
I think the comments are missing the intent of the issue. The ability to import faker with es6 is to import only what functionality you need and leverage tree-shaking. Currently, you pay the penalty of the entire library. See below.

The answer is yes (kind of), i.e. you can import the sub namespaces explicitly.
import { company, address } from 'faker';
However this works because the entire faker namespace is assigned to module['exports'] in index.js and I'm not so sure if this still allows for tree shaking, since those sub "namespaces" are simply members of a huge object and no es/ts modules.
Update: I just tested it with rollup and I was right. It doesn't matter if I import faker.. or import { company }... the bundle size is always the same.
Consequently what you cannot do is import only single functions from each namespace, i.e.
import { city } from 'faker/company';
I've just looked into it and this would require major package restructuring. Going for typescript (since its a library) could also be considered while doing this but is in fact out of scope of import concerns.
@Marak whats your take on this? Do you plan on splitting up all the namespaces to their own es modules? I could help with that if necessary.
Any traction on this? I can collaborate as well if necessary.
Most helpful comment
The answer is yes (kind of), i.e. you can import the sub namespaces explicitly.
However this works because the entire
fakernamespace is assigned tomodule['exports']inindex.jsand I'm not so sure if this still allows for tree shaking, since those sub "namespaces" are simply members of a huge object and no es/ts modules.Update: I just tested it with rollup and I was right. It doesn't matter if I
import faker..orimport { company }...the bundle size is always the same.Consequently what you cannot do is import only single functions from each namespace, i.e.
I've just looked into it and this would require major package restructuring. Going for typescript (since its a library) could also be considered while doing this but is in fact out of scope of import concerns.
@Marak whats your take on this? Do you plan on splitting up all the namespaces to their own es modules? I could help with that if necessary.