Skip to content

Commit f8cbab8

Browse files
committed
plugin: reduce bundle size impact of framer-motion
By only loading a subset of animations into the compiled bundle.
1 parent 91d62e6 commit f8cbab8

File tree

6 files changed

+85
-51
lines changed

6 files changed

+85
-51
lines changed

package-lock.json

Lines changed: 75 additions & 45 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugin/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"@internationalized/date": "3.10.0",
1717
"camelize-ts": "3.0.0",
1818
"classnames": "2.5.1",
19-
"framer-motion": "12.23.25",
19+
"motion": "12.23.26",
2020
"obsidian": "1.7.2",
2121
"react": "19.2.1",
2222
"react-aria-components": "1.13.0",
@@ -47,4 +47,4 @@
4747
"overrides": {
4848
"rollup": "4.44.2"
4949
}
50-
}
50+
}

plugin/src/ui/query/QueryRoot.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { domAnimation, LazyMotion } from "motion/react";
12
import type React from "react";
23
import { useCallback, useEffect, useState } from "react";
34

@@ -87,7 +88,7 @@ export const QueryRoot: React.FC<Props> = ({ query, warnings }) => {
8788
}, [query, settings, refresh]);
8889

8990
return (
90-
<>
91+
<LazyMotion features={domAnimation}>
9192
<QueryHeader
9293
title={getTitle(query, result)}
9394
isFetching={isFetching}
@@ -96,7 +97,7 @@ export const QueryRoot: React.FC<Props> = ({ query, warnings }) => {
9697
/>
9798
<QueryWarnings warnings={warnings} />
9899
{hasFetchedOnce && <QueryResponseHandler result={result} query={query} />}
99-
</>
100+
</LazyMotion>
100101
);
101102
};
102103

plugin/src/ui/query/task/Task.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { motion } from "framer-motion";
1+
import * as motion from "motion/react-m";
22
import { Notice } from "obsidian";
33
import React, { type MouseEvent } from "react";
44
import { Checkbox } from "react-aria-components";

plugin/src/ui/query/task/TaskList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { AnimatePresence } from "framer-motion";
1+
import { AnimatePresence } from "motion/react";
22
import type React from "react";
33

44
import type { TaskTree } from "@/data/transformations/relationships";

plugin/vite.config.mts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ export default defineConfig({
6767
}),
6868
bundleAnalyzerPlugin(),
6969
],
70+
resolve: {
71+
dedupe: ["react", "react-dom"],
72+
},
7073
build: {
7174
// We aren't building a website, so we build in library mode
7275
// and bundle the output using our index.ts as the entrypoint.

0 commit comments

Comments
 (0)