motiondivision / motion

A modern animation library for React and JavaScript
https://motion.dev
MIT License
25.66k stars 842 forks source link

Bundle complete types #2900

Open cmahnke opened 2 days ago

cmahnke commented 2 days ago

Is your feature request related to a problem? Please describe. I have a directory setup using symlinks and usually use tsconfig.json paths like this:

"paths": {
      "three": ["./node_modules/three", "./node_modules/@types/three"],
      "three/webgpu": ["./node_modules/@types/three/src/Three.WebGPU.d.ts"],

For motion this currently looks like this:

      "motion": ["./node_modules/motion/types/index.d.ts"],
      "@motionone/types": ["./node_modules/@motionone/types/types/index.d.ts"],
      "@motionone/dom": ["./node_modules/@motionone/dom/types/index.d.ts"],
      "@motionone/animation": ["./node_modules/@motionone/animation/types/index.d.ts"],
      "@motionone/generators": ["./node_modules/@motionone/generators/types/index.d.ts"]

And this isn't even working:


1 export declare const animate: (elements: import("..").ElementOrSelector, keyframes: import("./types").MotionKeyframesDefinition, options?: import("./types").AnimationOptionsWithOverrides) => import("@motionone/types").AnimationControls;
                                                  ~~~~

node_modules/@motionone/types/types/MotionValue.d.ts:1:65 - error TS2792: Cannot find module './'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option?

1 import type { AnimationGenerator, BasicAnimationControls } from "./";

Describe the solution you'd like Just bundle complete type and don't scatter them across multiple packages for a simple reason: The code is also bundled...

That is: Either don't do a import of modules of index.d.ts or preferably build a dist/index.d.ts and include it in the package distributed by NPM.

Describe alternatives you've considered Switching to a more friendly library