Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

5to6-codemod/transforms/exports.js can't handle variable exports case #48

Open
faywong opened this issue Jun 21, 2017 · 3 comments
Open

Comments

@faywong
Copy link

faywong commented Jun 21, 2017

var exports = module.exports = {
    'testkey': 'testvalue'
};

// 导出错误类型码
Object.keys(constants).forEach(function (key) {
    if (key.indexOf('ERR_') === 0) {
        exports[key] = constants[key]; // this line will be converted wrong
    }
});

will be converted to

   export const key = ...
@jsnmoon
Copy link
Collaborator

jsnmoon commented Jun 22, 2017

Hi @faywong, I've cobbled together a fix for this in this branch; let me know if this works for you.

@jsnmoon
Copy link
Collaborator

jsnmoon commented Jul 25, 2017

Hi @faywong, have you had the chance to try the branch with the fix yet?

@coleturner
Copy link

coleturner commented Jan 20, 2018

The result I received:

var exports = {
    'testkey': 'testvalue'
};

export default exports;

// 导出错误类型码
Object.keys(constants).forEach(function (key) {
    if (key.indexOf('ERR_') === 0) {
        exports[key] = constants[key]; // this line will be converted wrong
    }
});

Seems to have fixed it 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants