Skip to content

Instantly share code, notes, and snippets.

@hughfdjackson
Created June 3, 2013 14:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hughfdjackson/5698791 to your computer and use it in GitHub Desktop.
Save hughfdjackson/5698791 to your computer and use it in GitHub Desktop.
define([
'Backbone'
], function(
Backbone
){
// I've evalled the entire file at this point, using cmd + A, cmd + Enter
Backbone // cmd + Enter returns me `undefined`, although in the application, it would be the Backbone library object
})
@hughfdjackson
Copy link
Author

For reference, I've attempted:

LT Browser

Connected to the browser available within lighttable, pointing it at my dev server (not a file).

Results:

  • No errors;
  • Inability to eval in required dependencies.

External Browser

Using script tag v1

Added the script tag:

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Mission Control</title>
    <base href="/base/path/">

    <script type='text/javascript' id='lt_ws' src='http://localhost:59077/socket.io/lighttable/ws.js'></script>
</head>
<body>

    <script src="js/libs/require.js?app=dev"></script>
    <script src="js/require-config.js?app=dev"></script>
    <script>require(['js/application.js?app=dev']);</script>
</body>
</html>

Results:

  • No errors;
  • Inability to eval in required dependencies.

Using script tag v2

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Mission Control</title>
    <base href="/base/path/">
</head>
<body>


    <script src="js/libs/require.js?app=dev"></script>
    <script src="js/require-config.js?app=dev"></script>
    <script>require(['js/application.js?app=dev']);</script>
    <script type='text/javascript' id='lt_ws' src='http://localhost:59077/socket.io/lighttable/ws.js'></script>

</body>
</html>

Results:

  • My dependencies fail to load through require.js - they're coming up as undefined

Using script tag v3

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Mission Control</title>
    <base href="/base/path/">
</head>
<body>


    <script src="js/libs/require.js?app=dev"></script>
    <script src="js/require-config.js?app=dev"></script>
    <script type='text/javascript' id='lt_ws' src='http://localhost:59077/socket.io/lighttable/ws.js'></script>
    <script>require(['js/application.js?app=dev']);</script>

</body>
</html>

Results:

  • Uncaught Error: Mismatched anonymous define() module: function () { return io; }

Using require.js

Added the following to my index.html - attempting to force the websocket server to be loaded after the rest of the
dependency graph.

    <script type='text/fake' id='lt_ws' src='http://localhost:59077/socket.io/lighttable/ws.js'></script>
    <script>require(['js/application.js?app=dev'], function(){
        require(['http://localhost:59077/socket.io/lighttable/ws.js']);
    });</script>

Results:

  • No errors;
  • Inability to eval in required dependencies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment