Make WordPress Core

Opened 2 years ago

Closed 8 months ago

#61771 closed enhancement (maybelater)

Script Modules: add the importmap's scopes key

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

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
2 years ago

  • Focuses javascript added
  • Version trunk6.5

#2 @jonsurrell
23 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
11 months ago

  • Keywords close added

#4 @jonsurrell
8 months ago

  • Milestone Awaiting Review
  • Resolutionmaybelater
  • Status newclosed
Note: See TracTickets for help on using tickets.