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

expose isProps #188

Open
DanielMazurkiewicz opened this issue Dec 13, 2023 · 2 comments
Open

expose isProps #188

DanielMazurkiewicz opened this issue Dec 13, 2023 · 2 comments

Comments

@DanielMazurkiewicz
Copy link

There is this fragment in tagsNS:

let [props, ...children] = protoOf(args[0] ?? 0) === objProto ? args : [{}, ...args]

and for the sake of possibility of creating semi "custom tags" I would want to get exposed isProps to be able to detect if props are provided as first argument to my function:

let isProps = (o) => protoOf(o ?? 0) === objProto

and then line in tagsNS would look like that:

let [props, ...children] = isProps(args[0]) ? args : [{}, ...args]

If no one using isProps minifier should inline it back, so no size impact.

@Tao-VanJS
Copy link
Member

Thanks for the suggestion!

My current feeling is that since isProps function is quite easy to add on the client side (a just a couple lines of change) it probably doesn't have too much value to add another top-level function to VanJS.

btw: All top-level functions of VanJS are nested into a single van object when being exported. Thus that's not something minifier can trim off (this might be a design mistake of VanJS, but it's too late to fix).

@DanielMazurkiewicz
Copy link
Author

btw: All top-level functions of VanJS are nested into a single van object when being exported. Thus that's not something minifier can trim off (this might be a design mistake of VanJS, but it's too late to fix).

Paste this code:

const test0 = () => console.log("test0");

const namespace = {
    test1: () => test0(),
    test2: () => console.log("test2")
}

namespace.test1();

here:

https://try.terser.org/

To me looks like nothing that need to be fixed or changed with VanJS, whatever not used gets wiped out, whatever used once, gets inlined.

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

No branches or pull requests

2 participants