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

delete with and move to use vastly #1001

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

delete with and move to use vastly #1001

wants to merge 1 commit into from

Conversation

adamjanicki2
Copy link
Collaborator

Work in progress, not ready for review yet

Addresses #967

Copy link

netlify bot commented Nov 27, 2023

Deploy Preview for getmavo ready!

Name Link
🔨 Latest commit a91116f
🔍 Latest deploy log https://app.netlify.com/sites/getmavo/deploys/6565299fc2da9800087b6dc5
😎 Deploy Preview https://deploy-preview-1001--getmavo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

"object", "property", // MemberExpression
"body"
],
walk: Vastly.walk,
Copy link
Member

@LeaVerou LeaVerou Nov 28, 2023

Choose a reason for hiding this comment

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

@DmitrySharabin what do you think? Should we continue to define these or just use vastly methods internally and print out a deprecation warning for these, directing plugin authors to use vastly too (using your Mavo.Functions.deprecatedFunction())?

Might be helpful to quickly look into whether these are used by any plugins

Copy link
Member

Choose a reason for hiding this comment

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

I checked all Mavo plugins. Not only ours but also every plugin in the plugin registry. I couldn't find any that uses these Mavo.Script methods: walk, closest, and serialize. However, even though we don't use it in the plugins from the registry, we can't guarantee no (private) plugin does. So, I would follow the route with a deprecation message (until the next release minimum). At least we can lower the chance of breaking some author code and level up the awareness of vASTly, which is nice from my perspective. 😊

}

return _.serializers[node.type](node, parent);
},
Copy link
Member

Choose a reason for hiding this comment

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

Oooh that must have been pleasant 😁

However, we still need the transformations (vastly has an export of an empty transformations object so the developer can modify them). Keep in mind vastly is written for parsing/serializing regular JS, so all the special Mavo stuff will still live here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah I realized this after I committed it, oops! One question I had was how do we set the transformations for vastly from mavo?

Copy link
Member

Choose a reason for hiding this comment

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

Try Object.assign(Vastly.transformations, transformations) but do check where rollup puts that export, it may be Vastly.serialize.transformations or something entirely different.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Followup question: where should this go such that it only runs once? Somewhere around here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Update: transformations and other non-default exports are not accessible outside Vastly. I assume it's because the index file only exports the defaults for each file: https://github.com/mavoweb/vastly/blob/main/src/index.js#L2C1-L9C55

Copy link
Member

Choose a reason for hiding this comment

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

Followup question: where should this go such that it only runs once? Somewhere around here?

I'm confused, Mavo's transformations wouldn't go in vastly.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah I agree, I was asking where in mavo should we put the line Object.assign(Vastly..., transformations). I suggested here since there's a very similar line right below to set something inside stretchy

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's something to fix on the vastly side :) Please file an issue first, so you have something to close.

Will do

One way is to add it as a property of serialize, another to add it as a separate named export. Which solution would you pick and why? :)

I'm leaning toward adding it as a prop of serialize, because adding additional lines like export {transformations} from "./serialize.js" doesn't seem too good to me. When you say add as a property of serialize, how would I go about doing this?

Copy link
Member

Choose a reason for hiding this comment

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

Ok, let me elaborate a bit, as I think my earlier message wasn't super clear.

Option 1 is that index-fn also does export { transformations, serializers }. Then they become top-level exports, same as the functions, and they'd be available as e.g. Vastly.transformations.

Option 2 is that we add them as properties of the serialize function, since functions are objects in JS:

serialize.transformations = transformations;

Then they are not exported per se, but can be accessed via serialize.

What do you think are the pros & cons of each of these approaches?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's cool! To me, it seems like the pros of option1 is we don't waste space inside of serialize "object", and the pros of option2 are we don't have to worry about exporting a separate thing from index, and transformations is tied to serialize since that's where it belongs

Overall I would say going for option 2 is better, but if you have a strong opinion either way, let me know

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