Package and upload JS Policy to the KK server

I am trying to upload Java Script based policy to the server.
So far I am doing it through starting the server with the following options:

-Dkeycloak.profile.feature.upload_scripts=enabled -Dkeycloak.profile.feature.scripts=enabled

and then uploading the script as JavaScript policy through the KK Admin Console.

According to the documentation this is deprecated and the recommended way is to package JS files as Jar archive.
There is a very good description of the structure of the jar file, however there is no explanation how the java script based policy file should look. Do I have to write the file in the same way as the policy uploaded through the admin console:

var context = $evaluation.getContext();
var contextAttributes = context.getAttributes();

if (contextAttributes.containsValue('kc.client.network.ip_address', '127.0.0.1')) {
    $evaluation.grant();
}

or I have to package it somehow?