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

Minifier-friendly references to properties #183

Merged
merged 5 commits into from
Apr 27, 2022

Conversation

sd-yip
Copy link
Contributor

@sd-yip sd-yip commented Jan 29, 2022

Description of the change
Dynamically matching property names in a switch is hard to detect and optimize. Currently, it breaks minifier outputs under aggressive minification settings. This PR modifies the corresponding part for easier usage with a minifier.


Checklist:

  • Added the change to the changelog's "Unreleased" section with a link to this PR and your username
  • Linked any existing issues or proposals that this pull request should close
  • Updated or added relevant documentation in the README and/or documentation directory
  • Added a test for the contribution (if applicable)

@jamesdbrock
Copy link
Member

Thanks for the PR @sd-yip ! Please come and talk about it on the PureScript Discord contrib channel. https://discord.com/channels/864614189094928394/938253816862736405

src/React.js Outdated
throw new Error("[purescript-react] Not a component property: " + prop);
function curry2(f) {
return f === undefined ? f : function (a, b) {
return f(a)(b)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think these are correct. They are missing the () for invoking the effects (ie, it's not just a curry).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Previously, I applied the amount of arguments + 1 as the currying number for UNSAFE_componentWillReceiveProps and UNSAFE_componentWillUpdate, but not sure why I have missed them for the remaining.

Now the invocation and currying should be fixed. Please take another look.

@JordanMartinez
Copy link
Member

🏓 @thomashoneyman

@thomashoneyman thomashoneyman merged commit 6b91856 into purescript-contrib:main Apr 27, 2022
@thomashoneyman
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants