Giter Club home page Giter Club logo

Comments (8)

smth avatar smth commented on May 18, 2024 1

That resulted in the same error for me, but did prompt me to try the below, which seems to work. 👍

import fitty from 'fitty';

fitty.default('.my-element');

from fitty.

rikschennink avatar rikschennink commented on May 18, 2024

what if you do import fitty from 'fitty/dist/fitty.module.js'

from fitty.

smth avatar smth commented on May 18, 2024

Same result.

from fitty.

PaulMorel avatar PaulMorel commented on May 18, 2024

I made it work like this with Rollup

import fitty from 'fitty';

window.fitty = fitty.default;

// Do your thing
fitty('.my-element');

I don't 100% understand all the various ways to import and export modules, but from my understainding the default export seems to be an object and within the default key of that object, we have the fitty() function as the value.

from fitty.

rikschennink avatar rikschennink commented on May 18, 2024

Okay, nice, happy to make adjustments to the package.json to get this working, but not sure why this happens. Will leave the issue open for any suggestions.

from fitty.

PaulMorel avatar PaulMorel commented on May 18, 2024

@rikschennink From a quick observation, it seems like it might be due to an older version of Babel? I tried transpiling the source using Babel v7.11.0 and the resulting file is different. In this case fitty gets assigned to a global _default var instead of being assigned to exports.default. If we give the exported function a name, it should be available as a global variable other than _default.

I haven't had the time to test this thoroughly, but I think it's a good lead.

from fitty.

rikschennink avatar rikschennink commented on May 18, 2024

@PaulMorel thanks, will look into it when I have some free time

from fitty.

rikschennink avatar rikschennink commented on May 18, 2024

Just tested with codesandbox but seems to work fine:
https://codesandbox.io/s/fitty-demo-bzkfb?file=/src/index.js

from fitty.

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.