mikeric / rivets

Lightweight and powerful data binding.

Home Page:http://rivetsjs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Uncaught ReferenceError: sightglass is not defined (Electron)

snify opened this issue · comments

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?

You will need rivets.bundled or add also sightglass

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'

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

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.

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
//}

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

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.

@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>

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

https://github.com/blikblum/tinybind