ember-cli / ember-cli/babel-plugin-ember-modules-api-polyfill

Handle wildcard imports: import * as something from '@ember/something'

Open
#16 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
15
Forks
19
PR merge metrics
No merged PRs in 30d

Description

https://github.com/babel/ember-cli-babel/issues/170#issue-246272427

> The [`import` statement](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import) supports importing all named exports into an object.
>
>For example, instead of this
>
>```js
>import {
> alias as computedAlias,
> and as computedAnd,
> // ...
>} from '@ember/object/computed';
>import { decoratedPropertyWithRequiredParams } from '../utils/decorator-macros';
>
>export const alias = decoratedPropertyWithRequiredParams(computedAlias);
>```
>
> you could just do this
>
> ```js
> import * as computed from '@ember/object/computed';
> import { decoratedPropertyWithRequiredParams } from '../utils/decorator-macros';
>
> export const alias = decoratedPropertyWithRequiredParams(computed.alias);
> ```
>
> But apparently, the latter does not work. :slightly_frowning_face:
>
> ```
> Could not find module `@ember/object/computed` imported from `ember-decorators/object/computed`
> ```

https://github.com/babel/ember-cli-babel/issues/170#issuecomment-318635180
> We would need to handle wildcard import in babel-plugin-ember-modules-API-polyfill. This seems reasonable to me though. We would need to check if the specified module contains only exports from a single namespace or multiple. If multiple namespaces we would have to build up the intermediate POJO that would be used.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing how the Babel plugin handles Ember module imports, then read the linked ember-cli-babel issue and comment. The work should make `import * as something from '@ember/something'` resolve correctly, including modules with one or multiple export namespaces; done means the documented wildcard example no longer reports the module-not-found error.

Written by the indexing model from the issue text.

Assessment

Tech stack
babel, javascript
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.