I'm using wp_register_script
and wp_enqueue_script
to bring in some custom JavaScript logic for the admin screen of a WordPress plugin I'm developing.
The problem comes when I try to add import
statements at the top of my JavaScript in order to bring in a couple node modules. Understandably, this gives me the following browser console message:
import declarations may only appear at top level of a module
What is the standard way to tell WordPress to treat a custom bit of JavaScript as a module? And are there other steps I need to follow in order to make sure that my node modules can be imported?