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

Support asynchronous module definition #2

Open
GoogleCodeExporter opened this issue Nov 6, 2015 · 2 comments
Open

Support asynchronous module definition #2

GoogleCodeExporter opened this issue Nov 6, 2015 · 2 comments

Comments

@GoogleCodeExporter
Copy link

Supporting asynchronous module definition [1] would allow to use 
CommonJS-compliant asynchronous javascript loaders like requirejs [2] on the 
client side.

This also allows to declare dependencies between modules, and to ensure that 
some module is loaded before an other.

This would look like this for Markdown.Converter:

``` Javascript
define(function() {
    // return Converter here
});

And for Markdown.Editor:

define(['Markdown.Converter'], function(Converter) {
    // return Editor here
});

And in the client code:

require(['Markdown.Converter', 'Markdown.Editor'], function(Converter, Editor) {
     // ...
});

With non-CommonJs compat:

var Markdown;

function doExport(factory) {
    if (typeof 'define' === 'function' && typeof 'require' === 'function') {
        define.call(this, factory);
    } else {
        Markdown.Converter = factory();
    }
}
doExport(function() {
     // ... return Converter
});

[1] http://wiki.commonjs.org/wiki/Modules/AsynchronousDefinition
[2] http://requirejs.org/


Original issue reported on code.google.com by `arnaud.lb` on 4 Aug 2011 at 5:09
@GoogleCodeExporter
Copy link
Author

I was somewhat expecting this request :)

I'll look at it.

Original comment by b...@stackoverflow.com on 5 Aug 2011 at 5:30

  • Changed state: Accepted
  • Added labels: Type-Enhancement
  • Removed labels: Type-Defect

@GoogleCodeExporter
Copy link
Author

This would be great for using pagedown in GitHub's gollum software.

Original comment by m...@bootstraponline.com on 7 Jun 2012 at 4:32

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

No branches or pull requests

1 participant