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

Plugin: Remove vendor script registration #13573

Merged
merged 1 commit into from
Feb 26, 2019
Merged
Changes from all 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
92 changes: 4 additions & 88 deletions lib/client-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,21 +139,6 @@ function gutenberg_register_scripts_and_styles() {
global $wp_scripts;

gutenberg_register_vendor_scripts();

wp_add_inline_script(
'wp-polyfill',
wp_get_script_polyfill(
$wp_scripts,
array(
'\'fetch\' in window' => 'wp-polyfill-fetch',
'document.contains' => 'wp-polyfill-node-contains',
'window.FormData && window.FormData.prototype.keys' => 'wp-polyfill-formdata',
'Element.prototype.matches && Element.prototype.closest' => 'wp-polyfill-element-closest',
),
'after'
)
);

gutenberg_register_packages_scripts();

// Inline scripts.
Expand Down Expand Up @@ -246,33 +231,6 @@ function gutenberg_register_scripts_and_styles() {
),
'after'
);
wp_add_inline_script(
'moment',
sprintf(
"moment.locale( '%s', %s );",
get_user_locale(),
wp_json_encode(
array(
'months' => array_values( $wp_locale->month ),
'monthsShort' => array_values( $wp_locale->month_abbrev ),
'weekdays' => array_values( $wp_locale->weekday ),
'weekdaysShort' => array_values( $wp_locale->weekday_abbrev ),
'week' => array(
'dow' => (int) get_option( 'start_of_week', 0 ),
),
'longDateFormat' => array(
'LT' => get_option( 'time_format', __( 'g:i a', 'default' ) ),
'LTS' => null,
'L' => null,
'LL' => get_option( 'date_format', __( 'F j, Y', 'default' ) ),
'LLL' => __( 'F j, Y g:i a', 'default' ),
'LLLL' => null,
),
)
)
),
'after'
);
// Loading the old editor and its config to ensure the classic block works as expected.
wp_add_inline_script(
'editor',
Expand Down Expand Up @@ -534,52 +492,10 @@ function gutenberg_preload_api_request( $memo, $path ) {
* @since 0.1.0
*/
function gutenberg_register_vendor_scripts() {
$suffix = SCRIPT_DEBUG ? '' : '.min';

// Vendor Scripts.
$react_suffix = ( SCRIPT_DEBUG ? '.development' : '.production' ) . $suffix;

gutenberg_register_vendor_script(
'react',
'https://unpkg.com/react@16.6.3/umd/react' . $react_suffix . '.js',
array( 'wp-polyfill' )
);
gutenberg_register_vendor_script(
'react-dom',
'https://unpkg.com/react-dom@16.6.3/umd/react-dom' . $react_suffix . '.js',
array( 'react' )
);
$moment_script = SCRIPT_DEBUG ? 'moment.js' : 'min/moment.min.js';
gutenberg_register_vendor_script(
'moment',
'https://unpkg.com/moment@2.22.1/' . $moment_script,
array()
);
gutenberg_register_vendor_script(
'lodash',
'https://unpkg.com/lodash@4.17.11/lodash' . $suffix . '.js'
);
wp_add_inline_script( 'lodash', 'window.lodash = _.noConflict();' );
gutenberg_register_vendor_script(
'wp-polyfill-fetch',
'https://unpkg.com/whatwg-fetch@3.0.0/dist/fetch.umd.js'
);
gutenberg_register_vendor_script(
'wp-polyfill-formdata',
'https://unpkg.com/formdata-polyfill@3.0.9/formdata.min.js'
);
gutenberg_register_vendor_script(
'wp-polyfill-node-contains',
'https://unpkg.com/polyfill-library@3.26.0-0/polyfills/Node/prototype/contains/polyfill.js'
);
gutenberg_register_vendor_script(
'wp-polyfill-element-closest',
'https://unpkg.com/element-closest@2.0.2/element-closest.js'
);
gutenberg_register_vendor_script(
Copy link
Member

Choose a reason for hiding this comment

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

We need to remember to update @babel/polyfill in core to the latest version when WordPress 5.2.0 release process starts.

Copy link
Member Author

Choose a reason for hiding this comment

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

We need to remember to update @babel/polyfill in core to the latest version when WordPress 5.2.0 release process starts.

How best can we track this? Would a Trac ticket be appropriate?

Copy link
Member

Choose a reason for hiding this comment

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

'wp-polyfill',
'https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/7.0.0/polyfill' . $suffix . '.js'
);
/*
* This function is kept as an empty stub, in case Gutenberg should need to
* explicitly provide a version newer than that provided by core.
*/
}

/**
Expand Down