Skip to content

Defer resolution errors to execution time in CJS #21

@jugglinmike

Description

@jugglinmike

Script loaders should execute the factory function for CommonJS-style modules regardless of whether all dependencies were successfully resolved. Any errors in resolution should instead be thrown by the local require function. This would more closely mimic the behavior of CJS environments and enable module authors to handle unsatisfied dependencies. Authors could then specify "optional" dependencies (which currently cannot be expressed with AMD):

define(function(require) {
  var Backbone = {};
  var _ = require('underscore');

  try {
    Backbone.$ = require('jquery');
  } catch(err) {}

  // etc.
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions