Skip to content

wp scaffold block creates block.js rather than index.js #138

@salcode

Description

@salcode

When scaffolding a block with a command like

wp scaffold block myblock --title="My Block" --plugin=myplugin

the JavaScript file created is called block.js.

@zgordon makes the argument that index.js is preferable. His reasoning centers around when using ESNext with an import statement and you name the file index.js, it allows you to include the file in the import statement without explicitly including the filename.

You can see an example of his using import without the filename in one of his sample plugins, where he writes:

/**
 * Import registerBlockType blocks
 */
import './register-block-type/';
import './demo/';

Using the current version with block.js, these lines would be

/**
 * Import registerBlockType blocks
 */
import './register-block-type/block.js';
import './demo/block.js';

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions