Giter VIP home page Giter VIP logo

Comments (2)

justin-schroeder avatar justin-schroeder commented on August 22, 2024 4

I could be wrong about this — but there seems to be a common thread when people encounter this issue. Typically the build tool is a bit older (like webpack 4) and doesn't like .mjs files. AutoAnimate as of right now is ESM only, we don't plan to ship any CJS (we're ok with some rough edges if it helps move the ecosystem along a bit — better for the environment you could say 😂).

That said — if there is some way we could write the export map to allow these older bundlers to actually work without shipping CJS I'm in!

from auto-animate.

zaynbuksh avatar zaynbuksh commented on August 22, 2024

Hi team,

I'm getting the same error, details below.

Error

Without react hook

Module not found: Error: Package path . is not exported from package <path>/node_modules/@formkit/auto-animate (see exports field in <path>/node_modules/@formkit/auto-animate/package.json)

With react hook

Module not found: Error: Package path ./react is not exported from package <path>/node_modules/@formkit/auto-animate (see exports field in <path>/node_modules/@formkit/auto-animate/package.json)

My setup

  • React version 17
  • Compiled by Webpack (via the tooling provided by Bit)
  • Version is beta.3

Import attempts

  • import { useAutoAnimate } from "@formkit/auto-animate/react"; // hook
  • import autoAnimate from "@formkit/auto-animate"; // without hook

Calling code attempts

  • const [examplesContainer ] = useAutoAnimate(); // hook
  • const examplesContainer = useRef(null); and autoAnimate(examplesContainer.current); // without hook

Error screenshot

formkit-auto-animate-error

The module and default keys in exports might have something to do with?

When I compare your exports vs the exports for something that doesn't generate the error (e.g. emotion), the structure is somewhat different.

Auto-animate's exports in package.json

  "exports": {
    "./vue": {
      "import": "./vue/index.mjs",
      "types": "./vue/index.d.ts"
    },
    "./react": {
      "import": "./react/index.mjs",
      "types": "./react/index.d.ts"
    },
    "./angular": {
      "import": "./angular/index.mjs",
      "types": "./angular/index.d.ts"
    },
    ".": {
      "import": "./index.mjs"
    }
  },

Emotion's exports in package.json

"exports": {
    ".": {
      "module": {
        "worker": "./dist/emotion-react.worker.esm.js",
        "browser": "./dist/emotion-react.browser.esm.js",
        "default": "./dist/emotion-react.esm.js"
      },
      "default": "./dist/emotion-react.cjs.js"
    },
    "./jsx-runtime": {
      "module": {
        "worker": "./jsx-runtime/dist/emotion-react-jsx-runtime.worker.esm.js",
        "browser": "./jsx-runtime/dist/emotion-react-jsx-runtime.browser.esm.js",
        "default": "./jsx-runtime/dist/emotion-react-jsx-runtime.esm.js"
      },
      "default": "./jsx-runtime/dist/emotion-react-jsx-runtime.cjs.js"
    },
    "./_isolated-hnrs": {
      "module": {
        "worker": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.worker.esm.js",
        "browser": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.browser.esm.js",
        "default": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.esm.js"
      },
      "default": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.cjs.js"
    },
    "./jsx-dev-runtime": {
      "module": {
        "worker": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.worker.esm.js",
        "browser": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.browser.esm.js",
        "default": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.esm.js"
      },
      "default": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.cjs.js"
    },
    "./package.json": "./package.json",
    "./types/css-prop": "./types/css-prop.d.ts",
    "./macro": "./macro.js"
  },

from auto-animate.

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.