example.js
var a = require("./a");
// get module id
var aId = require.resolve("./a.js");
// clear module in require.cache
delete require.cache[aId];
// require module again, it should be reexecuted
var a2 = require("./a");
// vertify it
if(a == a2) throw new Error("Cache clear failed :(");
a.js
module.exports = Math.random();
js/output.js
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function require(moduleId) {
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ exports: {},
/******/ id: moduleId,
/******/ loaded: false
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(null, module, module.exports, require);
/******/
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/ // The bundle contains no chunks. A empty chunk loading function.
/******/ require.e = function requireEnsure(_, callback) {
/******/ callback.call(null, require);
/******/ };
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ require.modules = modules;
/******/
/******/ // expose the module cache
/******/ require.cache = installedModules;
/******/
/******/
/******/ // Load entry module and return exports
/******/ return require(0);
/******/ })
/************************************************************************/
/******/ ({
/******/ // __webpack_public_path__
/******/ c: "",
/***/ 0:
/*!********************!*\
!*** ./example.js ***!
\********************/
/***/ function(module, exports, require) {
var a = require(/*! ./a */ 1);
// get module id
var aId = /*require.resolve*/(/*! ./a.js */ 1);
// clear module in require.cache
delete require.cache[aId];
// require module again, it should be reexecuted
var a2 = require(/*! ./a */ 1);
// vertify it
if(a == a2) throw new Error("Cache clear failed :(");
/***/ },
/***/ 1:
/*!**************!*\
!*** ./a.js ***!
\**************/
/***/ function(module, exports, require) {
module.exports = Math.random();
/***/ }
/******/ })
Info
Uncompressed
Hash: 995c10e31ea4676dccbdc20d8ed79bec
Version: webpack 0.10.0-beta6
Time: 30ms
Asset Size Chunks Chunk Names
output.js 2161 0 [emitted] main
chunk {0} output.js (main) 314 [rendered]
[0] ./example.js 283 [built] {0}
[1] ./a.js 31 [built] {0}
require.resolve ./a.js [0] ./example.js 4:10-35
cjs require ./a [0] ./example.js 1:8-22
cjs require ./a [0] ./example.js 10:9-23
Minimized (uglify-js, no zip)
Hash: 995c10e31ea4676dccbdc20d8ed79bec
Version: webpack 0.10.0-beta6
Time: 63ms
Asset Size Chunks Chunk Names
output.js 387 0 [emitted] main
chunk {0} output.js (main) 314 [rendered]
[0] ./example.js 283 [built] {0}
[1] ./a.js 31 [built] {0}
require.resolve ./a.js [0] ./example.js 4:10-35
cjs require ./a [0] ./example.js 1:8-22
cjs require ./a [0] ./example.js 10:9-23