Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vite typescript support #19

Merged
merged 3 commits into from
Jun 18, 2023
Merged

Vite typescript support #19

merged 3 commits into from
Jun 18, 2023

Conversation

garbit
Copy link
Owner

@garbit garbit commented Jun 18, 2023

  • Added typings for Vite
  • Updated docs for script setup

@garbit garbit merged commit 28ac2e0 into main Jun 18, 2023
@garbit garbit deleted the vite-typescript-support branch June 18, 2023 09:33
@Pezmc
Copy link

Pezmc commented Jun 21, 2023

Heads up that this caused a regression for us over at FlowForge as we were importing this library using:

import LottieAnimation from 'lottie-web-vue'

Fix was to change to:

import { LottieAnimation } from 'lottie-web-vue'

Our package.lock was set to use ^, so it happily pulled in the latest patch version.

@garbit
Copy link
Owner Author

garbit commented Jun 21, 2023

Thanks @Pezmc for raising this. I've tried to export both default and named export using the following:

// src/index.ts
import LottieAnimation from "./components/lottie-web-vue.vue";
export default LottieAnimation;
export { LottieAnimation }

However I've not been able to support both export types. Do you have any recommendations on how to approach this?

@Pezmc
Copy link

Pezmc commented Jun 22, 2023

@garbit I've experimented at this end and I believe I have been able to get it to work with both, but it does some with a compiler warning for the CJS version. See: Pezmc@6a9d48b, which also updates App.vue to render two instances of LotteAnimation to show it working in practice.

Screenshot 2023-06-22 at 09 12 04

Compiler warning for CJS version is the below, but I believe that's ok?

Entry module "src/index.ts" is using named and default exports together. Consumers of your bundle will have to use `LottieAnimation.default` to access the default export, which may not be what you want. Use `output.exports: "named"` to disable this warning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants