Skip to content

Commit d8333a5

Browse files
committed
re-built loader
1 parent 5b48ba3 commit d8333a5

11 files changed

+27
-17
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Optimized [PINF](http://pinf.org/)/[CommonJS](http://commonjs.org/) Loader for J
44
*Status: ALPHA* [![Build Status](https://secure.travis-ci.org/sourcemint/loader-js.png)](http://travis-ci.org/sourcemint/loader-js)
55

66
The `Sourcemint JavaScript Loader` is an optimized *(intended for production use)* **CommonJS package mappings**
7-
based **JavaScript module loader** for the browser in only **1583 bytes** *(minified and zipped)*.
7+
based **JavaScript module loader** for the browser in only **1637 bytes** *(minified and zipped)*.
88

99
* Copyright: 2011 [Christoph Dorn](http://www.christophdorn.com/)
1010
* Code License: [MIT](http://www.opensource.org/licenses/mit-license.php) and [MPL](http://mozilla.org/MPL/2.0/)

loader.crush.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

loader.crush.js.gz

43 Bytes
Binary file not shown.

loader.min.js

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

loader.min.js.gz

54 Bytes
Binary file not shown.

loader.stripped.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,11 @@ var sourcemint = null;
229229
exports: undefined
230230
}
231231

232+
// If embedded in bundle `isMain` will be set to `true` if bundle was `require.main`.
233+
if (packageIdentifier === "" && pkg.main === moduleIdentifier && sandboxOptions.isMain === true) {
234+
module.require.main = moduleInterface;
235+
}
236+
232237
if (sandboxOptions.onInitModule) {
233238
sandboxOptions.onInitModule(moduleInterface, module, pkg, sandbox);
234239
}
@@ -271,7 +276,7 @@ var sourcemint = null;
271276
if (loadingBundles[moduleIdentifier]) {
272277
loadingBundlesCallbacks = loadingBundles[moduleIdentifier];
273278
delete loadingBundles[moduleIdentifier];
274-
for (i=0;i<loadingBundlesCallbacks.length;i++) {
279+
for (var i=0 ; i<loadingBundlesCallbacks.length ; i++) {
275280
loadingBundlesCallbacks[i](sandbox);
276281
}
277282
}
@@ -304,8 +309,13 @@ var sourcemint = null;
304309
}
305310

306311
// Call the 'main' module of the program
312+
sandbox.boot = function() {
313+
return sandbox.require(Package("").main).exports;
314+
};
315+
316+
// Call the 'main' exported function of the main' module of the program
307317
sandbox.main = function() {
308-
var exports = sandbox.require(Package("").main).exports;
318+
var exports = sandbox.boot();
309319
return ((exports.main)?exports.main.apply(null, arguments):undefined);
310320
};
311321

workspace/www/loader.crush.js-size

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2226
1+
2293

workspace/www/loader.crush.js.gz-size

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1672
1+
1715

workspace/www/loader.min.js-size

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3620
1+
3715

workspace/www/loader.min.js.gz-size

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1583
1+
1637

0 commit comments

Comments
 (0)