require-handlebars-plugin icon indicating copy to clipboard operation
require-handlebars-plugin copied to clipboard

Loading template with the same name as module failed

Open mbektimirov opened this issue 10 years ago • 6 comments

Given I have MyModule.js and MyModule.hbs in the same folder. If I try to load MyModule.hbs from MyModule.js the requirejs gets silent at all - no errors, just nothing.

Simple example:

app/scripts/MyModule
├── MyModule.hbs
└── MyModule.js
// MyModule.js
define(['hbs!./MyModule'], function (tmpl) {
  // MyModule.js not loaded 
});

mbektimirov avatar Mar 16 '14 06:03 mbektimirov

Same but with error. I got this in console

Error: Load timeout for modules: hbs!app/scripts/MyModule/MyModule_unnormalized12,hbs!app/scripts/MyModule/MyModule
http://requirejs.org/docs/errors.html#timeout

Where does this unnormalized12 get from?

poke @SlexAxton

JSteunou avatar Jun 30 '14 08:06 JSteunou

same here.

Uncaught Error: Load timeout for modules: hbs!selectRace/CategoryView_unnormalized6,hbs!selectRace/CategoryView

RainThinks avatar Aug 22 '14 03:08 RainThinks

Also getting this bug on a very small app, but on a larger one no problems. Its being served off localhost, and only happens about 1 out of every 10 page loads, so maybe its a synchronicity issue?

azaslavsky avatar Oct 21 '14 11:10 azaslavsky

I've been working around this by appending -template to all of my templates, but it's a definitely a gotcha that can take a while to debug.

dak avatar Oct 21 '14 13:10 dak

Hmm, so I was working on localhost, and when I enalbed self-signed HTTPS on that local server, the problem disappeared. Maybe this is a "CORS" related issue like, [as is common[(https://github.com/requirejs/text#xhr-restrictions) with the related text! plugin?

azaslavsky avatar Oct 21 '14 14:10 azaslavsky

Same problem here, so :+1:

As @dak proposed, workaround is to simply rename hbs file to avoid collision Agreed with him, it took a bit long for me to find this issue (far longer than solving it ;-))

fcamblor avatar Apr 03 '15 14:04 fcamblor