|
15 | 15 | // the top function. |
16 | 16 |
|
17 | 17 | (function (root, factory) { |
18 | | - if (typeof exports === 'object') { |
| 18 | + if (typeof define === 'function' && define.amd) { |
| 19 | + // AMD. Register as an anonymous module. |
| 20 | + define(['b'], factory); |
| 21 | + } else if (typeof exports === 'object') { |
19 | 22 | // Node. Does not work with strict CommonJS, but |
20 | 23 | // only CommonJS-like enviroments that support module.exports, |
21 | 24 | // like Node. |
22 | 25 | module.exports = factory(require('b')); |
23 | | - } else if (typeof define === 'function' && define.amd) { |
24 | | - // AMD. Register as an anonymous module. |
25 | | - define(['b'], factory); |
26 | 26 | } else { |
27 | 27 | // Browser globals (root is window) |
28 | 28 | root.returnExports = factory(root.b); |
|
39 | 39 |
|
40 | 40 | // if the module has no dependencies, the above pattern can be simplified to |
41 | 41 | (function (root, factory) { |
42 | | - if (typeof exports === 'object') { |
| 42 | + if (typeof define === 'function' && define.amd) { |
| 43 | + // AMD. Register as an anonymous module. |
| 44 | + define(factory); |
| 45 | + } else if (typeof exports === 'object') { |
43 | 46 | // Node. Does not work with strict CommonJS, but |
44 | 47 | // only CommonJS-like enviroments that support module.exports, |
45 | 48 | // like Node. |
46 | 49 | module.exports = factory(); |
47 | | - } else if (typeof define === 'function' && define.amd) { |
48 | | - // AMD. Register as an anonymous module. |
49 | | - define(factory); |
50 | 50 | } else { |
51 | 51 | // Browser globals (root is window) |
52 | 52 | root.returnExports = factory(); |
|
0 commit comments