Skip to content

Commit

Permalink
instant-search: Remove IE11 polyfill (#20998)
Browse files Browse the repository at this point in the history
We don't transpile for IE11 anymore since #19328, meaning IE11 won't
run our JS anymore in the first place. So there's no point in keeping
the polyfill around.
  • Loading branch information
anomiex committed Sep 14, 2021
1 parent 8b57b40 commit 7d64e37
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 55 deletions.
8 changes: 0 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: compat

Instant Search: As IE11 support was removed in Jetpack 10.1, remove an IE11 polyfill.
Original file line number Diff line number Diff line change
Expand Up @@ -115,25 +115,12 @@ public function load_assets() {
* @param string $plugin_base_path - Base path for use in plugins_url.
*/
public function load_assets_with_parameters( $path_prefix, $plugin_base_path ) {
$polyfill_relative_path = $path_prefix . '_inc/build/instant-search/jp-search-ie11-polyfill-loader.bundle.js';
$script_relative_path = $path_prefix . '_inc/build/instant-search/jp-search-main.bundle.js';
$script_relative_path = $path_prefix . '_inc/build/instant-search/jp-search-main.bundle.js';

if (
! file_exists( JETPACK__PLUGIN_DIR . $polyfill_relative_path ) ||
! file_exists( JETPACK__PLUGIN_DIR . $script_relative_path )
) {
if ( ! file_exists( JETPACK__PLUGIN_DIR . $script_relative_path ) ) {
return;
}

$polyfill_version = Jetpack_Search_Helpers::get_asset_version( $polyfill_relative_path );
$polyfill_path = plugins_url( $polyfill_relative_path, $plugin_base_path );
wp_enqueue_script( 'jetpack-instant-search-ie11', $polyfill_path, array(), $polyfill_version, true );
$polyfill_payload_path = plugins_url(
$path_prefix . '_inc/build/instant-search/jp-search-ie11-polyfill-payload.bundle.js',
$plugin_base_path
);
$this->inject_polyfill_js_options( $polyfill_payload_path );

$script_version = Jetpack_Search_Helpers::get_asset_version( $script_relative_path );
$script_path = plugins_url( $script_relative_path, $plugin_base_path );
wp_enqueue_script( 'jetpack-instant-search', $script_path, array(), $script_version, true );
Expand All @@ -151,15 +138,6 @@ protected function inject_javascript_options() {
wp_add_inline_script( 'jetpack-instant-search', 'var JetpackInstantSearchOptions=JSON.parse(decodeURIComponent("' . rawurlencode( wp_json_encode( $options ) ) . '"));', 'before' );
}

/**
* Passes options to the polyfill loader script.
*
* @param string $polyfill_payload_path - Absolute path to the IE11 polyfill payload.
*/
protected function inject_polyfill_js_options( $polyfill_payload_path ) {
wp_add_inline_script( 'jetpack-instant-search-ie11', 'var JetpackInstantSearchIe11PolyfillPath=decodeURIComponent("' . rawurlencode( $polyfill_payload_path ) . '");', 'before' );
}

/**
* Registers a widget sidebar for Instant Search.
*/
Expand Down

This file was deleted.

4 changes: 1 addition & 3 deletions projects/plugins/jetpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@
"@wordpress/interface": "4.1.0",
"@wordpress/url": "3.2.2",
"@wordpress/viewport": "4.0.2",
"abortcontroller-polyfill": "1.7.1",
"bounding-client-rect": "1.0.5",
"classnames": "2.3.1",
"click-outside": "2.0.2",
Expand Down Expand Up @@ -149,8 +148,7 @@
"url-polyfill": "1.1.12",
"uuid": "8.3.2",
"webpack": "5.51.1",
"webpack-cli": "4.8.0",
"whatwg-fetch": "3.6.2"
"webpack-cli": "4.8.0"
},
"devDependencies": {
"@automattic/color-studio": "2.5.0",
Expand Down
10 changes: 0 additions & 10 deletions projects/plugins/jetpack/tools/webpack.config.search.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,6 @@ const baseWebpackConfig = getBaseWebpackConfig(
{
entry: {
main: path.join( __dirname, '../modules/search/instant-search/loader.js' ),
'ie11-polyfill-loader': path.join(
__dirname,
'../modules/search/instant-search/ie11-polyfill.js'
),
'ie11-polyfill-payload': [
require.resolve( 'core-js' ),
require.resolve( 'regenerator-runtime/runtime' ),
require.resolve( 'whatwg-fetch' ),
require.resolve( 'abortcontroller-polyfill/dist/polyfill-patch-fetch' ),
],
},
'output-chunk-filename': 'jp-search.chunk-[name]-[hash].min.js',
'output-filename': 'jp-search-[name].bundle.js',
Expand Down

0 comments on commit 7d64e37

Please sign in to comment.