require optimizer error when using underscore-tpl
The library has been working great but we started using the RequireJS Optimizer. The text! template references are working fine but all of the tpl! references fail with the following error. Any suggestions?
Error: Loader plugin did not call the load callback in the build: tpl: tpl!templates/abc.tpl tpl!templates/xyz.tpl
hi! could you give some more info? what version of requirejs / r.js are you using? did you tried narrowing down the issue to the template that is causing the issue? any other information you can provide?
there are some related issues in the requirejs repo here, you may find the answer there
https://github.com/jrburke/requirejs/issues/865 https://github.com/jrburke/requirejs/issues/981
what this plugin does is calling the text plugin, it is very likely the issue may be there.
if there is anything else I'll come back.
Check that you are loading the text plugin somewhere in your configuration when building.
http://stackoverflow.com/questions/14839559/requirejs-optimization-error-loader-plugin-did-not-call-the-load-callback-in-th
looking forward for more details from your side about the issue
I am using require.js 2.1.20, backbone 1.2.2, grunt 0.4.5, grunt-contrib-requirejs 0.4.4 (r.js 2.1.22) and underscore-tpl 0.1.0. The project works fine for text! (runtime and compile) and runtime for tpl! but the compile fails for tpl!.
Here is my grunt task:
requirejs: {
compile: {
options: {
baseUrl: "js",
dir: "dist",
optimize: "none",
findNestedDependencies: true,
paths: {
"jquery": "empty:",
"underscore": "empty:",
"backbone": "empty:",
"bootstrap": "empty:",
"bootbox": "empty:",
"q": "empty:",
"text": "lib/text",
"tpl": "lib/underscore-tpl"
},
modules: [
{
name: "main",
exclude:[
'jquery',
'underscore',
'backbone',
'bootstrap',
'bootbox',
'q',
'text',
'tpl'
]
}
]
}
}
Here is my main.js:
require.config({
baseUrl: 'js',
waitSeconds : 60,
shim : {
"bootstrap" : { "deps" :['jquery'] },
"q" : {}
},
paths: {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.min",
"underscore": "https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min",
"backbone": "https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.2.3/backbone-min",
"bootstrap": "https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/js/bootstrap.min",
"bootbox": "https://cdnjs.cloudflare.com/ajax/libs/bootbox.js/4.4.0/bootbox.min",
"q": "https://cdnjs.cloudflare.com/ajax/libs/q.js/1.4.1/q.min",
"tpl": "lib/underscore-tpl"
}
});
require(['app'], function(App) {
App.initialize();
});
Here is the module that is using tpl. When I use text! it compiles OK. It only fails if I use the tpl!
define(['jquery', 'underscore', 'backbone', . . . 'tpl!templates/playerList.html', 'text!templates/playerListEmpty.html'], function($, _, Backbone, . . . playerListHtml, playerListEmptyHtml) {
var PlayersView = AbstractDetailContentsView.extend({
. . .
noPlayersTemplate: _.template(playerListEmptyHtml)
template: playerListHtml,
. . .
Here is the error:
Running "requirejs:compile" (requirejs) task { [Error: Error: Loader plugin did not call the load callback in the build: tpl: tpl!templates/playerList.html_unnormalized3 tpl!templates/playerList.html Module loading did not complete for: main, app, router, views/AppView, views/TeamDetailView, views/PlayersView at Function.build.checkForErrors (/Users/jim/Dropbox/WebstormProjects/GruntTesting/node_modules/grunt-contrib-requirejs/node_modules/requirejs/bin/r.js:31556:19) ] originalError: [Error: Loader plugin did not call the load callback in the build: tpl: tpl!templates/playerList.html_unnormalized3 tpl!templates/playerList.html Module loading did not complete for: main, app, router, views/AppView, views/TeamDetailView, views/PlayersView] }
apologies for the delay. I have little time to review this and I am not much familiar any more with this tech stack. this plugin is rather simple, unless something changed on requirejs, it should normally work. Have you tried opening an issue on requirejs repository?