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

inline constant tag name in JSX transformation #115

Open
pionxzh opened this issue Feb 15, 2024 · 4 comments · Fixed by #129
Open

inline constant tag name in JSX transformation #115

pionxzh opened this issue Feb 15, 2024 · 4 comments · Fixed by #129
Labels
enhancement New feature or request scope: unminify

Comments

@pionxzh
Copy link
Owner

pionxzh commented Feb 15, 2024

Description

Constant tag name should be inlined into the JSX tag to reduce the noise.

source: #113 (comment)

Input code

const Name = "div";
const attrs = {id: "x"};
const Comp = React.createElement(Name, attrs);

Expected behavior

const attrs = {id: "x"};
const Comp = <div {...attrs} />;

Actual behavior

const Name = "div";
const attrs = { id: "x" };
const Comp = <Name {...attrs} />;
@0xdevalias
Copy link

0xdevalias commented Feb 16, 2024

Not sure if it's a good idea; but you could also use inlined spread syntax like this:

const Comp = <div {...{ id: "x" }} />;

Though I wonder; would there be any reason to not expand it completely into something like this:

const Comp = <div id="x" />;

@pionxzh
Copy link
Owner Author

pionxzh commented Feb 16, 2024

would there be any reason to not expand it completely into something like this:

const Comp = <div id="x" />;

If we want to implement props inlining, then the redundant {...{ ... } } will be removed.

@0xdevalias
Copy link

@pionxzh I believe this should be reopened as per:

#115 still needs the props inlining to be considered "completed". But let's merge this first.

Originally posted by @pionxzh in #129 (comment)

@pionxzh pionxzh reopened this May 10, 2024
@pionxzh
Copy link
Owner Author

pionxzh commented May 10, 2024

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request scope: unminify
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants