-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
163 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
test/expected/*.js | ||
test/expected/*/*.js | ||
test/tmp/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ node_modules | |
npm-debug.log | ||
coverage | ||
.idea | ||
test/tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
define('simple_amd_file',[],function() { | ||
|
||
var Mult = function(a, b) { | ||
return a * b; | ||
}; | ||
|
||
return Mult; | ||
|
||
}); | ||
|
||
// src for the wrapper: https://github.com/umdjs/umd/blob/master/amdWeb.js | ||
(function (root, factory) { | ||
if (typeof define === 'function' && define.amd) { | ||
// AMD. Register as an anonymous module. | ||
define('umd_file',factory); | ||
} else { | ||
// Browser globals | ||
root.amdWeb = factory(root.b); | ||
} | ||
}(this, function() { | ||
//use b in some fashion. | ||
|
||
// Just return a value to define the module export. | ||
// This example returns an object, but the module | ||
// can return a function as the exported value. | ||
return { | ||
test: function() { | ||
console.log('Test Log from the UMD file'); | ||
} | ||
}; | ||
})); | ||
|
||
(function(root) { | ||
|
||
root.myLib = {}; | ||
|
||
root.myLib.sum = function(a, b) { | ||
return a + b; | ||
}; // END PROTYPE OF sum | ||
|
||
})(this); | ||
|
||
define("non_md_file", (function (global) { | ||
return function () { | ||
var ret, fn; | ||
return ret || global.myLib; | ||
}; | ||
}(this))); | ||
|
||
define('complex_amd_file',['non_md_file', 'simple_amd_file'], function(MyLib, mult) { | ||
|
||
var SumMulti = function(a, b) { | ||
return mult(MyLib.sum(a, b), b); | ||
}; | ||
|
||
return SumMulti; | ||
|
||
}); | ||
|
||
requirejs(['simple_amd_file', 'umd_file', 'complex_amd_file'], | ||
function(mult, UMDLib, sumMulti) { | ||
console.log('executing the COMPLEX init file'); | ||
console.log(mult(3, 5), '<= this should be 15'); | ||
UMDLib.test(); // should log 'Test Log from the UMD file' | ||
console.log(sumMulti(5, 8), '<= this should be 104'); | ||
} | ||
); | ||
|
||
define("complex_init_dir", function(){}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
requirejs(['simple_amd_file', 'umd_file', 'complex_amd_file'], | ||
function(mult, UMDLib, sumMulti) { | ||
console.log('executing the COMPLEX init file'); | ||
console.log(mult(3, 5), '<= this should be 15'); | ||
UMDLib.test(); // should log 'Test Log from the UMD file' | ||
console.log(sumMulti(5, 8), '<= this should be 104'); | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
//The build will inline common dependencies into this file. | ||
requirejs.config({ | ||
paths: { | ||
'complex_init_dir': '../complex_init_dir', | ||
}, | ||
shim: { | ||
'non_md_file': { | ||
exports: 'myLib' | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters