Allow Dojo require() to fail

237 Views Asked by At

I have a require statement that loads in a layer that I build with Dojo. I want to be able to test my code without having to build my Dojo source every time. However, if I don't build and the require statement is called, it fails with a 404 error.

Is there any way to catch this 404 error and allow it to fail?

1

There are 1 best solutions below

2
C Snover On BEST ANSWER

Any module in an application can be converted into a “layer” module, which consists of the original module + additional dependencies built into the same file. Using layers allows applications to reduce the number of HTTP requests by combining all JavaScript into a single file. Creating a new layer file just for the production version of your application is not the correct way to create a build. Instead, build into a module that you’re already loading in development. Then, your require calls never change between development and production; the only difference is that your layered modules contain their dependencies.