-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
It seems that dynamic import is not working properly #8196
Comments
Hmm, interesting example.
Since framer-motion (at least a part of it for
I'm wondering what Vite (rollup) would actually do for this scenario. Could you create a demo project to explain the difference and expected behavior? |
This is a repository that builds the same using https://remix.run/docs/en/main/future/vite. |
I thought you're were talking about non-Remix project, but you were comparing with Remix's unstable vite, which is even better. Thanks for the quick repro! Now I see that Vite/Rollup seems smart about this code splitting and unfortunately this might be a known issue/limitation of esbuild-based code splitting evanw/esbuild#2227. For your use case, I'm not sure any workaround exists either. I was thinking to directly import files like below, but probably framer-motion doesn't allows this since it has strict // in components/LazyMotion.tsx
import { LazyMotion as FramerLazyMotion } from "framer-motion/dist/es/components/LazyMotion/index.mjs";
// in component/features.ts
import { domMax } from "framer-motion/dist/es/render/dom/features-max.mjs" |
@hi-ogawa |
Reproduction
I am using framer motion's LazyMotion to reduce the bundle size.
However, it seems that dynamic import is not applied properly when building remix.
System Info
Used Package Manager
pnpm
Expected Behavior
A dynamically imported JavaScript files should not be included in the html.
Actual Behavior
A dynamically impored js file is included in the html.
If built using vite, it works properly.
The text was updated successfully, but these errors were encountered: