Skip to content

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

Closed

Description

@jrburke

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.

Activity

  1. added a commit that references this issue on Jul 8, 2013
  2. jrburke commented on Jul 8, 2013

    @jrburke
    MemberAuthor

    Fixed in 230dc35

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions