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 in not defined #259

Closed
aladdin-add opened this issue Aug 20, 2021 · 6 comments
Closed

global in not defined #259

aladdin-add opened this issue Aug 20, 2021 · 6 comments

Comments

@aladdin-add
Copy link
Contributor

aladdin-add commented Aug 20, 2021

var SERVER_RENDERED = typeof navigator === 'undefined' || global['PREVENT_CODEMIRROR_RENDER'] === true;

this line will cause error in browsers(no webpack bundled). would it be possible to change to:

(typeof global !== 'undefined' && global['PREVENT_CODEMIRROR_RENDER'] === true)
@davidwinter
Copy link

I use this package with Electron, and I was able to workaround it with the following: #66 (comment)

@aladdin-add
Copy link
Contributor Author

aladdin-add commented Aug 23, 2021

haha, I used the same workaround 😄.

but better to fix it in the package: #260

@elsigh elsigh closed this as completed in a4487a4 Oct 5, 2021
elsigh added a commit that referenced this issue Oct 5, 2021
fix: global is not defined (fixes #259)
@mhsdesign
Copy link

mhsdesign commented Oct 19, 2022

in esbuild either use:

define: {
    'global': 'window'
}

or a patch see: #259 (comment)

@marcelgerber
Copy link

Hi @elsigh @scniro,
great that this was fixed!
Could you release a new version to npm? I'm still running into this issue with the latest published version.

marcelgerber added a commit to owid/owid-grapher that referenced this issue Jan 26, 2023
@mhsdesign
Copy link

@marcelgerber no they wont ^^

im now using a patch like:

fixes https://github.com/scniro/react-codemirror2/pull/260#issuecomment-1023202972
this bug has been fixed and merged to the source code of react-codemirror2,
but the maintainers said that they won't release it, because they are not using the project anymore.

diff --git a/index.js b/index.js
index d109de477e2b4afa44836ac8da63e75542743919..823a6b014ad15b895dcaf69f88b81f6c575320bd 100644
--- a/index.js
+++ b/index.js
@@ -63,7 +63,7 @@ exports.UnControlled = exports.Controlled = void 0;
 
 var React = require('react');
 
-var SERVER_RENDERED = typeof navigator === 'undefined' || global['PREVENT_CODEMIRROR_RENDER'] === true;
+var SERVER_RENDERED = false;
 var cm;
 
 if (!SERVER_RENDERED) {

@marcelgerber
Copy link

@mhsdesign yes, I'm using a similar patch now (through yarn 3).

it's nice that this is easily possible, but on the other hand it would be even nicer if I didn't have to do that, and could just run the code that's in this repo already, but just doesn't get pushed to npm.

Thank you nonetheless :)

marcelgerber added a commit to owid/owid-grapher that referenced this issue Feb 28, 2023
marcelgerber added a commit to owid/owid-grapher that referenced this issue Feb 28, 2023
marcelgerber added a commit to owid/owid-grapher that referenced this issue Mar 3, 2023
marcelgerber added a commit to owid/owid-grapher that referenced this issue Mar 4, 2023
marcelgerber added a commit to owid/owid-grapher that referenced this issue Mar 8, 2023
marcelgerber added a commit to owid/owid-grapher that referenced this issue Mar 8, 2023
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

4 participants