forked from webpack/webpack
-
Notifications
You must be signed in to change notification settings - Fork 0
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
25 changed files
with
668 additions
and
43 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,4 +1,4 @@ | ||
/node_modules | ||
/test/js | ||
/test/browsertest/js | ||
/example/js | ||
/examples/*/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
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,138 @@ | ||
# example.js | ||
|
||
``` javascript | ||
function getTemplate(templateName, callback) { | ||
require.ensure([], function(require) { | ||
callback(require("../require.context/templates/"+templateName)); | ||
}); | ||
} | ||
getTemplate("a", function(a) { | ||
console.log(a); | ||
}); | ||
getTemplate("b", function(b) { | ||
console.log(b); | ||
}); | ||
``` | ||
|
||
# js/output.js | ||
|
||
``` javascript | ||
/******/(function(document, undefined) { | ||
/******/ return function(modules) { | ||
/******/ var installedModules = {}, installedChunks = {0:1}; | ||
/******/ function require(moduleId) { | ||
/******/ if(installedModules[moduleId]) | ||
/******/ return installedModules[moduleId].exports; | ||
/******/ var module = installedModules[moduleId] = { | ||
/******/ exports: {} | ||
/******/ }; | ||
/******/ modules[moduleId](module, module.exports, require); | ||
/******/ return module.exports; | ||
/******/ } | ||
/******/ require.ensure = function(chunkId, callback) { | ||
/******/ if(installedChunks[chunkId] === 1) return callback(require); | ||
/******/ if(installedChunks[chunkId] !== undefined) | ||
/******/ installedChunks[chunkId].push(callback); | ||
/******/ else { | ||
/******/ installedChunks[chunkId] = [callback]; | ||
/******/ var head = document.getElementsByTagName('head')[0]; | ||
/******/ var script = document.createElement('script'); | ||
/******/ script.type = 'text/javascript'; | ||
/******/ script.src = modules.c+chunkId+modules.a; | ||
/******/ head.appendChild(script); | ||
/******/ } | ||
/******/ }; | ||
/******/ window[modules.b] = function(chunkId, moreModules) { | ||
/******/ for(var moduleId in moreModules) | ||
/******/ modules[moduleId] = moreModules[moduleId]; | ||
/******/ var callbacks = installedChunks[chunkId]; | ||
/******/ installedChunks[chunkId] = 1; | ||
/******/ for(var i = 0; i < callbacks.length; i++) | ||
/******/ callbacks[i](require); | ||
/******/ }; | ||
/******/ return require(0); | ||
/******/ } | ||
/******/})(document) | ||
/******/({a:".output.js",b:"webpackJsonp",c:"", | ||
/******/0: function(module, exports, require) { | ||
|
||
function getTemplate(templateName, callback) { | ||
require.ensure(1, function(require) { | ||
callback(require(1)("./"+templateName)); | ||
}); | ||
} | ||
getTemplate("a", function(a) { | ||
console.log(a); | ||
}); | ||
getTemplate("b", function(b) { | ||
console.log(b); | ||
}); | ||
|
||
/******/}, | ||
/******/ | ||
/******/}) | ||
``` | ||
|
||
# js/1.output.js | ||
|
||
``` javascript | ||
/******/webpackJsonp(1, { | ||
/******/1: function(module, exports, require) { | ||
|
||
/***/module.exports = function(name) { | ||
/***/ var map = {"./b.js":3,"./a.js":2,"./c.js":4}; | ||
/***/ return require(map[name]||map[name+".web.js"]||map[name+".js"]); | ||
/***/}; | ||
|
||
/******/}, | ||
/******/ | ||
/******/2: function(module, exports, require) { | ||
|
||
module.exports = function() { | ||
return "This text was generated by template A"; | ||
} | ||
|
||
/******/}, | ||
/******/ | ||
/******/3: function(module, exports, require) { | ||
|
||
module.exports = function() { | ||
return "This text was generated by template B"; | ||
} | ||
|
||
/******/}, | ||
/******/ | ||
/******/4: function(module, exports, require) { | ||
|
||
module.exports = function() { | ||
return "This text was generated by template C"; | ||
} | ||
|
||
/******/}, | ||
/******/ | ||
/******/}) | ||
``` | ||
|
||
# Info | ||
|
||
## Uncompressed | ||
|
||
``` javascript | ||
{ chunkCount: 2, | ||
modulesCount: 5, | ||
modulesIncludingDuplicates: 5, | ||
modulesPerChunk: 2.5, | ||
modulesFirstChunk: 1, | ||
fileSizes: { 'output.js': 1855, '1.output.js': 729 } } | ||
``` | ||
|
||
## Minimized (uglify-js, no zip) | ||
|
||
``` javascript | ||
{ chunkCount: 2, | ||
modulesCount: 5, | ||
modulesIncludingDuplicates: 5, | ||
modulesPerChunk: 2.5, | ||
modulesFirstChunk: 1, | ||
fileSizes: { 'output.js': 683, '1.output.js': 404 } } | ||
``` |
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,11 @@ | ||
function getTemplate(templateName, callback) { | ||
require.ensure([], function(require) { | ||
callback(require("../require.context/templates/"+templateName)); | ||
}); | ||
} | ||
getTemplate("a", function(a) { | ||
console.log(a); | ||
}); | ||
getTemplate("b", function(b) { | ||
console.log(b); | ||
}); |
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,14 @@ | ||
var cp = require('child_process'); | ||
|
||
var argv = process.argv; | ||
argv.shift(); | ||
argv.shift(); | ||
var extraArgs = argv.join(" "); | ||
|
||
cp.exec("node ../../bin/webpack.js "+extraArgs+" example.js js/output.js", function (error, stdout, stderr) { | ||
console.log('stdout:\n' + stdout); | ||
console.log('stderr:\n ' + stderr); | ||
if (error !== null) { | ||
console.log('error: ' + error); | ||
} | ||
}); |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.