Skip to content

v2.2.0 - The included global.define breaks UMD defs in other scripts #1544

@marshallswain

Description

@marshallswain

In order to use can.jquery.dev.js in its current form, I have to delete window.define:

    <script src="/bower_components/jquery/dist/jquery.min.js"></script>
    <script src="/bower_components/canjs/can.jquery.dev.js"></script>
    <script src="/bower_components/canjs/can.stache.js"></script>
    <script src="/bower_components/canjs/can.map.define.js"></script>
    <script src="/bower_components/canjs/can.map.delegate.js"></script>
    <script src="/bower_components/canjs/can.list.promise.js"></script>
    <script src="/bower_components/canjs/can.list.sort.js"></script>
    <script src="/bower_components/canjs/can.fixture.js"></script>

    <script>delete window.define;</script>

    <script src="/socket.io/socket.io.js"></script>
    <script src="/bower_components/momentjs/min/moment.min.js"></script>
    <script src="/bower_components/accounting.js/accounting.min.js"></script>
    <script src="/bower_components/feathers-websocket-client/dist/feathers-websocket-client.js"></script>
    <script src="/bower_components/canjs-feathers/lib/feathers.js"></script>

If not, because can.jquery.dev.js includes the following lines:

// Line 26: 
var ourDefine = global.define = function(moduleName, deps, callback){
...
// Line 60: 
global.define.amd = true;

This breaks any UMD definitions in libraries loaded after CanJS:

(function (root, factory) {
  if (typeof define === 'function' && define.amd) {
      // AMD mode gets run instead of window global stuff, below.
      define(['can/util/can', 'feathers-websocket-client'], factory);
  } else if (typeof exports === 'object') {
      module.exports = factory(require('can/util/can'),  require('feathers-websocket-client'));
  } else if(typeof window !== 'undefined' && root && root.can && root.Feathers.client) {
      // This would run if define.amd wasn't true.
      factory(root.can, root.Feathers.client);
  }
}(this, function (can, feathersClient) {

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