Skip to content

Commit 318c2ee

Browse files
committed
Leverage the module_dependencies arg to add espree to importmap
1 parent b39030a commit 318c2ee

3 files changed

Lines changed: 1 addition & 13 deletions

File tree

src/wp-includes/general-template.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4045,7 +4045,6 @@ function wp_enqueue_code_editor( $args ) {
40454045

40464046
wp_enqueue_script( 'code-editor' );
40474047
wp_enqueue_style( 'code-editor' );
4048-
wp_enqueue_script_module( 'wp-codemirror' ); // Hack to get importmap printed with espree.
40494048

40504049
if ( isset( $settings['codemirror']['mode'] ) ) {
40514050
$mode = $settings['codemirror']['mode'];

src/wp-includes/script-loader.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,6 +1196,7 @@ function wp_default_scripts( $scripts ) {
11961196
);
11971197

11981198
$scripts->add( 'wp-codemirror', '/wp-includes/js/codemirror/codemirror.min.js', array(), '5.65.20' );
1199+
did_action( 'init' ) && $scripts->add_data( 'wp-codemirror', 'module_dependencies', array( 'espree' ) );
11991200
$scripts->add( 'csslint', '/wp-includes/js/codemirror/csslint.js', array(), '1.0.5' );
12001201
$scripts->add( 'esprima', '/wp-includes/js/codemirror/esprima.js', array(), '4.0.1' ); // Deprecated. Use 'espree' script module.
12011202
$scripts->add( 'jshint', '/wp-includes/js/codemirror/fakejshint.js', array( 'esprima' ), '2.9.5' ); // Deprecated.

src/wp-includes/script-modules.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -201,18 +201,6 @@ function wp_default_script_modules() {
201201
array(),
202202
'9.6.1'
203203
);
204-
205-
// The following is a workaround for classic scripts not yet being able to depend on modules. See <https://core.trac.wordpress.org/ticket/61500>.
206-
wp_register_script_module(
207-
'wp-codemirror',
208-
'', // An empty string is a hack to cause the dependencies to be printed in the importmap without a dependent script being printed.
209-
array(
210-
array(
211-
'id' => 'espree',
212-
'import' => 'dynamic',
213-
),
214-
)
215-
);
216204
}
217205

218206
/**

0 commit comments

Comments
 (0)