Git Product home page Git Product logo

Comments (3)

mAAdhaTTah avatar mAAdhaTTah commented on August 24, 2024

Two questions:

  1. What error(s) are you getting?
  2. Why is kefir listed as a global?

from kefir.

antonioaguilar avatar antonioaguilar commented on August 24, 2024

@mAAdhaTTah I listed kefir as global because Rollup was complaining about unresolved dependencies and a missing global variable name, see output below:

> rollup -c
./src/main.js → dist/library.min.js...
(!) Unresolved dependencies
https://rollupjs.org/guide/en/#warning-treating-module-as-external-dependency
kefir (imported by src/main.js)
(!) Missing global variable name
Use output.globals to specify browser global variable names corresponding to external modules
kefir (guessing 'kefir')
created dist/library.min.js in 300ms

Adding or removing kefir from rollup.config.js globals didn't have any effect.

This is the code for my src/main.js file:

// main.js
import { later } from 'kefir';
export default {
  sayLater: (delay) => {
    const interval = delay || 1000;
    const stream = later(interval, 'hello world');
    stream.log();
  },
  VERSION: Date.now()
};

I'm trying to load the library as follows:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title></title>
</head>
<body>
  <script src="dist/library.min.js"></script>
  <script>
    window.onload = function () {
      console.log(window.Library);
    };
  </script>
</body>
</html>

when trying to run this the later method is undefined:

{VERSION: 1582815560788, sayLater: ƒ}sayLater: ƒ sayLater(delay)VERSION: 1582815560788__proto__: Object
Library.sayLater()
main.js:6 Uncaught TypeError: Cannot read property 'later' of undefined
    at Object.sayLater (main.js:6)
    at <anonymous>:1:9

Any ideas on what I could be doing wrong?

from kefir.

mAAdhaTTah avatar mAAdhaTTah commented on August 24, 2024

You've configured Rollup to expect Kefir to be available as a global variable, so you need to make it available as such in order for this to work.

That said, this is a Rollup issues, and I'm not really a Rollup expert. I might suggest taking this question to StackOverflow or the Rollup issue tracker if you still have problems with this.

from kefir.

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.