Last active
December 16, 2015 08:09
-
-
Save amatiasq/5403764 to your computer and use it in GitHub Desktop.
Testing a script to be used instead of almond
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
({ | |
name: "require.optimized", | |
optimize: "none", | |
include: ["main"], | |
out: "out.js" | |
}) |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="out.js"></script> | |
</head> | |
<body></body> | |
</html> |
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
require(['moduleB']) |
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
define(function() { | |
return 'hi'; | |
}); |
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
define(function(require) { | |
var a = require('moduleA'); | |
console.log(a + '!'); | |
}); |
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
(function() { | |
var loaded = {}; | |
var mods = {}; | |
function require(a) { | |
return mods[a]; | |
} | |
function load(name) { | |
if (loaded[name] !== true) | |
return; | |
mods[name] = mods[name](); | |
loaded[name] = true; | |
} | |
function define(name, deps, mod) { | |
mod = mod || deps; | |
if (deps instanceof Array) deps.map(load); | |
mods[name] = mod(require); | |
} | |
function globalRequire(arr, cbk) { | |
arr.map(load); | |
if (cbk) cbk.apply(null, arr.map(require)); | |
} | |
window.define = define; | |
window.require = window.requirejs = globalRequire; | |
})(); | |
define("require.optimized", function(){}); | |
define('moduleA',[],function() { | |
return 'hi'; | |
}); | |
define('moduleB',['require','moduleA'],function(require) { | |
var a = require('moduleA'); | |
console.log(a + '!'); | |
}); | |
require(['moduleB']); | |
define("main", 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
(function() { | |
var loaded = {}; | |
var mods = {}; | |
function require(a) { | |
return mods[a]; | |
} | |
function load(name) { | |
if (loaded[name] !== true) | |
return; | |
mods[name] = mods[name](); | |
loaded[name] = true; | |
} | |
function define(name, deps, mod) { | |
mod = mod || deps; | |
if (deps instanceof Array) deps.map(load); | |
mods[name] = mod(require); | |
} | |
function globalRequire(arr, cbk) { | |
arr.map(load); | |
if (cbk) cbk.apply(null, arr.map(require)); | |
} | |
window.define = define; | |
window.require = window.requirejs = globalRequire; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment