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

Uncaught ReferenceError: sightglass is not defined (Electron) #699

Open
snify opened this issue Dec 4, 2016 · 9 comments
Open

Uncaught ReferenceError: sightglass is not defined (Electron) #699

snify opened this issue Dec 4, 2016 · 9 comments

Comments

@snify
Copy link

snify commented Dec 4, 2016

I tried to use the latest 0.9.4 from CDN. I use the latest Electron build: electron-v1.4.10-win32-ia32. And every time I get:

Uncaught ReferenceError: sightglass is not defined

Why is this?

@blikblum
Copy link
Contributor

blikblum commented Dec 4, 2016

You will need rivets.bundled or add also sightglass

@snify
Copy link
Author

snify commented Dec 5, 2016

I used rivets.bundled.min.js. Tried with sightglass and then rivets and it still shows undefined. I'm not sure where the bug is... maybe it's related to ES2016 support? (Because with nw.js it works) Included in Electron it says 'undefined'

@blikblum
Copy link
Contributor

blikblum commented Dec 5, 2016

No idea, whats going on.

You can try this build: https://github.com/blikblum/rivets/tree/svelte/dist

It integrates sightglass into rivets so should not have this problem

Be aware that has some other changes that may fit or not your requirements. You can check them at https://github.com/blikblum/rivets/tree/svelte

@snify
Copy link
Author

snify commented Dec 7, 2016

Somehow it works with your build, but not with the official one. Thanks

P.S. To the author: It would be nice to see what's going on. I can't seem to find the problem.

@ghost
Copy link

ghost commented Feb 27, 2017

NOTE: I apologize for the lack of clarity. I came up with a solution to this exact issue 2 months ago and have since forgotten a lot of it.

I had this issue awhile back. I "fixed" it by monkey patching the imports not to do any of the various import/export stuff from commonJS or ES6, and then concatenated them into a vendor.js file that gets placed as a script file within the <script> tag in the index.html file within Electron. Rivets and sightglass are included separately, with jquery coming before sightglass which comes before rivets. (This is handled within a gulpfile that concatenates and minifies all these files together into a vendor.js file)

Thus, rivets and sightglass doesn't get confused this way about what export/import method to use and uses the old broken goodness defaults of how we handled imports in 2008. :) Definitely a hack. I don't recommend it, but for those struggling with this, you may want to approach something similar as a workaround.

This is what I commented out at the end of SightglassJS.

// Export module for Node and the browser.
/if (typeof module !== 'undefined' && module.exports) {
module.exports = sightglass
} else if (typeof define === 'function' && define.amd) {
define([], function() {
return this.sightglass = sightglass
})
} else {
/
this.sightglass = sightglass
//}

@brtthomp
Copy link

brtthomp commented Apr 17, 2017

Any more ideas on this problem? I'm having the same issue and can't get @blikblum build to work and @kitanata idea didn't seem to help either.

Edit: @blikblum build did work I just had a user error there. Either way it would be nice to have a fix in the master library

@blimpmason
Copy link

I'm getting the same error (Uncaught ReferenceError: sightglass is not defined) when using rivets bundled in a Browserify module. @blikblum's build link is no longer active.

@brtthomp
Copy link

@blimpmason
The fix I have been running with is either changing the code as @kitanata suggested. The other way I have been doing it is via the HTML code below. You could probably modify that to work if you are using require

<script>if (typeof module === 'object') {window.module = module; module = undefined;}</script>
<script src="js/vendor-min.js"></script>
<script>if (window.module) module = window.module;</script>

@blikblum
Copy link
Contributor

You can try tinybind, a fork of rivets with many bug fixes and other improvements

https://github.com/blikblum/tinybind

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