Skip to content

Treate define(Identifier) as AMD call if AMD check before it #460

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

Closed
jrburke opened this issue Jun 7, 2013 · 1 comment
Closed

Treate define(Identifier) as AMD call if AMD check before it #460

jrburke opened this issue Jun 7, 2013 · 1 comment
Milestone

Comments

@jrburke
Copy link
Member

jrburke commented Jun 7, 2013

A result of this thread:
http://groups.google.com/group/requirejs/browse_thread/thread/b4f701db210f980c

With this block

(function (root, factory) {
    if (typeof define === 'function' && define.amd) {
        //Allow using this built library as an AMD module
        //in another project. That other project will only
        //see this AMD call, not the internal modules in
        //the closure below.
        define(factory);
    } else {
        //Browser globals case. Just assign the
        //result to a property on the global.
        root.Bam = factory();
    }
}(this, function () {
});

The define(Identifier) is not seen as a define() call, so the internals of the lib are scanned, and a loader plugin resource is found.

Ideally, if define(Identifier), backtrack in the token stream to check for a define.amd check, and if there, treat it as an AMD define call and skip internal parsing?

Hmm, the rest of the file still may be scanned regardless? Consider stopping scanning in this case. Needs some thought though, may get bumped to a later release.

@jrburke
Copy link
Member Author

jrburke commented Jul 8, 2013

Fixed in 230dc35

@jrburke jrburke closed this as completed Jul 8, 2013
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

1 participant