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

Register runtime as dependency if found #48

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions inc/namespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,17 @@ function register_asset( string $manifest_path, string $target_asset, array $opt
$asset_handle = $options['handle'] ?? $target_asset;
$asset_version = Manifest\get_version( $asset_uri, $manifest_path );

Copy link
Collaborator

Choose a reason for hiding this comment

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

It's a small thing, but the double-spacing here is breaking linting.

// If running the development build with runtimeChunk: single, a runtime
// file will be present in the manifest. Register this and ensure it is
// loaded only once per page.
$runtime = Manifest\get_manifest_resource( $manifest_path, 'runtime.js' );
if ( $runtime && ! is_css( $asset_uri ) ) {
// Ensure unique handle based on src.
$runtime_handle = 'runtime-' . hash( 'crc32', $runtime );
wp_register_script( $runtime_handle, $runtime );
$options['dependencies'][] = $runtime_handle;
}

// Track registered handles so we can enqueue the correct assets later.
$handles = [];

Expand Down