Import Category class in a component

Developing a component with the code in the Header section using
<script type="text/discourse-plugin" version="0.8.26">
where I have lines like
parentCat = Discourse.Category.findById(get(category, "parent_category_id"));

I am getting this on the console

So what do I actually need to do? If I add an import statement
import Category from "discourse/models/category"; at the top of the script it barfs saying
SyntaxError: unknown: 'import' and 'export' may only appear at the top level (18:0)

Please help a novice…

You got to use a multi JS file component to get these features see:

5 Likes

Thanks @sam, I can just about understand what I need to do.

Bit of a shame, but understandable. I guess I can source the theme from my device rather than git.
Since the warning says it will be removed in 2.5 I guess there will be a way of handling this within the component code well before 2.5 (when is that BTW?)