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

RequireJS Working Example? #38

Closed
plusjade opened this issue Feb 9, 2012 · 3 comments
Closed

RequireJS Working Example? #38

plusjade opened this issue Feb 9, 2012 · 3 comments

Comments

@plusjade
Copy link

plusjade commented Feb 9, 2012

I'm struggling to get this working with requireJS. I've tried the examples in the README with no luck.

Here is my control case:

define([
  'require',
  'jquery',
  'mustache',
  'js-yaml.min',
], function(require, $){

  var JB = { 
    init : function(boot){
      var doc = jsyaml.load('greeting: hello\nname: world');
      console.log(doc); // this works fine.

      //require('js-yaml.min'); // this works both uncommented and commented.

      var singleDoc = require('http://127.0.0.1/~jade/javascripts/require-js/tags.yaml').shift();
      console.log(singleDoc); 
      // This does not work
      // Uncaught Error: Module name 'http://127.0.0.1/~jade/javascripts/require-js/tags.yaml' has not been loaded yet for context: _
      // http://requirejs.org/docs/errors.html#notloaded

      if(typeof boot === "function") boot();
    } 
  };

  return JB;
});

As per the error documentation (http://requirejs.org/docs/errors.html#notloaded) I have tried to load the tags.yaml first in the define statement. The tags.yaml loads fine but since its not javascript, It returns a syntax error.

Any help would be appreciated, thanks.

@ixti
Copy link
Contributor

ixti commented Feb 9, 2012

Hm... It looks like you're right. In fact I'm not really familiar with RequireJS, so I simply copy-pasted jQuery's define block:

if ( typeof define === "function" && define.amd) {
  define( "jsyaml", [], function () { return jsyaml; } );
}

In terms of what you want to do, as far as I can see, it's not enough. If you'll provide a necessary code that RequireJS needs to make JsYAML 100% compatible with RequireJS, I'll be proud to merge it.

@plusjade
Copy link
Author

Ok thank you. I am still working on this. When I get it figured out nicely I will send my pull request!

@ixti
Copy link
Contributor

ixti commented Feb 14, 2012

We have removed AMD definition in the trunk, as it's obviously not ready yet. Please, if you are confident with RequireJS and can provide a pull-request - I will be happy to merge it in.

@ixti ixti closed this as completed Feb 14, 2012
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

2 participants