[wp-trac] [WordPress Trac] #64907: Script Modules: Import map can print after classic footer scripts in wp-admin, breaking bare specifier resolution
WordPress Trac
noreply at wordpress.org
Thu Mar 19 18:45:46 UTC 2026
#64907: Script Modules: Import map can print after classic footer scripts in wp-
admin, breaking bare specifier resolution
---------------------------+-----------------------------
Reporter: mlaetitia | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Script Loader | Version:
Severity: normal | Keywords:
Focuses: javascript |
---------------------------+-----------------------------
While testing the new Settings->Connectors and Appearance->Fonts screens
we noticed that in some sites nothing was getting loaded and this error
came up in the console:
{{{
TypeError: Failed to resolve module specifier '@wordpress/boot'
}}}
Both `_wp_footer_scripts` and `WP_Script_Modules::print_import_map` hook
into `admin_print_footer_scripts` at priority 10. At the same priority,
callbacks run in registration order. If a plugin loads `admin-filters.php`
before `after_setup_theme` fires, `_wp_footer_scripts` registers first and
classic scripts (including inline `import()` calls) print before the
import map. The browser can't resolve bare specifiers without the import
map already in the DOM.
== Steps to reproduce ==
1. Install WordPress 7.0-beta5
2. Create a plugin with this code and activate it (or use Code Snippets):
{{{#!php
<?php
/**
* Plugin Name: Import Map Order Bug Reproducer
*/
// Loading admin-filters.php during plugin init (before after_setup_theme)
// causes _wp_footer_scripts to register on admin_print_footer_scripts
// before the Script Modules system registers print_import_map.
if ( is_admin() ) {
require_once ABSPATH . 'wp-admin/includes/admin-filters.php';
}
}}}
3. Go to Settings > Connectors or Appearance > Fonts
4. Open the browser console — the page is broken with a bare specifier
error
Example: The Events Calendar does causes this through its bundled Action
Scheduler/admin dependencies (the reason why we found this issue!). Other
plugins that load admin utilities early will have the same effect.
== Suggested fix ==
`print_import_map` should hook at a priority that guarantees it runs
before `_wp_footer_scripts`, regardless of registration order. For
example, hooking `print_import_map` at priority 9 in class-wp-script-
modules.php:358 would fix this:
{{{#!php
add_action( 'admin_print_footer_scripts', array( $this, 'print_import_map'
), 9 );
}}}
== Environment ==
* WordPress 7.0-beta5 (build 62069)
* Reproducible with The Events Calendar 6.15.17.1 or the minimal code
snippet above (can be reproduced in Playground)
* Tested locally on macOS/Valet
* Affects both the Connectors screen and the Font Library screen
--
Ticket URL: <https://core.trac.wordpress.org/ticket/64907>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list