From 97f7cb26fcf9963fc33fe096dc188808ef70bdbb Mon Sep 17 00:00:00 2001 From: Matt Perry Date: Mon, 3 Feb 2025 14:20:33 +0100 Subject: [PATCH] Latest --- packages/framer-motion/client/package.json | 2 +- packages/framer-motion/package.json | 4 ++-- packages/framer-motion/rollup.config.mjs | 18 +++++++++++------ .../src/motion/__tests__/types.test.tsx | 20 +++++++++++++++++++ 4 files changed, 35 insertions(+), 9 deletions(-) create mode 100644 packages/framer-motion/src/motion/__tests__/types.test.tsx diff --git a/packages/framer-motion/client/package.json b/packages/framer-motion/client/package.json index c4eeff4b2f..ed702d3c3f 100644 --- a/packages/framer-motion/client/package.json +++ b/packages/framer-motion/client/package.json @@ -1,6 +1,6 @@ { "private": true, - "types": "../dist/client.d.ts", + "types": "../dist/types/client.d.ts", "main": "../dist/cjs/client.js", "module": "../dist/es/client.mjs" } diff --git a/packages/framer-motion/package.json b/packages/framer-motion/package.json index 9641ac1304..924fce5370 100644 --- a/packages/framer-motion/package.json +++ b/packages/framer-motion/package.json @@ -6,7 +6,7 @@ "module": "dist/es/index.mjs", "exports": { ".": { - "types": "./dist/index.d.ts", + "types": "./dist/types/index.d.ts", "require": "./dist/cjs/index.js", "import": "./dist/es/index.mjs", "default": "./dist/cjs/index.js" @@ -24,7 +24,7 @@ "default": "./dist/cjs/dom.js" }, "./client": { - "types": "./dist/client.d.ts", + "types": "./dist/types/client.d.ts", "require": "./dist/cjs/client.js", "import": "./dist/es/client.mjs", "default": "./dist/cjs/client.js" diff --git a/packages/framer-motion/rollup.config.mjs b/packages/framer-motion/rollup.config.mjs index a85d2c09f4..f6e82d6185 100644 --- a/packages/framer-motion/rollup.config.mjs +++ b/packages/framer-motion/rollup.config.mjs @@ -114,7 +114,7 @@ const umdDomProd = createUmd("lib/dom.js", `dist/dom.js`) const umdDomMiniProd = createUmd("lib/dom-mini.js", `dist/dom-mini.js`) const cjs = Object.assign({}, config, { - input: "lib/index.js", + input: ["lib/index.js", "lib/client.js"], output: { entryFileNames: `[name].js`, dir: "dist/cjs", @@ -138,7 +138,6 @@ const cjs = Object.assign({}, config, { const cjsDom = Object.assign({}, cjs, { input : "lib/dom.js" }) const cjsMini = Object.assign({}, cjs, { input : "lib/mini.js" }) const cjsDomMini = Object.assign({}, cjs, { input : "lib/dom-mini.js" }) -const cjsClient = Object.assign({}, cjs, { input : "lib/client.js" }) const cjsM = Object.assign({}, cjs, { input : "lib/m.js" }) export const es = Object.assign({}, config, { @@ -162,6 +161,17 @@ export const es = Object.assign({}, config, { const typePlugins = [dts({compilerOptions: {...tsconfig, baseUrl:"types"}})] +const types = { + input: ["types/index.d.ts", "types/client.d.ts"], + output: { + format: "es", + entryFileNames: "[name].d.ts", + dir: "dist", + }, + plugins: typePlugins, +} + + function createTypes(input, file) { return { input, @@ -174,12 +184,10 @@ function createTypes(input, file) { } -const types = createTypes("types/index.d.ts", "dist/index.d.ts") const miniTypes = createTypes("types/mini.d.ts", "dist/mini.d.ts") const animateTypes = createTypes("types/dom.d.ts", "dist/dom.d.ts") const animateMiniTypes = createTypes("types/dom-mini.d.ts", "dist/dom-mini.d.ts") const mTypes = createTypes("types/m.d.ts", "dist/m.d.ts") -const clientTypes = createTypes("types/client.d.ts", "dist/client.d.ts") const threeTypes = createTypes("types/three-entry.d.ts", "dist/three.d.ts") // eslint-disable-next-line import/no-default-export @@ -193,13 +201,11 @@ export default [ cjsMini, cjsDom, cjsDomMini, - cjsClient, cjsM, es, types, mTypes, miniTypes, - clientTypes, animateTypes, animateMiniTypes, threeTypes, diff --git a/packages/framer-motion/src/motion/__tests__/types.test.tsx b/packages/framer-motion/src/motion/__tests__/types.test.tsx new file mode 100644 index 0000000000..adbe6e6a01 --- /dev/null +++ b/packages/framer-motion/src/motion/__tests__/types.test.tsx @@ -0,0 +1,20 @@ +import { motion, useMotionValue } from "framer-motion" +import * as clientMotion from "framer-motion/client" +import * as React from "react" +import { render } from "../../../jest.setup" + +describe("accepts motion values into both motion components from both entry points", () => { + it("renders", () => { + function Component() { + const x = useMotionValue(0) + return ( + <> + + + + ) + } + + render() + }) +})