# ES Modules: import & destructure at once!

**URL:** <https://es.discourse.group/t/es-modules-import-destructure-at-once/425>\
**Category:** 💡 Ideas\
**Tags:** proposal\
**Created:** [August 12, 2020, 11:17pm UTC](https://es.discourse.group/t/es-modules-import-destructure-at-once/425 "2020-08-12T23:17:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![iamfotx](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/iamfotx/32/1763_2.png) [@iamfotx](https://es.discourse.group/u/iamfotx)\
**Post date:** [August 12, 2020, 11:17pm UTC](https://es.discourse.group/t/es-modules-import-destructure-at-once/425/1 "2020-08-12T23:17:31Z")

</div>

# The Problem:

ES modules don't support for import and destructure the exports at once, in some situations, it takes an additional step like this:

```javascript
import { config } from './config'
const {port, ...rest} = config

```

# The solution:

Wouldn't it be nice if we could import and destructure in no time? something like this:

```javascript
import { config: { port }, ...rest } from './config'

```

Thanks!

---

<div class="post-metadata">

**Author:** ![bergus](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/bergus/32/152_2.png) [@bergus](https://es.discourse.group/u/bergus)\
**Post date:** [August 13, 2020, 12:01am UTC](https://es.discourse.group/t/es-modules-import-destructure-at-once/425/2 "2020-08-13T00:01:44Z")

</div>

I don't think it would be nice, it would only increase the confusion about the difference between them. Notice that in a syntax like

```javascript
import { config as { port, ...rest } } from './config';

```

it would not be clear whether `port` and `rest` are declared as `let`, `const`, or would become an alias (reference, getter) for `config.port` and, uh, something respectively. The extra line really doesn't hurt. If you have to do this a lot, consider whether the _config_ module should rather have `port` and `rest` named exports in addition to `config`.
