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

feat: add patchMotionTags for legacy browsers which don't support Proxy #1194

Closed
wants to merge 1 commit into from

Conversation

ambar
Copy link
Contributor

@ambar ambar commented Jun 24, 2021

Related: #364 #664 #674 #1178

Usage

import {patchMotionTags} from 'framer-motion'

patchMotionTags()

Test result:

Tool Bundle Diff
webpack +1070B (gzip 464B)
esbuild +1068B (gzip 469B)

A less convenient solution is to rewrite export, but it will significantly increase the bundle size:

export let motion = motionProxy
// motion will always be bundled
export const patchMotion = () => {
    motion = createMotionFallback()
}

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jun 24, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 5b5e994:

Sandbox Source
Framer Motion: Simple animation Configuration
App Store UI using React and Framer Motion Configuration
Framer Motion: Reorder animation Configuration
Framer Motion: growing item positionTransition issue Configuration
Framer Motion: Image lightbox Configuration

@ppsirius
Copy link

What is the status of this?

@mattgperry
Copy link
Collaborator

Sorry for the delay on this but closing this out as the point of using Proxy in the first place is to avoid having to maintain a list of valid tags that has to be then included in the bundle.

@mattgperry mattgperry closed this Nov 1, 2021
@ambar
Copy link
Contributor Author

ambar commented Nov 3, 2021

The DOM tags in this patch would not be bundled unless you call patchMotionTags().

Right now, all other workarounds are a little pain to use:

  • yarn patch requires line number of source code (unstable)
  • Aliasing requires different bundler config in different projects (and also, we may need to inject a fake Proxy polyfill and then revert it)
  • Re-exporting m/motion from another package (we end up with this)

@mattgperry
Copy link
Collaborator

They would be included though, because the bundler has no way of knowing whether patchMotionTags is going to be called by the client.

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

3 participants