Add DependencyExtractionWebpackPlugin for pages and read deps from .min.asset.php#1964
Add DependencyExtractionWebpackPlugin for pages and read deps from .min.asset.php#1964KMchaudhary wants to merge 1 commit into
Conversation
rtBot
left a comment
There was a problem hiding this comment.
Code analysis identified issues
action-phpcs-code-review has identified potential problems in this pull request during automated scanning. We recommend reviewing the issues noted and that they are resolved.
phpcs scanning turned up:
Powered by rtCamp's GitHub Actions Library
|
|
||
| if ( file_exists( $player_analytics_path ) ) { | ||
| $player_analytics_asset_file = RTGODAM_PATH . 'assets/build/js/godam-player-analytics.min.asset.php'; | ||
| $player_analytics_asset = file_exists( $player_analytics_asset_file ) ? include $player_analytics_asset_file : array( |
There was a problem hiding this comment.
$player_analytics_asset_file). Probably needs manual inspection (WordPressVIPMinimum.Files.IncludingFile.UsingVariable).
There was a problem hiding this comment.
Pull request overview
This PR refactors GoDAM’s asset registration/enqueue logic to consume dependency + version metadata from build-generated .asset.php files (including pages bundles), improving script dependency accuracy and cache busting as JS builds evolve.
Changes:
- Adds
@wordpress/dependency-extraction-webpack-pluginfor the custompageswebpack build to emit.min.asset.phpmetadata. - Updates many PHP enqueue/register call sites (frontend + admin + integrations) to read dependencies/version from corresponding
.min.asset.phpfiles with fallbacks. - Merges extracted dependencies with required runtime handles in select integrations to preserve load order.
Reviewed changes
Copilot reviewed 17 out of 18 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| webpack.config.js | Adds dependency extraction for pages build to generate .min.asset.php files. |
| package.json | Adds the dependency-extraction webpack plugin dependency. |
| package-lock.json | Lockfile updates reflecting the new webpack plugin version and dependency tree. |
| inc/classes/wpforms/class-wpforms-integration.php | Loads WPForms editor script deps/version from .min.asset.php. |
| inc/classes/shortcodes/class-godam-player.php | Loads analytics script deps/version from .min.asset.php and merges required runtime deps. |
| inc/classes/ninja-forms/class-ninja-forms-integration.php | Loads Ninja Forms submissions list script deps/version from .min.asset.php. |
| inc/classes/ninja-forms/class-ninja-forms-field-godam-recorder.php | Loads Ninja Forms recorder script deps/version from .min.asset.php and merges required deps. |
| inc/classes/lifter-lms/class-lifter-lms.php | Loads LifterLMS integration scripts deps/version from .min.asset.php. |
| inc/classes/gravity-forms/class-init.php | Loads Gravity Forms editor script deps/version from .min.asset.php. |
| inc/classes/fluentforms/fields/class-recorder-field.php | Loads FluentForms recorder script deps/version from .min.asset.php. |
| inc/classes/everest-forms/class-everest-forms-field-godam-video.php | Loads Everest Forms recorder script deps/version from .min.asset.php. |
| inc/classes/elementor-controls/class-godam-media.php | Loads Elementor editor script deps/version from .min.asset.php. |
| inc/classes/class-video-preview.php | Loads video preview script deps/version from .min.asset.php. |
| inc/classes/class-video-embed.php | Loads video embed script deps/version from .min.asset.php. |
| inc/classes/class-pages.php | Loads admin pages bundles deps/version from .min.asset.php. |
| inc/classes/class-elementor-widgets.php | Loads Elementor frontend script deps/version from .min.asset.php and merges required deps. |
| inc/classes/class-deactivation.php | Loads deactivation feedback script deps/version from .min.asset.php. |
| inc/classes/class-assets.php | Loads core frontend/admin (and http-auth detector) deps/version from .min.asset.php. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "@uppy/screen-capture": "5.0.0", | ||
| "@uppy/webcam": "5.0.0", | ||
| "@wordpress/dependency-extraction-webpack-plugin": "6.48.1", | ||
| "analytics": "^0.8.18", |
| wp_enqueue_script( | ||
| 'nf-godam-recorder-upload', | ||
| RTGODAM_URL . 'assets/build/js/ninja-forms.min.js', | ||
| array( 'backbone', 'jquery', 'wp-i18n' ), | ||
| filemtime( RTGODAM_PATH . 'assets/build/js/ninja-forms.min.js' ), | ||
| array_merge( $ninja_forms_asset['dependencies'], array( 'backbone' ) ), | ||
| $ninja_forms_asset['version'], |
| wp_register_script( | ||
| 'godam-http-auth-detector', | ||
| RTGODAM_URL . 'assets/build/js/http-auth-detector.min.js', | ||
| array( 'jquery' ), | ||
| filemtime( RTGODAM_PATH . 'assets/build/js/http-auth-detector.min.js' ), | ||
| $http_auth_asset['dependencies'], | ||
| $http_auth_asset['version'], |
| wp_enqueue_script( | ||
| 'gf-godam-recorder-editor-script', | ||
| RTGODAM_URL . 'assets/build/js/gf-godam-recorder-editor.min.js', | ||
| array( 'jquery' ), | ||
| filemtime( RTGODAM_PATH . 'assets/build/js/gf-godam-recorder-editor.min.js' ), | ||
| $gf_editor_asset['dependencies'], | ||
| $gf_editor_asset['version'], | ||
| true |
| $player_analytics_asset_file = RTGODAM_PATH . 'assets/build/js/godam-player-analytics.min.asset.php'; | ||
| $player_analytics_asset = file_exists( $player_analytics_asset_file ) ? include $player_analytics_asset_file : array( | ||
| 'dependencies' => array(), | ||
| 'version' => filemtime( $player_analytics_path ), | ||
| ); |
Code ReviewOverviewReplaces hardcoded script dependency/version arguments in Worth noting: the The version-from-content-hash change (vs Issues1. Because the PHP fallbacks for the page scripts are mostly Please run the production build and inspect the generated 2.
Dropping the explicit For the record, the other 3. Maintainability (non-blocking)
SummarySolid, well-scoped direction and the content-hash versioning is a genuine win. Before merging, please (1) build and verify the generated |
This pull request updates how JavaScript assets are registered and enqueued throughout the plugin to make use of dynamically generated
.asset.phpfiles. This ensures that each script's dependencies and version are accurately set based on the build process, improving reliability and maintainability when assets change.Asset management improvements:
.asset.phpfiles generated during the build process, falling back to defaults if the files are missing. This affects scripts inclass-assets.php,class-deactivation.php,class-elementor-widgets.php,class-pages.php,class-video-embed.php,class-video-preview.php,class-godam-media.php,class-everest-forms-field-godam-video.php,class-recorder-field.php, andclass-init.php. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20]Dependency handling enhancements:
'godam-player-frontend-script'or form plugin requirements), ensuring scripts are loaded in the correct order. [1] [2]Fallback and compatibility:
.asset.phpfile is missing, the code falls back to an empty dependencies array and uses the file modification time for versioning, maintaining backward compatibility and preventing asset loading failures. (applies throughout all affected files and changes above)These changes make asset loading more robust, especially as the codebase grows and asset dependencies change over time.