{"_id":"webpack-clear-require-cache-plugin","_rev":"7-77f897e8ef75f383677edbd536bae466","time":{"0.0.1":"2020-10-21T13:51:53.666Z","0.0.2":"2020-10-21T13:51:53.666Z","0.0.3":"2020-10-21T13:51:53.666Z","0.0.4":"2020-10-21T13:51:53.666Z","created":"2020-10-22T14:20:37.393Z","0.0.5":"2020-10-22T14:20:37.505Z","modified":"2022-05-24T06:37:02.428Z"},"name":"webpack-clear-require-cache-plugin","dist-tags":{"latest":"0.0.5"},"versions":{"0.0.5":{"name":"webpack-clear-require-cache-plugin","version":"0.0.5","description":"clear require cache upon webpack compiler afterEmit hook","main":"lib/index.js","scripts":{"build":"babel src --out-dir lib","watch":"babel src --watch --out-dir lib","release":"npm run build && npm publish"},"keywords":["webpack","plugin","clear","require","cache"],"author":{"name":"maerzhase"},"license":"ISC","devDependencies":{"babel-cli":"^6.26.0","babel-core":"^6.26.3","babel-preset-env":"^1.7.0","babel-preset-stage-3":"^6.24.1"},"gitHead":"743da2c5ff9da11d40e46dee6b93c0fa9dbd15c5","_id":"webpack-clear-require-cache-plugin@0.0.5","_nodeVersion":"12.13.0","_npmVersion":"6.12.0","dist":{"integrity":"sha512-9k6C/lH2q3GvuhotpMAZTmovZFM8KJ4eV2SgJdtSASCga8LUL3ofQnaFxyhtPUAwflajhFTEuFANiBcbpImOtw==","shasum":"0348f5be216e6d8409488fbfb493c820a612fef0","tarball":"https://registry.npmjs.org/webpack-clear-require-cache-plugin/-/webpack-clear-require-cache-plugin-0.0.5.tgz","fileCount":5,"unpackedSize":4099,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfkZU1CRA9TVsSAnZWagAAFLcQAJ3pCPoZDLX7Z/rUvnKM\njF8ePLDxOwOBGBA82437n3hkA/c9NAjbtn7+bhapuyGrkotlcLy3VRTugYdU\ndFJd8ZFU/kIaCb5wxolG7NJN0PbO7anldhpqwo9XeJDIGz1W01J0VhsBx2Wq\nizBwiKPxWboqeRxjofup9Qz9wYpFffs0bTdWf8MRrJH154JqJbmVPjvwDeJg\nuthwPT6ZkA/HFAhyPF5W3kfe8t2NQYyMwBOuDZld7uiEr9rVPelOwRBKV2mF\nMMd3ipuHZP/WY3v8aU9fEjANEJKXfXWP33AWYc6SxshuH7VZ+xEDT4xtCRe/\n4KQJteR/jYl1u/PL12+7d6zis/3JOgON8klod7sik9kFOimXgSqTUvtt/hpn\nM/iOOnxO5UMzdXCLshp3peiUdcWFsAReDIb1MW5ufbaGIS0VfBy04sTStH7M\nlR87Lk67dyvJ8O5JE2EPERckSVCAUPV/adw63MiwZGBQQkCC2g3OAzPysQE+\nA0mdOk8iuZVto2QB6PTYFyLwsqdh7iuN2v5SHyzegaJ9nVeJTonY/dztKsOL\nHpouLogdw9zu7FSAA03MgCIkhTFtUEek8RAUATsCj2J0Zt9bcNqklpiWOknL\nVwF5kvReTLxRjTu6qzn2o4kGakcIRmFFhsxUz85t7p/X0aeu8uY4Yup9zC2v\nuLwo\r\n=OxYD\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCuXmB3B9jG6lMntJIXo1gO6nehJdWKB6Fnqz7kMTrcDgIhAJ7K/wl9KVMjMoCkzK+JGa9yHgkl+Lab1Aa8AaVqgN1u"}]},"maintainers":[{"name":"m3000","email":"markus@lili16.de"}],"_npmUser":{"name":"m3000","email":"markus@lili16.de"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/webpack-clear-require-cache-plugin_0.0.5_1603376437393_0.4230337050255586"},"_hasShrinkwrap":false}},"maintainers":[{"name":"m3000","email":"markus@lili16.de"}],"description":"clear require cache upon webpack compiler afterEmit hook","keywords":["webpack","plugin","clear","require","cache"],"author":{"name":"maerzhase"},"license":"ISC","readme":"# Webpack Clear Require Cache Plugin\n\nA plugin to delete modules from the `require.cache`. This is especially useful when working on shared modules inside another webpack project.\n\n- [Why use this?](#why-use-this)\n- [Usage](#usage)\n- [Next.js Example](#nextjs-example)\n\n\n## Why use this?\n\nIn larger projects it makes sense to develop parts of your application inside a separate module that has it's own build and release cycle. Npm provides the functionality to link your local module into the `node_modules` folder via `npm link`. Having all the fancy webpack hot-reloading stuff set-up, you might notice that changing your linked module triggers a reload on the webpack build but the module doesn't respect the changes. This happens because your module inside the `node_modules` folder will be loaded from the `require.cache`.\n\n## Usage\n\n```\nnpm install --save-dev webpack-clear-require-cache-plugin\n```\n\n\n```\nconst clearRequireCachePlugin = require('./clearRequireCachePlugin');\n\nmodule.exports = {\n  plugins: [\n    clearRequireCachePlugin([\n      /my-module/,\n    ]),\n  ],\n}\n```\n\nThe plugin accepts an array of regex's that will be tested on each `compiler.hooks.afterEmit`. It will test for each module inside `require.cache` and delete the module if the test returns `true`.\n\n\n## Next.js Example\n\nThe plugin is also compatible with `next-js`. When you have a linked module inside `node_modules` within a `next-js` project webpack will recognize the changes and trigger a reload but from now on client and server are out of sync, because the `client` will reload the changed module and the server will require from `require.cache`.\n\nIn order to achieve that the server reloades the updated module the `next.config.js` has to look somethign like this:\n\n```\nconst clearRequireCachePlugin = require('./clearRequireCachePlugin');\n\nexports.webpack = config =>\n  Object.assign(config, {\n    plugins: [\n      ...config.plugins,\n      clearRequireCachePlugin([\n        /\\.next\\/server\\/static\\/development\\/pages/,\n        /\\.next\\/server\\/ssr-module-cache.js/,\n        /my-module/, // replace this with your own module name\n      ]),\n    ],\n  });\n```\n\n##### NOTE: this is still a work in progress solution for an open issue https://github.com/zeit/next.js/issues/5463\n","readmeFilename":"README.md"}