#2480 afColdFeet for ScriptModule

shturman Fri 2 Oct 2015

How i can use afColdFeet caching strategy for my script module:

@Contribute { serviceType=ScriptModules# }
static Void contributeScriptModules(Configuration config) {
    config.add(
        ScriptModule("my_module").atUrl(`/js/my_script.js`)
    )
}

SlimerDude Fri 2 Oct 2015

Good question! There's no means to automate this because RequireJS uses relative moduleIDs (should you use them) as paths to find other modules.

But assuming your module has no dependencies, you can do this:

@Contribute { serviceType=ScriptModules# }
static Void contributeScriptModules(Configuration config, FileHandler fh) {
    config.add(
        ScriptModule("my_module").atUrl(
            fh.fromLocalUrl(`/js/my_script.js`).clientUrl
        )
    )
}

Login or Signup to reply.