-
Notifications
You must be signed in to change notification settings - Fork 27
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
20 changed files
with
452 additions
and
7 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
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,15 @@ | ||
var read = require('fs').readFileSync; | ||
|
||
var banner = '/*!\n * ' + read(__dirname + '/../LICENCE', 'utf8').replace(/\n/g, '\n * ') + '\n */'; | ||
|
||
module.exports = { | ||
name: 'dynamic banner example', | ||
banner: banner, | ||
root: '../js', | ||
output: '../dynamic.js', | ||
modules: { | ||
main: 'main.js' | ||
}, | ||
main: 'main', | ||
ie: false | ||
}; |
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,21 @@ | ||
{ | ||
"name": "static banner example", | ||
"banner": "/*! Bundle from config \"<%= __filename.replace(__dirname, '').slice(1) %>\" */", | ||
"root": "../js", | ||
"output": "../index.js", | ||
"modules": { | ||
"main": "main.js" | ||
}, | ||
"bundles": { | ||
"test": { | ||
"name": "bundles are inherit banner from parent module", | ||
"modules": { | ||
"main": "main.js" | ||
}, | ||
"styles_output": false | ||
} | ||
}, | ||
"main": "main", | ||
"ie": false, | ||
"optimize": true | ||
} |
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,13 @@ | ||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | ||
Version 2, December 2004 | ||
|
||
Copyright (C) 2004 Anonymous <i@anonymous.net> | ||
|
||
Everyone is permitted to copy and distribute verbatim or modified | ||
copies of this license document, and changing it is allowed as long | ||
as the name is changed. | ||
|
||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | ||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION | ||
|
||
0. You just DO WHAT THE FUCK YOU WANT TO. |
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 @@ | ||
This example covers | ||
|
||
* banner - message before bundle code | ||
|
||
```js | ||
/*! Banner is this */ | ||
(function(global,main,modules,modules_options,options){}) | ||
``` |
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,170 @@ | ||
/*! | ||
* DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | ||
* Version 2, December 2004 | ||
* | ||
* Copyright (C) 2004 Anonymous <i@anonymous.net> | ||
* | ||
* Everyone is permitted to copy and distribute verbatim or modified | ||
* copies of this license document, and changing it is allowed as long | ||
* as the name is changed. | ||
* | ||
* DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | ||
* TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION | ||
* | ||
* 0. You just DO WHAT THE FUCK YOU WANT TO. | ||
* | ||
*/ | ||
(function (global, main, modules, modules_options, options) { | ||
var initialized_modules = {}, | ||
global_eval = function (code) { | ||
return global.Function('return ' + code)(); | ||
}, | ||
|
||
global_document = global.document, | ||
local_undefined, | ||
/** | ||
* @param {String} moduleName module name or path to file | ||
* @param {*} module module content | ||
* | ||
* @returns {*} | ||
*/ | ||
register_module = function (moduleName, module) { | ||
lmd_trigger('lmd-register:before-register', moduleName, module); | ||
// Predefine in case of recursive require | ||
var output = {'exports': {}}; | ||
initialized_modules[moduleName] = 1; | ||
modules[moduleName] = output.exports; | ||
|
||
if (!module) { | ||
// if undefined - try to pick up module from globals (like jQuery) | ||
// or load modules from nodejs/worker environment | ||
module = lmd_trigger('js:request-environment-module', moduleName, module)[1] || global[moduleName]; | ||
} else if (typeof module === 'function') { | ||
// Ex-Lazy LMD module or unpacked module ("pack": false) | ||
var module_require = lmd_trigger('lmd-register:decorate-require', moduleName, lmd_require)[1]; | ||
|
||
// Make sure that sandboxed modules cant require | ||
if (modules_options[moduleName] && | ||
modules_options[moduleName].sandbox && | ||
typeof module_require === 'function') { | ||
|
||
module_require = local_undefined; | ||
} | ||
|
||
module = module(module_require, output.exports, output) || output.exports; | ||
} | ||
|
||
module = lmd_trigger('lmd-register:after-register', moduleName, module)[1]; | ||
return modules[moduleName] = module; | ||
}, | ||
/** | ||
* List of All lmd Events | ||
* | ||
* @important Do not rename it! | ||
*/ | ||
lmd_events = {}, | ||
/** | ||
* LMD event trigger function | ||
* | ||
* @important Do not rename it! | ||
*/ | ||
lmd_trigger = function (event, data, data2, data3) { | ||
var list = lmd_events[event], | ||
result; | ||
|
||
if (list) { | ||
for (var i = 0, c = list.length; i < c; i++) { | ||
result = list[i](data, data2, data3) || result; | ||
if (result) { | ||
// enable decoration | ||
data = result[0] || data; | ||
data2 = result[1] || data2; | ||
data3 = result[2] || data3; | ||
} | ||
} | ||
} | ||
return result || [data, data2, data3]; | ||
}, | ||
/** | ||
* LMD event register function | ||
* | ||
* @important Do not rename it! | ||
*/ | ||
lmd_on = function (event, callback) { | ||
if (!lmd_events[event]) { | ||
lmd_events[event] = []; | ||
} | ||
lmd_events[event].push(callback); | ||
}, | ||
/** | ||
* @param {String} moduleName module name or path to file | ||
* | ||
* @returns {*} | ||
*/ | ||
lmd_require = function (moduleName) { | ||
var module = modules[moduleName]; | ||
|
||
var replacement = lmd_trigger('*:rewrite-shortcut', moduleName, module); | ||
if (replacement) { | ||
moduleName = replacement[0]; | ||
module = replacement[1]; | ||
} | ||
|
||
lmd_trigger('*:before-check', moduleName, module); | ||
// Already inited - return as is | ||
if (initialized_modules[moduleName] && module) { | ||
return module; | ||
} | ||
|
||
lmd_trigger('*:before-init', moduleName, module); | ||
|
||
// Lazy LMD module not a string | ||
if (typeof module === 'string' && module.indexOf('(function(') === 0) { | ||
module = global_eval(module); | ||
} | ||
|
||
return register_module(moduleName, module); | ||
}, | ||
output = {'exports': {}}, | ||
|
||
/** | ||
* Sandbox object for plugins | ||
* | ||
* @important Do not rename it! | ||
*/ | ||
sandbox = { | ||
'global': global, | ||
'modules': modules, | ||
'modules_options': modules_options, | ||
'options': options, | ||
|
||
'eval': global_eval, | ||
'register': register_module, | ||
'require': lmd_require, | ||
'initialized': initialized_modules, | ||
|
||
|
||
'document': global_document, | ||
|
||
|
||
|
||
'on': lmd_on, | ||
'trigger': lmd_trigger, | ||
'undefined': local_undefined | ||
}; | ||
|
||
for (var moduleName in modules) { | ||
// reset module init flag in case of overwriting | ||
initialized_modules[moduleName] = 0; | ||
} | ||
|
||
|
||
|
||
main(lmd_trigger('lmd-register:decorate-require', 'main', lmd_require)[1], output.exports, output); | ||
})/*DO NOT ADD ; !*/ | ||
(this,(function (require, exports, module) { /* wrapped by builder */ | ||
console.log('it works'); | ||
|
||
}),{ | ||
|
||
},{},{"bundle":"_ed84fa22"}); |
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,9 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>LMD banner example</title> | ||
<script type="text/javascript" src="index.js"></script> | ||
</head> | ||
<body> | ||
</body> | ||
</html> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,7 @@ | ||
/*! Bundle from config "index.lmd.json" */ | ||
_b626bde7({ | ||
"main": (function (require, exports, module) { /* wrapped by builder */ | ||
console.log('it works'); | ||
|
||
}) | ||
},{}); |
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 @@ | ||
console.log('it works'); |
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
Oops, something went wrong.