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

Client.js getting root as undefined #105

Closed
neilmalgaonkar opened this issue Mar 28, 2016 · 2 comments
Assignees
Labels
bug
Milestone

Comments

@neilmalgaonkar
Copy link

@neilmalgaonkar neilmalgaonkar commented Mar 28, 2016

Hi,

I am trying out with hapi nes protocol in my current project. for testing purpose I implemented first example given on github page.

I included client.js file into script tag in chat.html page from dist folder of nes.
but when I try new nes.Client() or new Nes.Client() I get nes/Nes is undefined error.

After adding some console.log in client.js I realised that root is "undefined" while passing to factory function.

following is the snippet of code generated by running command npm run build-client

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };

(function (root, factory) {

    // $lab:coverage:off$

    if ((typeof exports === 'undefined' ? 'undefined' : _typeof(exports)) === 'object' && (typeof module === 'undefined' ? 'undefined' : _typeof(module)) === 'object') {
        module.exports = factory(); // Export if used as a module
    } else if (typeof define === 'function' && define.amd) {
            define(factory);
        } else if ((typeof exports === 'undefined' ? 'undefined' : _typeof(exports)) === 'object') {
            exports.nes = factory();
        } else {
            root.nes = factory();
        }

    // $lab:coverage:on$
})(**undefined**, function () {

// code related to client is here
});

If I update the code by removing undefined and replacing it with window code works perfectly.
I am not sure if its generated wrongly or I am missing something.
Please let me know If I done something wrong.

@hueniverse

This comment has been minimized.

Copy link
Member

@hueniverse hueniverse commented Mar 28, 2016

@tkh44 @kpdecker can you help?

@hueniverse hueniverse added the question label Mar 28, 2016
kpdecker added a commit that referenced this issue Mar 30, 2016
Babel replaces this with undefined under strict mode, breaking the global declaration for the UMD module. Unclear on if this changed recently (I doubt) or if we never tested this under globals mode before.

Fixes #105
@kpdecker

This comment has been minimized.

Copy link
Contributor

@kpdecker kpdecker commented Mar 30, 2016

@neilmalgaonkar this was a build problem. #108 should fix this.

kpdecker added a commit that referenced this issue Mar 30, 2016
Babel replaces this with undefined under strict mode, breaking the global declaration for the UMD module. Unclear on if this changed recently (I doubt) or if we never tested this under globals mode before.

Fixes #105
@hueniverse hueniverse added bug and removed question labels Mar 30, 2016
@hueniverse hueniverse added this to the 4.2.1 milestone Mar 30, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.