You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Script Loader: Warn when classic scripts with module dependencies lack footer/defer.
A classic script with `module_dependencies` may be evaluated before the script modules import map is printed if it loads blocking in the document head, causing a "Failed to resolve module specifier" error on dynamic imports.
* Trigger `_doing_it_wrong()` from `_wp_scripts_add_args_data()` when a classic script provides `module_dependencies` without setting `in_footer` to `true` or using a `defer` loading `strategy`, and document this requirement in the `wp_register_script()` and `wp_enqueue_script()` docblocks.
* Remove the `module_dependencies` arg from the `wp-codemirror` script registration in favor of passing the espree module URL directly through `wp_get_code_editor_settings()`. This avoids registering `espree` as a publicly-available script module when it is only ever used internally as a private implementation detail of the code editor.
* Add a `console.warn()` in `wp.codeEditor.initialize()` when invoked before `DOMContentLoaded`, so developers are alerted if the function is called too early for the import map to have been parsed.
* Add PHPStan types which were missing when `module_dependencies` were initially introduced.
* Harden `WP_Scripts::add_data()` against non-string `strategy` values being passed to `sprintf()`.
Developed in WordPress#11788
Follow-up to r61587.
Props khokansardar, westonruter, jonsurrell, jorbin.
See #61500, #64238.
Fixes #65165.
git-svn-id: https://develop.svn.wordpress.org/trunk@62368 602fd350-edb4-49c9-b593-d223f7449a82
Copy file name to clipboardExpand all lines: src/js/_enqueues/lib/codemirror/javascript-lint.js
+6-1Lines changed: 6 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -30,6 +30,7 @@ import CodeMirror from 'codemirror';
30
30
* @property {boolean} [es3] - "This option tells JSHint that your code needs to adhere to ECMAScript 3 specification. Use this option if you need your program to be executable in older browsers—such as Internet Explorer 6/7/8/9—and other legacy JavaScript environments."
31
31
* @property {boolean} [module] - "This option informs JSHint that the input code describes an ECMAScript 6 module. All module code is interpreted as strict mode code."
32
32
* @property {'implied'} [strict] - "This option requires the code to run in ECMAScript 5's strict mode."
33
+
* @property {string} [espreeModuleUrl] - The URL to the espree script module.
33
34
*/
34
35
35
36
/**
@@ -42,9 +43,13 @@ import CodeMirror from 'codemirror';
__( 'When the %1$s arg is provided, the "%2$s" script must either be printed in the footer (%3$s set to true) or use a deferred loading %4$s (%5$s) so that the import map is printed before the script is evaluated.' ),
0 commit comments