ember-cli / ember-cli/babel-plugin-ember-modules-api-polyfill
Handle wildcard imports: import * as something from '@ember/something'
- Vorherrschende Sprache
- JavaScript
- Sterne
- 15
- Forks
- 19
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
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.
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Rechercherichtung
Beginne damit nachzuverfolgen, wie das Babel-Plugin Importe von Ember-Modulen verarbeitet, und lies anschließend den verlinkten ember-cli-babel-Issue sowie den Kommentar dazu. Die Arbeit sollte dafür sorgen, dass `import * as something from '@ember/something'` korrekt aufgelöst wird, einschließlich Modulen mit einem oder mehreren Export-Namespaces; als abgeschlossen gilt sie, wenn das dokumentierte Wildcard-Beispiel nicht mehr den Module-not-found-Fehler meldet.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- babel, javascript
- Bereich
- tooling
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100