app.js 633 B

12345678910111213141516171819202122
  1. t.equal(
  2. require("./shared")(), 1,
  3. "the main app bundle can already use the shared library"
  4. );
  5. t.throws(function() {
  6. require("./lazy");
  7. }, "lazy bundle is not executed yet so the lazy module cannot be required yet");
  8. // Use setTimeout as script loader simulator as in real use case this would be
  9. // a call to one. Now we just let the rest of the source code string we build
  10. // to execute.
  11. setTimeout(function() {
  12. // After lazy bundle is executed we can require the lazy.js module
  13. require("./lazy");
  14. t.equal(
  15. require("./shared")(),3,
  16. "lazy module was able to use shared code"
  17. );
  18. }, 1);