Code Monkey home page Code Monkey logo

Comments (12)

diachedelic avatar diachedelic commented on May 27, 2024 9

The issue can be found in ./templates/umd-vissense-no-conflict.hbs, where the module.exports value is a factory function requiring window, not the VisSense constructor.

My solution:

import VisSenseFactory from 'vissense'

// requires window when initialised from CommonJS with WebPack,
// see https://github.com/vissense/vissense/issues/35
const VisSense = VisSenseFactory(window)

VisSense(el).monitor({ ... }).start()

from vissense.

zhouzi avatar zhouzi commented on May 27, 2024 3

I just faced the same issue so thanks @erikyuzwa. To solve it, I had to:

  1. npm install script-loader --save-dev - makes VisSense run in the global context
  2. npm install exports-loader --save-dev - to properly export VisSense as a module and make it work with ES2015 modules
  3. Add { test: /vissense/, loader: 'exports?VisSense!script'} to the list of module.loaders

The issue could be caused by an access to the global document object instead of window.document but I didn't find such code anywhere. Any idea of what's happening @erikyuzwa?

from vissense.

theborakompanioni avatar theborakompanioni commented on May 27, 2024 1

@zhouzi & @erikyuzwa Please report any findings or provide details to reproduce the problem. I am glad if I can help. I am currently in the process of rewriting VisSense in ES6 (as backward compatible as possible) - maybe that solves your issues.

from vissense.

erikyuzwa avatar erikyuzwa commented on May 27, 2024

Sorry. Turns out document was undefined which eventually led me back to webpack.
For future reference, you need to expose it via a script loader
{ test: /vissense/, loader: 'exports?VisSense!script'},

from vissense.

theborakompanioni avatar theborakompanioni commented on May 27, 2024

@erikyuzwa Nonetheless - thank you for reporting.

from vissense.

erikyuzwa avatar erikyuzwa commented on May 27, 2024

I think it's here @zhouzi
https://github.com/vissense/vissense/blob/master/dist/vissense.js#L209

For me it was looking like document was undefined somehow. Got pulled into other tasks, so I haven't yet had more time to go back on this.

from vissense.

zhouzi avatar zhouzi commented on May 27, 2024

Actually in this case, document is passed as an argument at #L824 which points to window.document #L860. I'll eventually spend some more time troubleshooting this but I don't really see what's happening at the moment.

from vissense.

bmwertman avatar bmwertman commented on May 27, 2024

I'm trying to use this with my Vue.js application. Without the fix mentioned by either @zhouzi or @erikyuzwa I get a similar error;

Uncaught TypeError: Cannot read property 'webkitHidden' of undefined
    at eval (eval at <anonymous> (app.js:1125), <anonymous>:210:32)
    at forEach (eval at <anonymous> (app.js:1125), <anonymous>:68:35)
    at eval (eval at <anonymous> (app.js:1125), <anonymous>:209:194)
    at createVisibilityApi (eval at <anonymous> (app.js:1125), <anonymous>:229:10)
    at eval (eval at <anonymous> (app.js:1125), <anonymous>:453:24)
    at withWindow (eval at <anonymous> (app.js:1125), <anonymous>:5:23)
    at VueComponent.visibility (eval at <anonymous> (app.js:1033), <anonymous>:63:70)
    at VueComponent.boundFn [as visibility] (eval at <anonymous> (app.js:723), <anonymous>:126:14)
    at VueComponent.mounted (eval at <anonymous> (app.js:1033), <anonymous>:26:10)
    at callHook (eval at <anonymous> (app.js:723), <anonymous>:2754:19)

With their fix I get an error that looks like I never installed vissense even though it's in node_modules

This dependency was not found in node_modules:

* vissense 

from vissense.

tommhuth avatar tommhuth commented on May 27, 2024

this should be fixed, any news on progress?

from vissense.

theborakompanioni avatar theborakompanioni commented on May 27, 2024

No progress yet. Problem is known and identified. But I do not know how to fix it properly. Can you provide a showcase?

from vissense.

theborakompanioni avatar theborakompanioni commented on May 27, 2024

@tommhuth Would it be possible for you to share some details on your build process/how you are including the library?

from vissense.

theborakompanioni avatar theborakompanioni commented on May 27, 2024

@diachedelic thanks for sharing. I am not aware of a proper solution to the problem yet.

from vissense.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.