ember-codemods / ember-modules-codemod

Codemod to upgrade Ember apps to JavaScript (ES6) modules

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Missed destructuring of old 'rsvp' shim

kellyselden opened this issue · comments

If you use the old shim like:

import RSVP from 'rsvp';

const { resolve } = RSVP;

It is not caught by the codemod. Is that something worth supporting? Please close if it is out of scope.

It correctly converts:

import Ember from 'ember';

const { RSVP: { resolve } } = Ember;

into

import { resolve } from 'rsvp';

Seems fine to support I think. Not sure what changes would be needed....

As another data point, I had the same issue in my repos. It seems to apply to all nested destructures which are been broken across multiple statements.

A simplified example:

Before codemod:

const { computed } = Ember;
const { oneWay } = computed;

After codemod:

import { computed } from '@ember/object';

const { oneWay } = computed;

Note the const { oneWay } = computed; is ignored by the codemod.

I can't speak to how common this pattern elsewhere, but in our team, we preferred this format over const { a: { b } } = c; for readability, and therefore have it in lots of places within our code.

Yep. Totally agree with you there (multi-level destructures really hurt my head 🤕). This just needs someone to care enough to put in the time to fix. Anyone feel like making life better for everyone else? 🤗

@jordansaints @rwjblue - I opened a PR to fix the multi-statement problem that Jordan brought up above: #81

The RSVP case will be a little bit trickier, as it doesn't come from an Ember global.

Thanks for picking up and fixing it so fast @danwenzel! Much appreciated :)