0

I hope you can help me with one, it's drivinig me crazy :(

I recently splitted a giant file called admin.js into many modules, using these two WordPress functions:

So, every module is mapped by an importmap, like this:

<script type=""importmap""id=""wp-importmap"">"{
   "imports":{
      "admin_colorpicker_js":"https:\/\/******\/wp-content\/plugins\/advanced-custom-post-type\/assets\/static\/js\/_admin_colorpicker.min.js?ver=6.8.3",
      "admin_commons_js":"\/wp-content\/plugins\/advanced-custom-post-type\/assets\/static\/js\/_admin_commons.min.js?ver=6.8.3",
      "admin_datepicker_js":"https:\/\/******\/wp-content\/plugins\/advanced-custom-post-type\/assets\/static\/js\/_admin_datepicker.min.js?ver=6.8.3",
      "admin_editor_js":"https:\/\/******\/wp-content\/plugins\/advanced-custom-post-type\/assets\/static\/js\/_admin_editor.min.js?ver=6.8.3",
      "admin_file_js":"https:\/\/******\/wp-content\/plugins\/advanced-custom-post-type\/assets\/static\/js\/_admin_file.min.js?ver=6.8.3",
      "admin_flexible_js":"https:\/\/******\/wp-content\/plugins\/advanced-custom-post-type\/assets\/static\/js\/_admin_flexible.min.js?ver=6.8.3",
      "admin_helpers_js":"https:\/\/******\/wp-content\/plugins\/advanced-custom-post-type\/assets\/static\/js\/_admin_helpers.min.js?ver=6.8.3",
      "admin_iconpicker_js":"https:\/\/******\/wp-content\/plugins\/advanced-custom-post-type\/assets\/static\/js\/_admin_iconpicker.min.js?ver=6.8.3",
      "admin_list_js":"https:\/\/******\/wp-content\/plugins\/advanced-custom-post-type\/assets\/static\/js\/_admin_list.min.js?ver=6.8.3",
      "admin_misc_js":"https:\/\/******\/wp-content\/plugins\/advanced-custom-post-type\/assets\/static\/js\/_admin_misc.min.js?ver=6.8.3",
      "admin_relational_js":"https:\/\/******\/wp-content\/plugins\/advanced-custom-post-type\/assets\/static\/js\/_admin_relational.min.js?ver=6.8.3",
      "admin_repeater_js":"https:\/\/******\/wp-content\/plugins\/advanced-custom-post-type\/assets\/static\/js\/_admin_repeater.min.js?ver=6.8.3",
      "admin_sortable_js":"https:\/\/******\/wp-content\/plugins\/advanced-custom-post-type\/assets\/static\/js\/_admin_sortable.min.js?ver=6.8.3",
      "admin_woocommerce_js":"https:\/\/******\/wp-content\/plugins\/advanced-custom-post-type\/assets\/static\/js\/_admin_woocommerce.min.js?ver=6.8.3"
   }
}"</script>

In rare cases, my clients got this error from the browser:

Uncaught TypeError: Failed to resolve module specifier "admin_commons_js". Relative references must start with either "/", "./", or "../".

There's no way to reproduce the issue on my localend/staging enviroment.

By the way, the admin.js is called AFTER the importmap.

Can anyone explain that and how to fix it?

Thanks in advance to everyone :)

M

I tried to reproduce the issue on my end, no luck.

4
  • admin_commons_js happens to be the only file in that importmap with a relative path. Maybe change it to https:\/\/******\/wp-content\/… and see if that fixes it? Commented Oct 8 at 16:25
  • Nope, I already tried :( Commented Oct 9 at 10:52
  • Couple more things to check: is the actual file there? Is it readable? You can easily check by visiting https://******/wp-content/plugins/advanced-custom-post-type/assets/static/js/_admin_commons.min.js?ver=6.8.3 with your web browser. Commented Oct 9 at 12:41
  • Yes, all the files are readable, I already tested it out Commented Oct 9 at 14:21

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.