Skip to content

Commit

Permalink
Scripts: Add viewScriptModule block.json support (#58203)
Browse files Browse the repository at this point in the history
Support `viewScriptModule` for building view script modules.

`viewModule` is still supported but has been deprecated.

The Module API was changed to use naming like "script module" instead of "module" so we'll follow that pattern with `viewScriptModule`.

Co-authored-by: sirreal <[email protected]>
Co-authored-by: luisherranz <[email protected]>
  • Loading branch information
3 people authored Feb 7, 2024
1 parent 1bdb445 commit 23b4c79
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
8 changes: 8 additions & 0 deletions packages/scripts/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

## Unreleased

### New Features

- Add experimental support for `viewScriptModule` field in block.json for `build` and `start` scripts ([#57437](https://github.com/WordPress/gutenberg/pull/57437)).

### Deprecations

- Experimental support for `viewModule` field in block.json is deprecated in favor of `viewScriptModule` ([#57437](https://github.com/WordPress/gutenberg/pull/57437)).

## 27.1.0 (2024-01-24)

## 27.0.0 (2024-01-10)
Expand Down
8 changes: 4 additions & 4 deletions packages/scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ This script automatically use the optimized config but sometimes you may want to
- `--webpack-src-dir` – Allows customization of the source code directory. Default is `src`.
- `--output-path` – Allows customization of the output directory. Default is `build`.

Experimental support for the block.json `viewModule` field is available via the
Experimental support for the block.json `viewScriptModule` field is available via the
`--experimental-modules` option. With this option enabled, script and module fields will all be
compiled. The `viewModule` field is analogous to the `viewScript` field, but will compile a module
compiled. The `viewScriptModule` field is analogous to the `viewScript` field, but will compile a module
and should be registered in WordPress using the Modules API.

#### Advanced information
Expand Down Expand Up @@ -396,9 +396,9 @@ This script automatically use the optimized config but sometimes you may want to
- `--webpack-src-dir` – Allows customization of the source code directory. Default is `src`.
- `--output-path` – Allows customization of the output directory. Default is `build`.

Experimental support for the block.json `viewModule` field is available via the
Experimental support for the block.json `viewScriptModule` field is available via the
`--experimental-modules` option. With this option enabled, script and module fields will all be
compiled. The `viewModule` field is analogous to the `viewScript` field, but will compile a module
compiled. The `viewScriptModule` field is analogous to the `viewScript` field, but will compile a module
and should be registered in WordPress using the Modules API.

#### Advanced information
Expand Down
2 changes: 1 addition & 1 deletion packages/scripts/utils/block-json.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const moduleFields = new Set( [ 'viewModule' ] );
const moduleFields = new Set( [ 'viewScriptModule', 'viewModule' ] );
const scriptFields = new Set( [ 'viewScript', 'script', 'editorScript' ] );

/**
Expand Down

0 comments on commit 23b4c79

Please sign in to comment.