var webpack = require('webpack');
var stealthyRequire = require('./index');
var newWebpack = stealthyRequire(require.cache, function () {
return require('webpack');
}, function () {
require('tough-cookie');
}, module);
Object.keys(require.cache).forEach(key => {
if (!require.cache[key]) {
// tough-cookies and it's dependencies undefined. But key is still there.
}
});
Hi
My project launched failed after request-promise update to v4.2.1. The error message indicates that require.cache got undefined with several keys when I try to iterate objects in
requird.cache.References:
request/request-promise@fdc522a
Because
tough-cookiehas not been required, tough-cookie does not exist inoriginalCache. It'll assign undefined with keys in themodulesToKeepon the next line.https://github.com/analog-nico/stealthy-require/blob/master/lib/index.js#L71
Example