2012-03-27 06:00:51 +08:00
|
|
|
# example.js
|
|
|
|
|
|
|
|
``` javascript
|
|
|
|
// Polyfill require for node.js usage of loaders
|
2012-10-25 01:28:17 +08:00
|
|
|
require = require("enhanced-require")(module);
|
2012-03-27 06:00:51 +08:00
|
|
|
|
|
|
|
// use our loader
|
|
|
|
console.dir(require("./loader!./file"));
|
|
|
|
|
|
|
|
// use buildin json loader
|
|
|
|
console.dir(require("./test.json")); // default by extension
|
|
|
|
console.dir(require("json!./test.json")); // manual
|
|
|
|
```
|
|
|
|
|
|
|
|
# file.js
|
|
|
|
|
|
|
|
``` javascript
|
|
|
|
exports.foo = "bar";
|
|
|
|
```
|
|
|
|
|
|
|
|
# loader.js
|
|
|
|
|
|
|
|
``` javascript
|
2012-04-05 21:08:49 +08:00
|
|
|
module.exports = function(content) {
|
|
|
|
return "exports.answer = 42;\n" + content;
|
2012-03-27 06:00:51 +08:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
# test.json
|
|
|
|
|
|
|
|
``` javascript
|
|
|
|
{
|
|
|
|
"foobar": 1234
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
# js/output.js
|
|
|
|
|
|
|
|
``` javascript
|
|
|
|
/******/(function(modules) {
|
|
|
|
/******/ var installedModules = {};
|
|
|
|
/******/ function require(moduleId) {
|
|
|
|
/******/ if(typeof moduleId !== "number") throw new Error("Cannot find module '"+moduleId+"'");
|
|
|
|
/******/ if(installedModules[moduleId])
|
|
|
|
/******/ return installedModules[moduleId].exports;
|
|
|
|
/******/ var module = installedModules[moduleId] = {
|
2012-08-23 08:05:07 +08:00
|
|
|
/******/ exports: {},
|
|
|
|
/******/ id: moduleId,
|
|
|
|
/******/ loaded: false
|
2012-03-27 06:00:51 +08:00
|
|
|
/******/ };
|
|
|
|
/******/ modules[moduleId](module, module.exports, require);
|
2012-08-23 08:05:07 +08:00
|
|
|
/******/ module.loaded = true;
|
2012-03-27 06:00:51 +08:00
|
|
|
/******/ return module.exports;
|
|
|
|
/******/ }
|
2012-05-22 04:59:31 +08:00
|
|
|
/******/ require.e = function(chunkId, callback) {
|
2012-03-27 06:00:51 +08:00
|
|
|
/******/ callback(require);
|
|
|
|
/******/ };
|
2012-05-17 18:47:06 +08:00
|
|
|
/******/ require.modules = modules;
|
2012-07-11 23:53:46 +08:00
|
|
|
/******/ require.cache = installedModules;
|
2012-03-27 06:00:51 +08:00
|
|
|
/******/ return require(0);
|
|
|
|
/******/})
|
2012-08-07 04:19:15 +08:00
|
|
|
/******/({c:"",
|
2012-03-27 06:00:51 +08:00
|
|
|
/******/0: function(module, exports, require) {
|
|
|
|
|
2012-07-11 23:53:46 +08:00
|
|
|
/*** .\example.js ***/
|
|
|
|
|
2012-10-25 01:28:17 +08:00
|
|
|
/******/ /* WEBPACK FREE VAR INJECTION */ (function(module,console) {
|
2012-03-27 06:00:51 +08:00
|
|
|
// Polyfill require for node.js usage of loaders
|
2012-10-25 01:28:17 +08:00
|
|
|
require = require(/* enhanced-require */3)(module);
|
2012-03-27 06:00:51 +08:00
|
|
|
|
|
|
|
// use our loader
|
2012-10-26 21:07:50 +08:00
|
|
|
console.dir(require(/* ./loader!./file */7));
|
2012-03-27 06:00:51 +08:00
|
|
|
|
|
|
|
// use buildin json loader
|
2012-04-08 03:36:55 +08:00
|
|
|
console.dir(require(/* ./test.json */2)); // default by extension
|
|
|
|
console.dir(require(/* json!./test.json */2)); // manual
|
2012-10-25 01:28:17 +08:00
|
|
|
/******/ /* WEBPACK FREE VAR INJECTION */ }(require(/* __webpack_module */5)(module),require(/* __webpack_console */1)))
|
2012-03-27 06:00:51 +08:00
|
|
|
|
|
|
|
/******/},
|
|
|
|
/******/
|
|
|
|
/******/1: function(module, exports, require) {
|
|
|
|
|
2012-07-11 23:53:46 +08:00
|
|
|
/*** (webpack)\buildin\__webpack_console.js ***/
|
|
|
|
|
2012-08-07 04:19:15 +08:00
|
|
|
var console = (function() { return this["console"] || (this["window"] && this["window"].console) || {} }());
|
2012-04-05 20:59:01 +08:00
|
|
|
module.exports = console;
|
|
|
|
for(var name in {log:1, info:1, error:1, warn:1, dir:1, trace:1, assert:1})
|
|
|
|
if(!console[name])
|
|
|
|
console[name] = function() {};
|
2012-07-19 18:03:56 +08:00
|
|
|
var times = {};
|
2012-04-05 20:59:01 +08:00
|
|
|
if(!console.time)
|
|
|
|
console.time = function(label) {
|
|
|
|
times[label] = Date.now();
|
|
|
|
};
|
|
|
|
if(!console.timeEnd)
|
|
|
|
console.timeEnd = function() {
|
|
|
|
var duration = Date.now() - times[label];
|
|
|
|
console.log('%s: %dms', label, duration);
|
|
|
|
};
|
2012-03-27 06:00:51 +08:00
|
|
|
|
2012-04-08 03:36:55 +08:00
|
|
|
/******/},
|
|
|
|
/******/
|
|
|
|
/******/2: function(module, exports, require) {
|
|
|
|
|
2012-07-11 23:53:46 +08:00
|
|
|
/*** (webpack)\~\json-loader!.\test.json ***/
|
|
|
|
|
2012-04-08 03:36:55 +08:00
|
|
|
module.exports = {
|
|
|
|
"foobar": 1234
|
|
|
|
}
|
|
|
|
|
2012-03-27 06:00:51 +08:00
|
|
|
/******/},
|
|
|
|
/******/
|
|
|
|
/******/3: function(module, exports, require) {
|
|
|
|
|
2012-10-25 01:28:17 +08:00
|
|
|
/*** C:\Users\Sokrates\Eigene Repos\~\enhanced-require\lib\require.webpack.js ***/
|
|
|
|
|
|
|
|
/*
|
|
|
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
|
|
Author Tobias Koppers @sokra
|
|
|
|
*/
|
|
|
|
module.exports = function() {
|
|
|
|
return require(/* __webpack_amd_require */4);
|
|
|
|
}
|
|
|
|
|
|
|
|
/******/},
|
|
|
|
/******/
|
|
|
|
/******/4: function(module, exports, require) {
|
|
|
|
|
|
|
|
/*** (webpack)\buildin\__webpack_amd_require.js ***/
|
|
|
|
|
|
|
|
var req = require.valueOf();
|
|
|
|
function amdRequire(chunk, requiresFn, fn) {
|
|
|
|
if(!requiresFn) {
|
|
|
|
// commonjs
|
|
|
|
return req(chunk);
|
|
|
|
}
|
|
|
|
req.e(chunk, function() {
|
|
|
|
var modules = requiresFn();
|
|
|
|
if(fn)
|
|
|
|
return fn.apply(null, modules);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
for(var name in req)
|
|
|
|
amdRequire[name] = req[name];
|
2012-10-26 21:07:50 +08:00
|
|
|
amdRequire.amd = require(/* ./__webpack_options_amd.loader.js!./__webpack_options_amd.loader.js */6);
|
2012-10-25 01:28:17 +08:00
|
|
|
amdRequire.config = function() {/* config is ignored, use webpack options */};
|
|
|
|
module.exports = amdRequire;
|
|
|
|
|
|
|
|
|
|
|
|
/******/},
|
|
|
|
/******/
|
|
|
|
/******/5: function(module, exports, require) {
|
|
|
|
|
|
|
|
/*** (webpack)\buildin\__webpack_module.js ***/
|
|
|
|
|
|
|
|
module.exports = function(module) {
|
|
|
|
if(!module.webpackPolyfill) {
|
|
|
|
module.deprecate = function() {};
|
|
|
|
module.paths = [];
|
|
|
|
// module.parent = undefined by default
|
|
|
|
module.children = [];
|
|
|
|
module.webpackPolyfill = 1;
|
|
|
|
}
|
|
|
|
return module;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******/},
|
|
|
|
/******/
|
|
|
|
/******/6: function(module, exports, require) {
|
|
|
|
|
2012-10-26 21:07:50 +08:00
|
|
|
/*** (webpack)\buildin\__webpack_options_amd.loader.js!(webpack)\buildin\__webpack_options_amd.loader.js ***/
|
|
|
|
|
|
|
|
/* empty to return {} */
|
|
|
|
|
|
|
|
/******/},
|
|
|
|
/******/
|
|
|
|
/******/7: function(module, exports, require) {
|
|
|
|
|
2012-07-11 23:53:46 +08:00
|
|
|
/*** .\loader.js!.\file.js ***/
|
|
|
|
|
2012-04-05 21:08:49 +08:00
|
|
|
exports.answer = 42;
|
|
|
|
exports.foo = "bar";
|
2012-03-27 06:00:51 +08:00
|
|
|
|
2012-10-26 21:07:50 +08:00
|
|
|
/******/}
|
2012-03-27 06:00:51 +08:00
|
|
|
/******/})
|
|
|
|
```
|
|
|
|
|
2012-03-27 10:23:11 +08:00
|
|
|
# Console output
|
|
|
|
|
|
|
|
Prints in node.js (`node example.js`) and in browser:
|
|
|
|
|
|
|
|
```
|
|
|
|
{ answer: 42, foo: 'bar' }
|
|
|
|
{ foobar: 1234 }
|
|
|
|
{ foobar: 1234 }
|
|
|
|
```
|
|
|
|
|
2012-03-27 06:00:51 +08:00
|
|
|
# Info
|
|
|
|
|
|
|
|
## Uncompressed
|
|
|
|
|
|
|
|
```
|
2012-11-02 17:30:07 +08:00
|
|
|
Hash: 3d8baf386d1b33530021b2545124dfa5
|
|
|
|
Compile Time: 73ms
|
2012-03-27 06:00:51 +08:00
|
|
|
Chunks: 1
|
2012-10-26 21:07:50 +08:00
|
|
|
Modules: 8
|
|
|
|
Modules including duplicates: 8
|
|
|
|
Modules first chunk: 8
|
|
|
|
main output.js: 3927 chars/bytes
|
2012-04-08 03:36:55 +08:00
|
|
|
|
|
|
|
<id> <size> <filename>
|
|
|
|
<reason> from <filename>
|
2012-03-27 06:00:51 +08:00
|
|
|
output.js
|
2012-10-25 01:28:17 +08:00
|
|
|
0 324 .\example.js
|
2012-03-27 06:00:51 +08:00
|
|
|
main
|
2012-08-07 04:19:15 +08:00
|
|
|
1 516 (webpack)\buildin\__webpack_console.js
|
2012-04-05 20:59:01 +08:00
|
|
|
require (3x) from .\example.js
|
2012-05-07 03:07:24 +08:00
|
|
|
2 36 (webpack)\~\json-loader!.\test.json
|
2012-04-08 03:36:55 +08:00
|
|
|
require (1x) from .\example.js
|
2012-04-05 20:59:01 +08:00
|
|
|
require (1x) from .\example.js
|
2012-10-25 01:28:17 +08:00
|
|
|
3 184 C:\Users\Sokrates\Eigene Repos\~\enhanced-require\lib\require.webpack.js
|
|
|
|
require (1x) from .\example.js
|
2012-10-26 21:07:50 +08:00
|
|
|
4 518 (webpack)\buildin\__webpack_amd_require.js
|
2012-10-25 01:28:17 +08:00
|
|
|
require (1x) from C:\Users\Sokrates\Eigene Repos\~\enhanced-require\lib\require.webpack.js
|
|
|
|
5 251 (webpack)\buildin\__webpack_module.js
|
|
|
|
require (1x) from .\example.js
|
2012-10-26 21:07:50 +08:00
|
|
|
6 24 (webpack)\buildin\__webpack_options_amd.loader.js!(webpack)\buildin\__webpack_options_amd.loader.js
|
|
|
|
require (1x) from (webpack)\buildin\__webpack_amd_require.js
|
|
|
|
7 41 .\loader.js!.\file.js
|
2012-04-05 20:59:01 +08:00
|
|
|
require (1x) from .\example.js
|
2012-03-27 06:00:51 +08:00
|
|
|
```
|