Using app_include_js with import statement

I have a custom app with Frappe only (No ERPNext). In my hooks.py I have added app_include_js = "/assets/custom_app/js/custom_app.bundle.js". And I have placed custom_app.bundle.js in custom_app/custom_app/public/js/custom_app.bundle.js. In that same folder I have config.js. In custom_app.bundle.js is this

import "./config"

However, I am receiving the following error:

Uncaught SyntaxError: Cannot use import statement outside a module (at custom_app.bundle.js:1:1)

Why can I not import here? I see Frappe and ERPNext use the same pattern, but it does not work with my custom app for some reason.

Please check
https://docs.frappe.io/framework/user/en/basics/asset-bundling

Also read this,

And,

1 Like