-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Create block: Add support for external templates installed from npm #23712
Conversation
Size Change: 0 B Total Size: 1.21 MB ℹ️ View Unchanged
|
There is one limitation in |
8b4da59
to
a3616d7
Compare
I came up with a solution that requires an explicit config with the path to the folder with template files to move forward with the initial support.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested and worked well for both examples.
The initial run seemed a little slow with no feedback to the user. This might be just my local setup or temporary issue, but if there is a long step for install, we should probably provide feedback to user that it is doing something. I quit and restarted the first time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also tested it with your package @gziolo. And it works great!!! Thank you for pushing this over the finish line :)
It's an actual issue with the Gutenberg repository and npm, I suppose. I experience it as well. I added more logging to account for that with 1e73571. However, in practice, it shouldn't be an issue because It's fast. I hope it will work like this when using the package from npm 😄 |
Thank you for reviewing. There were 2 CI jobs failing but the same issue exists in the |
This new feature might not get published to npm until WordPress 5.6 is released (8 December 2020). Let's see how it goes 😄 |
Description
Replaces #22175 and continues work started by @fabiankaegy. Description copied over:
External templates
To make it easier to use the existing
@wordpress/lazy-import
package, we better useindex.js
file (or anything thatmain
field allows overriding) as an entry point for the package that contains all definitions.Template Configuration
It is mandatory to provide the main file for the package that returns a configuration object. It must contain at least
templatesPath
field with the path pointing to the location where template files live (nested folders are also supported).Example:
It's a bit unfortunate that
templatesPath
has to be explicitly set but@wordpress/lazy-import
package would require some further development first to make the discovery automatic for external packages.It is also possible to override the default template configuration using the
defaultValues
field.Example:
How has this been tested?
This is being tested by running
npx wp-create-block
with different--template
(or-t
) parameters.To test things directly from NPM you can use two test templates: