Skip to content

Not able to expose the variable with dot in its name #19

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

Closed
TylerYang opened this issue Mar 15, 2016 · 1 comment · Fixed by #100
Closed

Not able to expose the variable with dot in its name #19

TylerYang opened this issue Mar 15, 2016 · 1 comment · Fixed by #100
Assignees

Comments

@TylerYang
Copy link

Hi guys, let's say I have a js file with dot in its name, e.g xyz.template.js. And I want to expose it into my global variable modules => modules['xyz.template.js'].

According to the source code below(value.split(".")), it is not possible to expose a variable which name contains 'dot'. I think it should be able to do that,

 function accesorString(value) {
    var childProperties = value.split(".");  // Not able to expose 'xyz.template'  
    var length = childProperties.length;
    var propertyString = "global";
    var result = "";

    for(var i = 0; i < length; i++) {
        if(i > 0)
            result += "if(!" + propertyString + ") " + propertyString + " = {};\n";
        propertyString += "[" + JSON.stringify(childProperties[i]) + "]";
    }

    result += "module.exports = " + propertyString;
    return result;
}

Please correct me if I was wrong about this.

@evisong
Copy link

evisong commented May 23, 2016

According to source code, it becomes modules['xyy']['template']['js']

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

Successfully merging a pull request may close this issue.

4 participants