formkit / auto-animate

A zero-config, drop-in animation utility that adds smooth transitions to your web app. You can use it with React, Vue, or any other JavaScript application.
https://auto-animate.formkit.com
MIT License
11.96k stars 210 forks source link

Vue - [ERROR] Could not resolve "../index" #172

Closed hamzanouali closed 7 months ago

hamzanouali commented 8 months ago

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch @formkit/auto-animate@1.0.0-pre-alpha.3 for the project I'm working on.

Project: Nuxt 3.8 Node version: 18.17.1 npm version: 9.67

Here is the diff that solved my problem:

diff --git a/node_modules/@formkit/auto-animate/vue/index.mjs b/node_modules/@formkit/auto-animate/vue/index.mjs
index 299222c..755ba97 100644
--- a/node_modules/@formkit/auto-animate/vue/index.mjs
+++ b/node_modules/@formkit/auto-animate/vue/index.mjs
@@ -1,4 +1,4 @@
-import { vAutoAnimate } from '../index';
+import { vAutoAnimate } from '../index.mjs';

 const autoAnimatePlugin = {
     install(app) {

This issue body was partially generated by patch-package.

justin-schroeder commented 7 months ago

Why the old version of AutoAnimate?

Vanilagy commented 7 months ago

I can attest, I also ran into this issue. Downgaded from 1.0.0-pre-alpha.3 to 0.8.1, and it works as usual again. @justin-schroeder May I ask why you consider 1.0.0-pre-alpha.3 to be an older version than 0.8.1?

In 0.8.1, the Vue index file still correctly imports the parent index:

import { ref, onMounted, watchEffect } from 'vue';
import autoAnimate, { vAutoAnimate as vAutoAnimate$1 } from '../index.mjs';

Seems like Vite can't resolve it if it's just ../index? I'm not sure what's going on here.

EDIT: Our dependabot automatically """bumped""" auto-animate from beta to pre-alpha. Dunno what it was smoking: CleanShot 2023-11-29 at 12 15 41@2x

Vanilagy commented 7 months ago

I noticed Vite seems to be having issues with .mjs files - not only can it not automatically import .mjs files when you import without an extension, but imports from within that file also seem to behave differently. I'm struggling to figure out when exactly this broke, or if it's always been like this.

justin-schroeder commented 7 months ago

May I ask why you consider 1.0.0-pre-alpha.3 to be an older version than 0.8.1?

We stopped doing "preid" suffix releases a while back because they caused confusion for package managers. Instead we are using standard ol semver in the 0.x ranges. You can see the historical releases here:

https://www.npmjs.com/package/@formkit/auto-animate?activeTab=versions

Vanilagy commented 7 months ago

Which version do you recommend I use? beta.6, or 0.8.x?

justin-schroeder commented 7 months ago

0.8.x

Vanilagy commented 7 months ago

Alright, got it