Skip to content

Commit c96e3cd

Browse files
authored
Merge pull request #1781 from ampproject/remove/redundant-dependencies-1.0
Prevent re-bundling WordPress packages
2 parents 4ad849f + 8e2090e commit c96e3cd

15 files changed

+86
-73
lines changed

.dev-lib

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ ASSETS_DIR=wp-assets
44
PROJECT_SLUG=amp
55
SKIP_ECHO_PATHS_SCOPE=1
66
README_MD_TITLE="AMP Plugin for WordPress"
7+
DEV_LIB_SKIP="$DEV_LIB_SKIP,jshint"
78

89
function after_wp_install {
910
echo "Installing plugins..."

.jshintignore

Lines changed: 0 additions & 4 deletions
This file was deleted.

.jshintrc

Lines changed: 0 additions & 27 deletions
This file was deleted.

Gruntfile.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/* eslint-env node */
2-
/* jshint node:true */
32
/* eslint-disable camelcase, no-console, no-param-reassign */
43

54
module.exports = function( grunt ) {

assets/js/wp-dom-ready.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import domReady from '@wordpress/dom-ready';
2+
3+
if ( ! window.wp ) {
4+
window.wp = {};
5+
}
6+
7+
wp.domReady = domReady;

assets/js/wp-i18n.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import * as i18n from '@wordpress/i18n';
2+
3+
if ( ! window.wp ) {
4+
window.wp = {};
5+
}
6+
7+
wp.i18n = i18n;

assets/src/amp-validation-detail-toggle.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
/**
2-
* WordPress dependencies
3-
*/
4-
import domReady from '@wordpress/dom-ready';
5-
61
/**
72
* Localized data
83
*/
@@ -79,7 +74,7 @@ function addTermListTableRowClasses() {
7974
} );
8075
}
8176

82-
domReady( () => {
77+
wp.domReady( () => {
8378
addToggleButtons( 'th.column-details.manage-column', detailToggleBtnAriaLabel )
8479
.forEach( ( btn ) => {
8580
addToggleAllListener( {

assets/src/amp-validation-single-error-url-details.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
/**
2-
* WordPress dependencies
3-
*/
4-
import domReady from '@wordpress/dom-ready';
5-
61
/**
72
* Toggles the contents of a details element as an additional table tr.
83
*/
@@ -154,6 +149,6 @@ class ErrorRows {
154149
}
155150
}
156151

157-
domReady( () => {
152+
wp.domReady( () => {
158153
new ErrorRows().init();
159154
} );
Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
/**
2-
* WordPress dependencies
3-
*/
4-
import domReady from '@wordpress/dom-ready';
5-
61
// WIP Pointer function
72
function sourcesPointer() {
83
jQuery( document ).on( 'click', '.tooltip-button', function() {
@@ -17,6 +12,5 @@ function sourcesPointer() {
1712
} );
1813
}
1914

20-
domReady( () => {
21-
sourcesPointer();
22-
} );
15+
// Run at DOM ready.
16+
jQuery( sourcesPointer );

includes/amp-helper-functions.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,16 @@ function amp_add_generator_metadata() {
333333
* @param WP_Scripts $wp_scripts Scripts.
334334
*/
335335
function amp_register_default_scripts( $wp_scripts ) {
336+
/*
337+
* Polyfill dependencies that are registered in Gutenberg and WordPress 5.0.
338+
* Note that Gutenberg will override these at wp_enqueue_scripts if it is active.
339+
*/
340+
$handles = array( 'wp-i18n', 'wp-dom-ready' );
341+
foreach ( $handles as $handle ) {
342+
if ( ! isset( $wp_scripts->registered[ $handle ] ) ) {
343+
$wp_scripts->add( $handle, amp_get_asset_url( sprintf( 'js/%s-compiled.js', $handle ) ) );
344+
}
345+
}
336346

337347
// AMP Runtime.
338348
$handle = 'amp-runtime';

0 commit comments

Comments
 (0)