Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined in requirejs #34

Closed
wenerme opened this issue Mar 22, 2015 · 6 comments
Closed

Undefined in requirejs #34

wenerme opened this issue Mar 22, 2015 · 6 comments

Comments

@wenerme
Copy link

wenerme commented Mar 22, 2015

main.js

  //the require library is configuring paths
  require.config({
    baseUrl: "../assets",
    paths: {
      //tries to load jQuery from Google's CDN first and falls back
      //to load locally
      log: ['log/log'],
      ractive: ['//cdn.ractivejs.org/latest/ractive'],
      rv: ["rv/rv"],

      jquery: ['//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min', 'jquery/jquery'],
      bootstrap: ['//netdna.bootstrapcdn.com/bootstrap/3.3.3/js/bootstrap.min', 'bootstrap/bootstrap'],
      moment: ['moment/moment']
    },
    shim: {
      'bootstrap': {
        deps: ['jquery']
      }
    },
    //how long the it tries to load a script before giving up, the default is 7
    waitSeconds: 10
  });
//requiring the scripts in the first argument and then passing the library namespaces into a callback
//you should be able to console log all of the callback arguments
  require(['jquery', 'moment', 'log', 'ractive', 'rv'],
    function ($, moment, log,Ractive, rv)
    {
      console.log(arguments, window.log);
      log("Log by log");
    });
})(require);

bower.json

{

  "private": true,
  "ignore": [
    "**/.*",
    "node_modules",
    "app/assets",
    "bower_components",
    "test",
    "tests"
  ],
  "dependencies": {
    "bootstrap": "~3.3.4",
    "jquery": "~2.1.3",
    "fontawesome": "~4.3.0",
    "moment": "~2.9.0",
    "requirejs": "~2.1.16",
    "rv": "~0.1.8",
    "log": "~0.1.5"
  }
}

.bowerrc

{
    "directory": "app/assets"
}
@ghost
Copy link

ghost commented Mar 30, 2015

@wenerme I'm having the same problem, were you able to figure this out?

@ghost
Copy link

ghost commented Mar 30, 2015

I figured it out. The AMD definition is incorrect at log.coffee:110:

  define exportedLog

should be

  define -> exportedLog

@adamschwartz I can make a pull request with this fix if desired, or you can do it since it's so small.

@adamschwartz
Copy link
Owner

Thanks @wenerme & @dav- for reporting this.

Interestingly enough, it looks like this was fixed with #32 in the JS, but not the original Coffeescript. Are we sure that this is now correct?

Let’s also loop in @alessioalex, the original author of the AMD stuff (#30), and @rodneyrehm, the author of the JS fix in (#32), for some extra eyes.

@ghost
Copy link

ghost commented Mar 30, 2015

@adamschwartz I found that just before you commented. It's interesting that it's fixed in the JS, because the package I got from Bower seemed to have the unfixed JS.

@rodneyrehm
Copy link
Contributor

#32 only fixed the compile target, not the compiled source. so any time someone compiled the CoffeeScript, the error would reappear. I have no Idea how I only fixed the JS, but not the CS. Shame on me :/

@adamschwartz
Copy link
Owner

Np @rodneyrehm :)

Alllright. 86a79c7 and fadf243 should bring us home.

Thx all!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants