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: migrate block definitions to getConfig #42

Draft
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

Swanand01
Copy link
Contributor

@Swanand01 Swanand01 commented Feb 5, 2025

What

This PR moves the custom block definitions to the snapwp.config.mjs file.
Instead of passing them as props to the EditorBlockRenderer, they are now imported from getConfig

Why

Since block definitions are overloadable/configurable, they should be put in the snapwp.config.mjs file.

Related Issue(s):

https://github.com/orgs/rtCamp/projects/141/views/14?pane=issue&itemId=96524753&issue=rtCamp%7Cheadless%7C396

How

SnapWPConfig is updated to include blockDefinitions, and an example CoreQuote implementation is passed in snapwp.config.mjs

Testing Instructions

Screenshots

Additional Info

Checklist

  • I have read the Contribution Guidelines.
  • My code is tested to the best of my abilities.
  • My code passes all lints (ESLint, tsc, prettier etc.).
  • My code has detailed inline documentation.
  • I have added unit tests to verify the code works as intended.
  • I have updated the project documentation accordingly.

@Swanand01
Copy link
Contributor Author

@ayushnirwal @justlevine What kind of validation should we add here:

blockDefinitions: {
type: 'object',
required: false,
},

@Swanand01
Copy link
Contributor Author

@justlevine Do we want to enforce lazy loading for the custom block implementations, or do we leave it up to the user to use React.lazy / normal imports?

On a side note, I haven't been able to verify if using React.lazy while passing block definitions is working as intended. Have discussed the same with @ayushnirwal over a call.

@Swanand01
Copy link
Contributor Author

This is blocked because we cannot import .tsx block definition files into snapwp.config.mjs.
The PR will be unblocked when we move snapwp.config to .ts

cc: @BhumikP

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.

2 participants