Make WordPress Core

Opened 17 months ago

Closed 12 days ago

#61771 closed enhancement (maybelater)

Script Modules: add the importmap's scopes key

Reported by: rosua's profile rosua Owned by:
Milestone: Priority: normal
Severity: normal Version: 6.5
Component: Script Loader Keywords: close
Focuses: javascript Cc:

Description

WP_Script_Modules::print_import_map() prints the script modules, but it only prints the imports key.

As per described on the https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type/importmap#import_map_json_representation, <script type="importmap"> element can have another optional key: scopes and integrity.

There's no means for a plugin to add scopes to be printed.
So, besides the wp_register_script_module() function, we need a function to register the scopes.

The use case of using scopes are typical when we are using CDN providers such as https://generator.jspm.io/

Change History (4)

#1 @gziolo
17 months ago

  • Focuses javascript added
  • Version changed from trunk to 6.5

#2 @jonsurrell
15 months ago

The scopes property is not printed at this time because WordPress has no use for it. It may in the future.

WordPress implements its own module system and tracks dependencies inside of WordPress. This could open the door to things like versioned dependencies. There are also some ideas to use scopes for localization data. But at this time the module system inside WordPress simply has no use for scopes.

#3 @jonsurrell
3 months ago

  • Keywords close added

#4 @jonsurrell
12 days ago

  • Milestone Awaiting Review deleted
  • Resolution set to maybelater
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.