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

global is undefined #42

Closed
stevehu opened this issue Nov 7, 2015 · 5 comments
Closed

global is undefined #42

stevehu opened this issue Nov 7, 2015 · 5 comments

Comments

@stevehu
Copy link

stevehu commented Nov 7, 2015

I am using brace from react-ace on Chrome browser with webpack and my app is broken due to global is undefined. You can reproduce it with my project https://github.com/networknt/react-schema-form

git clone git@github.com:networknt/react-schema-form.git
npm install
npm start

Then hit the url from your browser.
http://localhost:8080/webpack-dev-server/

The line of code failed.

    if (!global.document)
        return "";

Here is the line of the code I have changed as a work around. Just check if global is undefined before calling global.document.

    if (!global || !global.document)
        return "";

Does anyone know what is wrong? Is there any better workaround? Can this be fixed in the next release?

Thanks.

@thlorenz
Copy link
Owner

thlorenz commented Nov 9, 2015

That's a webpack issue, brace is only meant to be used with browserify and run client side.

@thlorenz thlorenz closed this as completed Nov 9, 2015
@stevehu
Copy link
Author

stevehu commented Nov 11, 2015

I am using webpack on the client side only. Also, this is not about fix the defect only, but a defensive coding style. You have to make sure the global is defined before calling global.document. This will make this wonderful package work with webpack which is much more popular then browserify. Thanks for your consideration.

@thlorenz
Copy link
Owner

@stevehu you do realize that this code is just pulled in from Ace right?
I'm not going to apply changes here. brace is just an automatically adapted version of Ace.
Please file the issue there.

@stevehu
Copy link
Author

stevehu commented Nov 13, 2015

@thlorenz Sorry. I didn't realize that it is in Ace codebase. I am opening an issue over there. Thanks for all the work you have done. I am using it but with my customized version installed from github:)

@thlorenz
Copy link
Owner

No worries, I had a feeling you weren't aware of that ;)

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

2 participants