{"_id":"@dkamyshov/webpack-hot-persist","_rev":"5-f7e74eeabd2bd9ed3d212c8ee1e46600","name":"@dkamyshov/webpack-hot-persist","dist-tags":{"beta":"0.1.0-beta.0","latest":"0.2.0"},"versions":{"0.1.0-beta.0":{"name":"@dkamyshov/webpack-hot-persist","version":"0.1.0-beta.0","description":"The persistence API for HMR in webpack.","license":"MIT","scripts":{"lint:prettier":"prettier -c \"**/*\"","lint:eslint":"eslint -c .eslintrc.js --ext .js,.ts . --color","prettier:fix":"prettier --write \"**/*\"","typecheck":"tsc --noEmit","test":"jest","build:esm":"tsc -p tsconfig.build.json","build:cjs":"tsc -p tsconfig.build.json --outDir ./lib/cjs --target ES3 --module commonjs --declaration false --declarationMap false","build":"yarn build:esm && yarn build:cjs","clean":"rm -rf lib","prepare":"yarn clean && yarn test && yarn build"},"devDependencies":{"@babel/plugin-transform-modules-commonjs":"^7.13.8","@babel/preset-typescript":"^7.13.0","@types/jest":"^26.0.22","@types/webpack-env":"^1.16.0","@typescript-eslint/eslint-plugin":"^4.19.0","@typescript-eslint/parser":"^4.19.0","eslint":"^7.23.0","jest":"^26.6.3","prettier":"^2.2.1","ts-jest":"^26.5.4","typescript":"^4.2.3"},"peerDependencies":{"@types/node":"*","@types/webpack-env":"*","webpack":"^4 || ^5"},"gitHead":"8fbcb3d80ed79e62729717cc7f04a6099d94afc4","_id":"@dkamyshov/webpack-hot-persist@0.1.0-beta.0","_nodeVersion":"14.16.0","_npmVersion":"6.14.11","dist":{"integrity":"sha512-s5bR+ILVSZzptGq55LRr4LOEOERzA+xE+78HH1HrUP5QsPoqpqZeO26WnfIlT3mFrOFzxKP7SwOwqmYW2OEk8g==","shasum":"9cf75f8d2c0495c6b5ee014a7a698e991fc89b79","tarball":"https://registry.npmjs.org/@dkamyshov/webpack-hot-persist/-/webpack-hot-persist-0.1.0-beta.0.tgz","fileCount":16,"unpackedSize":16789,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgYJiWCRA9TVsSAnZWagAAad4P/00GJoZ6Zq+zKrzwBY9M\nqjudzjacLsE+XfZuo4Ym7Mxxa3+6D+Veav8mZJQVh5vyRjS8tOFXULwEl29e\nCpz8iNzUAXrUf0QpgwPFvl8o2ZoU8XJo5RIOPIQgJABFdVEc+s+IMDa/bN9Z\nI1/kYoMDO8+t0OLJXG+YBoBUqXQ5bkAfa9uTAIHCshihahZ5oFgZrJw+txK4\nOuX1gCaBhSK1J1y6Rv/77QPu5saf/OEzuXEUqWShaEKsBYPCqD2NlyNoWDwo\n0YvV1zHhCZLQ6FwJEHfa7b9pHghdx5T20xGiJbpgWg1MoPFH/1cPlRi3R/LN\n9vhdAJt7IQw7Ql7JrXSMi0UGi49TnmZi/qoC887Y6YmEtBX78eManojf+PGY\nOFuajYxJXKkwFLL3P1+nbTdauIi2KLkEAo3ENWU1rcoOnQmSCryslu3qJ8LL\nQI8sAWqRazSoigleXMKKmgSbhjZEyV/+pP3WJJim7VBYkydJjB3ynYWZRSU+\nNL5Jvk4cdYmD373Vzf+Mzyda1euMbarUMAE755Nlmi3AyY80bliD7ALIzTea\nkrfTDu0j0MRSKz4l34MXNzEz3lo9T0fW+93UJHiBfd8a7FuloL2EAyNJp/A9\ny6YinPSr2KdB2imv4gkZd85jgGvrTOiLJ/b8/r5ZKD53FWNWyY2FqSNOlYWX\nl9d0\r\n=AYnt\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIG93/2BvluAvKGnAI2MNgX2eUuEBcHbi4czgOC9eVn8xAiBXVyDffigpwbegwk0U6Bz3/30F6leExxMVLABGc+fwTg=="}]},"_npmUser":{"name":"dkamyshov","email":"danil.kamyshov@gmail.com"},"directories":{},"maintainers":[{"name":"dkamyshov","email":"danil.kamyshov@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/webpack-hot-persist_0.1.0-beta.0_1616943253848_0.7756476280815239"},"_hasShrinkwrap":false,"deprecated":"This package has been superseded by @dkamyshov/hot-persist - https://www.npmjs.com/package/@dkamyshov/hot-persist"},"0.1.0":{"name":"@dkamyshov/webpack-hot-persist","version":"0.1.0","description":"The persistence API for HMR in webpack.","license":"MIT","scripts":{"lint:prettier":"prettier -c \"**/*\"","lint:eslint":"eslint -c .eslintrc.js --ext .js,.ts . --color","prettier:fix":"prettier --write \"**/*\"","typecheck":"tsc --noEmit","test":"jest","build:esm":"tsc -p tsconfig.build.json","build:cjs":"tsc -p tsconfig.build.json --outDir ./lib/cjs --target ES3 --module commonjs --declaration false --declarationMap false","build":"yarn build:esm && yarn build:cjs","clean":"rm -rf lib","prepare":"yarn clean && yarn test && yarn build"},"devDependencies":{"@babel/plugin-transform-modules-commonjs":"^7.13.8","@babel/preset-typescript":"^7.13.0","@types/jest":"^26.0.22","@types/webpack-env":"^1.16.0","@typescript-eslint/eslint-plugin":"^4.19.0","@typescript-eslint/parser":"^4.19.0","eslint":"^7.23.0","jest":"^26.6.3","prettier":"^2.2.1","ts-jest":"^26.5.4","typescript":"^4.2.3"},"peerDependencies":{"@types/node":"*","@types/webpack-env":"*","webpack":"^4 || ^5"},"gitHead":"707c96ecf5e2801599372e882f33af1214c74ab9","_id":"@dkamyshov/webpack-hot-persist@0.1.0","_nodeVersion":"14.16.0","_npmVersion":"6.14.11","dist":{"integrity":"sha512-OnfJJ3IOkO8RhnRa7ZR96HmuVHxNwG2nm+OWs7bv0WfvhNUw/4BGkw+mVvCBvyMvBJ1DfqLHYhloRivg41cYiQ==","shasum":"d2e43ecb357cee770c3f1badc244413e6e3850f9","tarball":"https://registry.npmjs.org/@dkamyshov/webpack-hot-persist/-/webpack-hot-persist-0.1.0.tgz","fileCount":14,"unpackedSize":10935,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgYJ0KCRA9TVsSAnZWagAA0nAQAJGiFOn/SPEj1Tj3Alfu\noej4Q04D6vrdd1XhuqkHDJpmdXvaBL4MqxpaKcnbParmCauOZbuSzhHBgwLB\nqgOINHmlt2xQAW5dJoxJrpdm3XR+3t+MyasLXEmkLF7+y7rQYwwlTgcsqcb7\n4Jr5AFKsMoN1MVcDDKaw1H7M+xF4FEEobgLgqIesGQjamrYYAo+eNiUdck9W\nEmJLivzKRub9EV0iYCLKCjSvQJy1PvYKtLwea/YVBNRqpZ7jz0wdMxritFwv\nxk02ZOvmlZzz3GES6TZwdZtxm7taYZ7xaYzIcDuOCMU1EuzsSUAblRjhQQ+/\nUCqocXw5u5JHnK8lyFu1Uby5CAO4QRK+yiS1Bn/XYvrUT4ELcrIX8xCGhuWT\nTca4mc8jE+cKqRw/36eWzbcgYVIdncALHATB7BK4pl+XggAKbHSNZ7/nQNRJ\nRgDAqf458p+HROuv+zG1tTW7NDpFlhFTeyxfxjYvNXEeqcWsvmREpZKdOej5\nRtfXq4sSiGyRwq8bVTE5HiEum50sVHLwCUcwumC+BTM9oCoC2A5itnLyWYBA\n3osvcebQwmLETgfnAwlAp9G03QEJ34Gy+CUwk84uPeNGPB0YNJxADwO6TFBO\nzKVVMd5b09c+Xo/xO5W53HgKapKgX97JkvsuSFHUQ85pwhd0jRGJf+JPTBWo\nEOV0\r\n=MVpn\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFONVU9v7yt0ng/CGYkwhY1mbZBIQVjNx0FSoUfut43XAiADkNU2bSXcK2nA5QRb4PlWCnsN0PYjTUby+E7GGDw41Q=="}]},"_npmUser":{"name":"dkamyshov","email":"danil.kamyshov@gmail.com"},"directories":{},"maintainers":[{"name":"dkamyshov","email":"danil.kamyshov@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/webpack-hot-persist_0.1.0_1616944394147_0.31673491542027254"},"_hasShrinkwrap":false,"deprecated":"This package has been superseded by @dkamyshov/hot-persist - https://www.npmjs.com/package/@dkamyshov/hot-persist"},"0.2.0":{"name":"@dkamyshov/webpack-hot-persist","version":"0.2.0","description":"The persistence API for HMR in webpack.","license":"MIT","engines":{"node":">=0.12.0"},"scripts":{"lint:prettier":"prettier -c \"**/*\"","lint:eslint":"eslint -c .eslintrc.js --ext .js,.ts . --color","prettier:fix":"prettier --write \"**/*\"","typecheck":"tsc --noEmit","test":"jest","build:esm":"tsc -p tsconfig.build.json","build:cjs":"tsc -p tsconfig.build.json --outDir ./lib/cjs --target ES3 --module commonjs --declaration false --declarationMap false","build":"yarn build:esm && yarn build:cjs","clean":"rm -rf lib","prepare":"yarn clean && yarn test && yarn build"},"devDependencies":{"@babel/plugin-transform-modules-commonjs":"^7.13.8","@babel/preset-typescript":"^7.13.0","@types/jest":"^26.0.22","@types/webpack-env":"^1.16.0","@typescript-eslint/eslint-plugin":"^4.19.0","@typescript-eslint/parser":"^4.19.0","eslint":"^7.23.0","jest":"^26.6.3","prettier":"^2.2.1","ts-jest":"^26.5.4","typescript":"^4.2.3"},"peerDependencies":{"@types/node":"*","@types/webpack-env":"*","webpack":"^4 || ^5"},"gitHead":"bf00f2d99e74a167806e76867accf8f860c22116","_id":"@dkamyshov/webpack-hot-persist@0.2.0","_nodeVersion":"14.17.0","_npmVersion":"6.14.13","dist":{"integrity":"sha512-/a0C7MoEL8x+VVAeTIEzG18+WGEdDvfFrAZugQWIVEQ8w6MXfY1w8UBJvTrEdW7akwlnbFsWYsGHFp0yumcR4A==","shasum":"67084052d2ddfb66c18c4a354a85cc04dfd1a28e","tarball":"https://registry.npmjs.org/@dkamyshov/webpack-hot-persist/-/webpack-hot-persist-0.2.0.tgz","fileCount":19,"unpackedSize":14725,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg3wTbCRA9TVsSAnZWagAAV/IP/299rPnRiUAQa5MB/HCI\nSxeRS3iPFV/2Z6+FW4BWzOh3nXNjbQbLbKU0Q839wMIsrZ5VSXlWNBuMG1LG\nIG6Gc7YDsCN73P7jLD39NgksV/97ixH06VAzc+N6YnlikiIYIPqwnzU2IPHw\nTFkuzCHdr65+WBMtDO0Mzs5QKcKDQpKU6vkTSpEtw0Vef16OpiFCtxb/ByAv\nAAGk+PtI2OiyxiAfkC5VMA+327/XQ5fkvcVTyubITx4pu1B11xWFk36wYEoG\nHXiFm/aGPadE0v2V0V93B3BJQEVRt/gSnn3CXmMTzrTOisaYa6gFSaTxMxIM\npvuOi4ZWjnoKx2vT6n1b5SSTyGu0/rxY43uF3TwElX0SFBX+3k+ruCdVtIfk\nhqYSPYA0ycNxLpsj1PkdD0LrhniA80yG374xDZ78mkH3quHISII+1kNsOfPr\nlFf5Eqp8lDG8CYunfR6KRMwNMMoftm+6JapNm3kUSKYoN5t2CFfQ542TlNSx\nlQ2Co1JKIAi+wcCsYFOY36eQ1SbvPF7I5SVKm7UjxfiqHo4UJEH6PY37CXOm\n9oB8FHtb0igazJ6l4CiGZBuBet096k3iOZkVQuz3OSKaR0IrlycAlNFdzbVW\naFvdnpr+KMd/CCrdSWXd5jzGJ5ZUgRT3Zr1pT1Z9CWdVfLQEHgbXHSZox//l\nWc96\r\n=ui0f\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCpJsBY7Js2IArOJjtCxyoNzBxA15v+mepURLvEd8VpnwIhAIrV/Zp8Yy65xOal+EU5XpDKJ5j7Q9qbvYxrYC4rASrS"}]},"_npmUser":{"name":"dkamyshov","email":"danil.kamyshov@gmail.com"},"directories":{},"maintainers":[{"name":"dkamyshov","email":"danil.kamyshov@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/webpack-hot-persist_0.2.0_1625228506716_0.5757780643054824"},"_hasShrinkwrap":false,"deprecated":"This package has been superseded by @dkamyshov/hot-persist - https://www.npmjs.com/package/@dkamyshov/hot-persist"}},"time":{"created":"2021-03-28T14:54:13.801Z","0.1.0-beta.0":"2021-03-28T14:54:14.010Z","modified":"2023-01-29T19:06:17.250Z","0.1.0":"2021-03-28T15:13:14.299Z","0.2.0":"2021-07-02T12:21:46.837Z"},"maintainers":[{"name":"dkamyshov","email":"danil.kamyshov@gmail.com"}],"description":"The persistence API for HMR in webpack.","license":"MIT","readme":"# @dkamyshov/webpack-hot-persist\n\nDead simple persistence API for preserving data across hot reloads in webpack. Zero dependencies!\n\n## Installation\n\n```sh\n$ yarn add -D @dkamyshov/webpack-hot-persist\n```\n\nNote: if you use TypeScript, you should also install `@types/webpack-env` and `@types/node`. Or you may want to disable type checking of declaration files altogether: https://www.typescriptlang.org/tsconfig#skipLibCheck.\n\n## Usage\n\n```js\nimport { persist } from '@dkamyshov/webpack-hot-persist';\n\nconst instance = persist(module)(() => {\n  return {\n    /* ... */\n  };\n});\n\nif (module.hot) {\n  module.hot.accept();\n}\n```\n\nThe `persist` function accepts the current module and then returns a new function that accepts 3 parameters:\n\n1. The `factory` function that returns the instance.\n2. The optional `dependencies` parameter, which is used to decide whether the instance should be recreated.\n\n   This works pretty much like React hooks' `dependencies` (it requires referential equality) with a slight difference: if the `dependencies` are not specified, the instance is never updated (unlike in React, where it means \"update on each run\").\n\n3. The optional `options` parameter.\n\n   1. `options.key` - the optional string key which is used to distinguish between multiple instances in a single module.\n   2. `options.cleanup` - the optional callback which is invoked if the instance is updated. The old instance is passed to the callback.\n\n   Instead of passing an object, you may pass a string here. The string will be treated as `options.key`.\n\n   If the `key` is not specified, the `persist` function automatically infers it based on the order of calls (much like hooks in React):\n\n   ```js\n   const a = persist(module)(() => ({})); // `key` is `0`\n   const b = persist(module)(() => ({})); // `key` is `1`\n   const c = persist(module)(() => ({})); // `key` is `2`\n   ```\n\nNote: in production (NODE_ENV === 'production') the `persist` function immediately calls `factory` and returns with the new result on each run. The same happens when HMR is not enabled.\n\n## Examples\n\n```js\nimport { persist } from '@dkamyshov/webpack-hot-persist';\n\n// Example 1. This instance never updates.\nconst value = persist(module)(() => {\n  return {\n    value: 0,\n  };\n});\n\n// Example 2. Same as above.\nconst value = persist(module)(() => {\n  return {\n    value: 0,\n  };\n}, []);\n\n// Example 3. The connection will be recreated\n// when the URL changes.\n\n// constants.js\nexport const URL = 'ws://localhost:8080/chat';\n\n// index.js\nimport { URL } from './constants';\n\nconst socket = persist(module)(() => new WebSocket(URL), [URL], {\n  cleanup: (socket) => {\n    socket.close();\n  },\n});\n\n// Example 4. The dependencies may be cascaded.\n// If `add.js` is updated, both `b` and `c` are\n// recreated. If `multiply.js` is updated, only `c`\n// is recreated.\n\n// add.js\nexport const add = (a, b) => a + b;\n\n// multiply.js\nexport const multiply = (a, b) => a * b;\n\n// index.js\nimport { add } from './add';\nimport { multiply } from './multiply';\n\nconst a = persist(module)(() => {\n  return { value: 0 };\n});\n\nconst b = persist(module)(() => {\n  return { value: add(a.value, 1) };\n}, [add, a]);\n\nconst c = persist(module)(() => {\n  return { value: multiply(b.value, 2) };\n}, [multiply, b]);\n```\n","readmeFilename":"README.md"}