{"_id":"babel-plugin-explicit-exports-references","_rev":"3-6d7fd1972ce9da7d6498c591901dd1a3","name":"babel-plugin-explicit-exports-references","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.0":{"name":"babel-plugin-explicit-exports-references","version":"1.0.0","description":"Transforms all internal references to a module's exports such that each reference starts with `module.exports` instead of directly referencing an internal name. This enables easy mocking of specific (exported) functions in Jest with Babel/TypeScript, even","keywords":["babel","rewire","jest","function","mock","spy","exported","single","same","module","functions","import","require","specific","test","typescript"],"repository":{"type":"git","url":"git+https://github.com/Xunnamius/babel-plugin-explicit-exports-references.git"},"license":"Unlicense","author":{"name":"Xunnamius"},"sideEffects":false,"type":"commonjs","exports":{".":"./dist/index.js","./package":"./package.json","./package.json":"./package.json"},"main":"./dist/index","types":"./dist/index.d.ts","scripts":{"build":"npm run clean && tsc --project tsconfig.types.json && NODE_ENV=production webpack --config-name main","build-stats":"NODE_ENV=production webpack --config-name main --json > bundle-stats.json","check-types":"rm -f npm.pipe; touch npm.pipe; command -v unbuffer >/dev/null; X=$?; [ $X -eq 0 ] && unbuffer tsc --project tsconfig.check-types.json >> npm.pipe; Y=$?; [ $Y -eq 0 ] && echo >> npm.pipe; unbuffer eslint --parser-options=project:tsconfig.check-types.json src >> npm.pipe; Z=$?; [ $X -ne 0 ] && tsc --project tsconfig.check-types.json >> npm.pipe && eslint --parser-options=project:tsconfig.check-types.json src >> npm.pipe; W=$?; cat npm.pipe | less -R -FX; rm npm.pipe; [ $W -eq 0 ] && [ $X -eq 1 ] || [ $X -eq 0 ] && [ $Y -eq 0 ] && [ $Z -eq 0 ]","clean":"rm -rf dist npm.pipe coverage external-scripts/bin","fixup":"npm run check-types && npm run test && npx npm-force-resolutions && npx Xunnamius/sort-package-json && npm audit","list-tasks":"npm run","prepublishOnly":"npm run build","postpublish":"npm run clean","repl":"command -v rlwrap >/dev/null && rlwrap npx -p @babel/core -p @babel/node babel-node","test":"BABEL_ENV=test jest --coverage"},"dependencies":{"@babel/core":"^7.13.15","@babel/template":"^7.12.13","@babel/types":"^7.13.14","debug":"^4.3.1"},"devDependencies":{"@babel/cli":"^7.13.14","@babel/eslint-parser":"^7.13.14","@babel/plugin-proposal-export-default-from":"^7.12.13","@babel/plugin-proposal-function-bind":"^7.12.13","@babel/plugin-syntax-module-string-names":"^7.12.13","@babel/preset-env":"^7.13.15","@babel/preset-typescript":"^7.13.0","@types/babel-types":"^7.0.9","@types/babel__core":"^7.1.14","@types/debug":"^4.1.5","@types/jest":"^26.0.22","@types/node":"^14.14.39","@typescript-eslint/eslint-plugin":"^4.22.0","@typescript-eslint/parser":"^4.22.0","babel-jest":"^26.6.3","babel-loader":"^8.2.2","babel-plugin-source-map-support":"^2.1.3","babel-plugin-tester":"^10.0.0","eslint":"^7.24.0","eslint-import-resolver-alias":"^1.1.2","eslint-import-resolver-typescript":"^2.4.0","eslint-plugin-import":"^2.22.1","eslint-plugin-jest":"^24.3.5","jest":"^26.6.3","jest-circus":"^26.6.3","jest-extended":"^0.11.5","prettier":"^2.2.1","source-map-support":"^0.5.19","typescript":"^4.2.4","webpack":"^5.33.2","webpack-cli":"^4.6.0","webpack-node-externals":"^2.5.2"},"engines":{"node":">= 12.x"},"publishConfig":{"access":"public"},"gitHead":"a2316d12d2aeece26264c6054a8f8ae223856c38","bugs":{"url":"https://github.com/Xunnamius/babel-plugin-explicit-exports-references/issues"},"homepage":"https://github.com/Xunnamius/babel-plugin-explicit-exports-references#readme","_id":"babel-plugin-explicit-exports-references@1.0.0","_nodeVersion":"15.14.0","_npmVersion":"7.9.0","dist":{"integrity":"sha512-y1YjAPXgwfCWKWXrCsXrCfKTSJYJqXH+7Zo/J9lvqndh6RQ75YoqOb4269Nlh51atcsji27xMAt23Y21Y7SYXA==","shasum":"4e06320206c13ec210b4c9fefc0a05321bbb54f3","tarball":"https://registry.npmjs.org/babel-plugin-explicit-exports-references/-/babel-plugin-explicit-exports-references-1.0.0.tgz","fileCount":6,"unpackedSize":12568,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgezJxCRA9TVsSAnZWagAAQ28P/ikmB8GPDxQfD0UPQ87S\nEhHeyIXsgPG/RZi+edB4zPTasOx42inAcJ/yTpI7wUaC2WN6x/0gHF7rk6KN\nXxT1IFV6H+PIepm+34SlDV2AqHN0cscUbNC7bh5BrzzksnG5y3Qui3558QBK\n6Y4PPUgccBPnIrrfHCCEB9n/loU/PsqooGLNEAthui3DJCoodSHAZafNqIrw\nU3mLUKuwkASRNaMCsXaMwXnnOxXVOIbSU5cbmeqaOvqOKpqpX0axCZzrA5Ca\nm3GLPiC76Mmwk9u7ECl+y4MnH6GaN10c9gvqQxG557LMg96+WiK/WDk6+pnv\nDketHLnHUOEA2gIRRuwJHBvHvVkbZzjUj679E7UnER7wLjW8vshe/Fn1Q9Vp\n2RyNJPjzXvB7kyceuXxeN3fPiwJT4xWmt+hPSTxog0X78I/PktVIgSiqGf8d\nq+hIbJ5AMWX9p9XX/3u56ELeY4coFF7J5eDWCvL8VjkDcPDyWcscHTlymMnC\nynMznttjYY+FmgtCUrh93BiqHMWb/7KFTwIRvnKtOi9NlR/lq93Id/sHH0X4\nqg5wCNA0W/IS74DWjOeIGckL7F2O8fc61fmmdM3UKb+uoWRyR4Zg9az7lDPn\nzgbh99cpm9+t32kCLYvp1dAg02evyKoncutc+FTNTO8JNjrieSqV5RMSBaof\nGttV\r\n=YotV\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCANqHtKFXG2jSGXCp5PLTWUtFJxSXR0ZKfMM3S4HxXAQIhANqLE0DY8nM8vrgq+8exVt8xJ2yjHk28I5twihlpdlpJ"}]},"_npmUser":{"name":"xunnamius","email":"git@ergodark.com"},"directories":{},"maintainers":[{"name":"xunnamius","email":"git@ergodark.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/babel-plugin-explicit-exports-references_1.0.0_1618686577496_0.8786633539562558"},"_hasShrinkwrap":false},"1.0.1":{"name":"babel-plugin-explicit-exports-references","version":"1.0.1","description":"Transforms all internal references to a module's exports such that each reference starts with `module.exports` instead of directly referencing an internal name. This enables easy mocking of specific (exported) functions in Jest with Babel/TypeScript, even","keywords":["babel","rewire","jest","function","mock","spy","exported","single","same","module","functions","import","require","specific","test","typescript"],"repository":{"type":"git","url":"git+https://github.com/Xunnamius/babel-plugin-explicit-exports-references.git"},"license":"Unlicense","author":{"name":"Xunnamius"},"sideEffects":false,"type":"commonjs","exports":{".":"./dist/index.js","./package":"./package.json","./package.json":"./package.json"},"main":"./dist/index","types":"./dist/index.d.ts","scripts":{"build":"npm run clean && tsc --project tsconfig.types.json && NODE_ENV=production webpack --config-name main","build-stats":"NODE_ENV=production webpack --config-name main --json > bundle-stats.json","check-types":"rm -f npm.pipe; touch npm.pipe; command -v unbuffer >/dev/null; X=$?; [ $X -eq 0 ] && unbuffer tsc --project tsconfig.check-types.json >> npm.pipe; Y=$?; [ $Y -eq 0 ] && echo >> npm.pipe; unbuffer eslint --parser-options=project:tsconfig.check-types.json src >> npm.pipe; Z=$?; [ $X -ne 0 ] && tsc --project tsconfig.check-types.json >> npm.pipe && eslint --parser-options=project:tsconfig.check-types.json src >> npm.pipe; W=$?; cat npm.pipe | less -R -FX; rm npm.pipe; [ $W -eq 0 ] && [ $X -eq 1 ] || [ $X -eq 0 ] && [ $Y -eq 0 ] && [ $Z -eq 0 ]","clean":"rm -rf dist npm.pipe coverage external-scripts/bin","fixup":"npm run check-types && npm run test && npx npm-force-resolutions && npx Xunnamius/sort-package-json && npm audit","list-tasks":"npm run","prepublishOnly":"npm run build","postpublish":"npm run clean","repl":"command -v rlwrap >/dev/null && rlwrap npx -p @babel/core -p @babel/node babel-node","test":"BABEL_ENV=test jest --coverage"},"dependencies":{"@babel/core":"^7.13.15","@babel/template":"^7.12.13","@babel/types":"^7.13.14","debug":"^4.3.1"},"devDependencies":{"@babel/cli":"^7.13.14","@babel/eslint-parser":"^7.13.14","@babel/plugin-proposal-export-default-from":"^7.12.13","@babel/plugin-proposal-function-bind":"^7.12.13","@babel/plugin-syntax-module-string-names":"^7.12.13","@babel/preset-env":"^7.13.15","@babel/preset-typescript":"^7.13.0","@types/babel-types":"^7.0.9","@types/babel__core":"^7.1.14","@types/debug":"^4.1.5","@types/jest":"^26.0.22","@types/node":"^14.14.39","@typescript-eslint/eslint-plugin":"^4.22.0","@typescript-eslint/parser":"^4.22.0","babel-jest":"^26.6.3","babel-loader":"^8.2.2","babel-plugin-source-map-support":"^2.1.3","babel-plugin-tester":"^10.0.0","eslint":"^7.24.0","eslint-import-resolver-alias":"^1.1.2","eslint-import-resolver-typescript":"^2.4.0","eslint-plugin-import":"^2.22.1","eslint-plugin-jest":"^24.3.5","jest":"^26.6.3","jest-circus":"^26.6.3","jest-extended":"^0.11.5","prettier":"^2.2.1","source-map-support":"^0.5.19","typescript":"^4.2.4","webpack":"^5.33.2","webpack-cli":"^4.6.0","webpack-node-externals":"^2.5.2"},"engines":{"node":">= 12.x"},"publishConfig":{"access":"public"},"gitHead":"43db6d94d56e5f5a88f685b138fef8863c8dac91","bugs":{"url":"https://github.com/Xunnamius/babel-plugin-explicit-exports-references/issues"},"homepage":"https://github.com/Xunnamius/babel-plugin-explicit-exports-references#readme","_id":"babel-plugin-explicit-exports-references@1.0.1","_nodeVersion":"15.14.0","_npmVersion":"7.9.0","dist":{"integrity":"sha512-BkwcY/gZ/VesW5Iih8X4EgAs/4jaWwSNXdWe/0JPSdMYmLMN/bxO+fsUaLUgcks4pOMtWbHjlTVU7/TlKjVSCA==","shasum":"6c21cd201eed8210e40845b0bc8308f7c39f8a8f","tarball":"https://registry.npmjs.org/babel-plugin-explicit-exports-references/-/babel-plugin-explicit-exports-references-1.0.1.tgz","fileCount":6,"unpackedSize":19423,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgjLsiCRA9TVsSAnZWagAAAycP/R6jOBYQbBgZNtXRUs1N\npNEuERgaYzibkfDKV5fGWe9jTluE9VbpueQ+coPDM3S/UoATvRi4v5P1etW+\nORMLqM2uKgODJ+Higv21lDC2dqs6btkvjBzTJGXHK6cOQkgpCrA5z3j0CGZN\nwQ8DlHTb9lbv2Q6WA3dvXlLaDJhEyQrDb1hz7P31jx38TIUFZGMtMS9sGW8L\nkxxNE9xZf5yG8lrH/jH5be8bBRPpNiaqcz7FRq1m6IHOW5WDQD0pdVZ783/i\ncCVQ0+F4lygCcrI024bZ2Q0sAdvhgihwRtlMfbjS0ot/Ie9ZVqEBGoGtlDcY\nV76v9bAAJAM1VCy3vFCrFkqKMVlsPQunqhrtRDfqMH4b45cpEExvLShKUJ+Z\nkBT7bmJgH9TumcBxqAzBwRmnscKEOs+Iam4FPkoMllHO4up7dSjRJvB5Rbid\nUnjF0pViIys5o4Vq/uuxFuDsTi39Pna8U3JHWdwRIzqIGNRrEWlfs/aC8n/p\nXa6NgATEU7xiCVbqNC4EKsDb+Zl8IpjsdvY03lVf6/5WW62KD6eWAamX40cf\nctYEpLNI7rdfoKv0WD2gj47iPi3fvs0TRNF/jptv2OUa9+bqLfkTz4rNUiFv\nSqyKqnngT+RdUjzJEmTi/3R8LLgmRvkQgSVyYmRjEliq9X1tunkSFTLXl9Hx\ne9Af\r\n=/UGb\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD6gql7YgXLbsqi8WM/HXwdOTV+RSSrnM364usXUmDDVwIgK1MU6eGAZ1WjQORB7PHdmJypPNOT2h++1zPzlxT61g0="}]},"_npmUser":{"name":"xunnamius","email":"git@ergodark.com"},"directories":{},"maintainers":[{"name":"xunnamius","email":"git@ergodark.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/babel-plugin-explicit-exports-references_1.0.1_1619835681546_0.022075874794849293"},"_hasShrinkwrap":false},"1.0.2":{"name":"babel-plugin-explicit-exports-references","version":"1.0.2","description":"Transforms all internal references to a module's exports such that each reference starts with `module.exports` instead of directly referencing an internal name. This enables easy mocking of specific (exported) functions in Jest with Babel/TypeScript, even","keywords":["babel","rewire","jest","function","mock","spy","exported","single","same","module","functions","import","require","specific","test","typescript"],"repository":{"type":"git","url":"git+https://github.com/Xunnamius/babel-plugin-explicit-exports-references.git"},"license":"MIT","author":{"name":"Xunnamius"},"sideEffects":false,"type":"commonjs","exports":{".":"./dist/index.js","./package":"./package.json","./package.json":"./package.json"},"main":"./dist/index","types":"./dist/index.d.ts","scripts":{"build":"npm run clean && tsc --project tsconfig.types.json && NODE_ENV=production webpack --config-name main","build-stats":"NODE_ENV=production webpack --config-name main --json > bundle-stats.json","check-types":"rm -f npm.pipe; touch npm.pipe; command -v unbuffer >/dev/null; X=$?; [ $X -eq 0 ] && unbuffer tsc --project tsconfig.check-types.json >> npm.pipe; Y=$?; [ $Y -eq 0 ] && echo >> npm.pipe; unbuffer eslint --parser-options=project:tsconfig.check-types.json src >> npm.pipe; Z=$?; [ $X -ne 0 ] && tsc --project tsconfig.check-types.json >> npm.pipe && eslint --parser-options=project:tsconfig.check-types.json src >> npm.pipe; W=$?; cat npm.pipe | less -R -FX; rm npm.pipe; [ $W -eq 0 ] && [ $X -eq 1 ] || [ $X -eq 0 ] && [ $Y -eq 0 ] && [ $Z -eq 0 ]","clean":"rm -rf dist npm.pipe coverage external-scripts/bin","fixup":"npm run check-types && npm run test && npx npm-force-resolutions && npx Xunnamius/sort-package-json && npm audit","list-tasks":"npm run","prepublishOnly":"npm run build","postpublish":"npm run clean","repl":"command -v rlwrap >/dev/null && rlwrap npx -p @babel/core -p @babel/node babel-node","test":"BABEL_ENV=test jest --coverage"},"dependencies":{"@babel/core":"^7.13.15","@babel/template":"^7.12.13","@babel/types":"^7.13.14","debug":"^4.3.1"},"devDependencies":{"@babel/cli":"^7.13.14","@babel/eslint-parser":"^7.13.14","@babel/plugin-proposal-export-default-from":"^7.12.13","@babel/plugin-proposal-function-bind":"^7.12.13","@babel/plugin-syntax-module-string-names":"^7.12.13","@babel/preset-env":"^7.13.15","@babel/preset-typescript":"^7.13.0","@types/babel-types":"^7.0.9","@types/babel__core":"^7.1.14","@types/debug":"^4.1.5","@types/jest":"^26.0.22","@types/node":"^14.14.39","@typescript-eslint/eslint-plugin":"^4.22.0","@typescript-eslint/parser":"^4.22.0","babel-jest":"^26.6.3","babel-loader":"^8.2.2","babel-plugin-source-map-support":"^2.1.3","babel-plugin-tester":"^10.0.0","eslint":"^7.24.0","eslint-import-resolver-alias":"^1.1.2","eslint-import-resolver-typescript":"^2.4.0","eslint-plugin-import":"^2.22.1","eslint-plugin-jest":"^24.3.5","jest":"^26.6.3","jest-circus":"^26.6.3","jest-extended":"^0.11.5","prettier":"^2.2.1","source-map-support":"^0.5.19","typescript":"^4.2.4","webpack":"^5.33.2","webpack-cli":"^4.6.0","webpack-node-externals":"^2.5.2"},"engines":{"node":">= 12.x"},"publishConfig":{"access":"public"},"gitHead":"31817864265c9e00bfdc9f1ceedf895b14b8ebef","bugs":{"url":"https://github.com/Xunnamius/babel-plugin-explicit-exports-references/issues"},"homepage":"https://github.com/Xunnamius/babel-plugin-explicit-exports-references#readme","_id":"babel-plugin-explicit-exports-references@1.0.2","_nodeVersion":"17.3.0","_npmVersion":"8.3.0","dist":{"integrity":"sha512-z+weAyF11Mr1azXIR5pfhAeXeK8ZvacXSKgPLGdwBoR7efyqnUxYvlGUny7eHZxAO/Q1C2O1+xO9lwgGPDaBlw==","shasum":"47102fcb5c97f5d54dcc03a99685d90c2ab564cf","tarball":"https://registry.npmjs.org/babel-plugin-explicit-exports-references/-/babel-plugin-explicit-exports-references-1.0.2.tgz","fileCount":5,"unpackedSize":19172,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh03G2CRA9TVsSAnZWagAAxi4P/3us+x6PCb45S9xibdZ3\nLgPTAE9SZELYuQ88l6mmhYXlqBmh2/h0YCUpslif1hyx4eb4ZI3zoO7xp0Rz\nnNqBswIwwA366tLpk0jCiLbL0qrjMyMxgcWclRVkxrZocKvPRG4/2THCtdUM\nmoacFS2IrwJPpI+K7waoTzLP53Dxd5hvSI/f5lS/MEXmgiS82GtcU1dRbvDd\nW4SfEx5p/3Ks1fJZQSZuH/EqTaMnC37MyJ05IlCgPQsGyUiKBiY91iNLxhVy\n6z2mm7MkEVTg6EAcpwuwHhxB06TcXnsPatWkrMpVIln/HRyPhAOnpZpXJMlP\nrqREx8aGtrdg0IWDcBKN/2Sj/p+bWIU5Ft/XalS4P4Wx9yZT72E1qvErQ2Ki\n/8UZho+UL44dLQl7fVKA+wZijj1Tl/qGCTu9E5U8NDf1zRs4QR8szfChsnJ0\ntpgCOV1eSqWZasmdYZl/+ci8lvT2SI7z7a3L+qoruFUCHhvoTMN21y/8JTPP\nKB5AtWiEfEQH5Uhsi5YNERV40AsGY9iL18llDBkNSKNb6sPfu3zP545xg/w2\nsPh0D/cCuhgCx6thuQScgl6B4e0q8UZz8BAO36qFxEuvwZSdmpDwb0xaSYo1\nz7xQ2Qqiry2Dnetpvrqz+3gmzVMYy7LKT4eolE4JShubPELDxQnyy+XhFhxz\nDKS0\r\n=+lVc\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDFdhD7wOpvgqpGi1ud12vghw3kwlVG3/lHnoTnX2ahtAiBek3j0IukOJmg1QkDqmQKkNuJ/A0hLkxfmAtOGexQnvw=="}]},"_npmUser":{"name":"xunnamius","email":"git@bernarddickens.dev"},"directories":{},"maintainers":[{"name":"xunnamius","email":"git@bernarddickens.dev"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/babel-plugin-explicit-exports-references_1.0.2_1641247158622_0.28026320928216"},"_hasShrinkwrap":false}},"time":{"created":"2021-04-17T19:09:37.453Z","1.0.0":"2021-04-17T19:09:37.593Z","modified":"2022-04-11T16:38:28.854Z","1.0.1":"2021-05-01T02:21:21.682Z","1.0.2":"2022-01-03T21:59:18.799Z"},"maintainers":[{"name":"xunnamius","email":"git@bernarddickens.dev"}],"description":"Transforms all internal references to a module's exports such that each reference starts with `module.exports` instead of directly referencing an internal name. This enables easy mocking of specific (exported) functions in Jest with Babel/TypeScript, even","homepage":"https://github.com/Xunnamius/babel-plugin-explicit-exports-references#readme","keywords":["babel","rewire","jest","function","mock","spy","exported","single","same","module","functions","import","require","specific","test","typescript"],"repository":{"type":"git","url":"git+https://github.com/Xunnamius/babel-plugin-explicit-exports-references.git"},"author":{"name":"Xunnamius"},"bugs":{"url":"https://github.com/Xunnamius/babel-plugin-explicit-exports-references/issues"},"license":"MIT","readme":"<!-- prettier-ignore-start -->\n\n<!-- badges-start -->\n\n[![Black Lives Matter!][badge-blm]][link-blm]\n[![Maintenance status][badge-maintenance]][link-repo]\n[![Last commit timestamp][badge-last-commit]][link-repo]\n[![Open issues][badge-issues]][link-issues]\n[![Pull requests][badge-pulls]][link-pulls]\n[![codecov][badge-codecov]][link-codecov]\n[![Source license][badge-license]][link-license]\n[![NPM version][badge-npm]][link-npm]\n[![semantic-release][badge-semantic-release]][link-semantic-release]\n\n<!-- badges-end -->\n\n<!-- prettier-ignore-end -->\n\n# babel-plugin-explicit-exports-references\n\nTransforms all internal references to a module's exports such that each\nreference starts with `module.exports` instead of directly referencing an\ninternal name. This enables easy mocking of specific (exported) functions in\nJest with Babel/TypeScript, even when the mocked functions call each other in\nthe same module.\n\n## Installation and Usage\n\n```Bash\nnpm install --save-dev babel-plugin-explicit-exports-references\n```\n\nAnd in your `babel.config.js`:\n\n```typescript\nmodule.exports = {\n  plugins: ['explicit-exports-references']\n};\n```\n\n**Note**: it is recommended that this plugin only be enabled when `NODE_ENV` is\n`test`. Using this plugin elsewhere, such as in production, can lead to\nincreased build size. For example:\n\n```javascript\nmodule.exports = {\n  parserOpts: { ... },\n  plugins: [ ... ],\n  env: {\n      test: {\n        plugins: ['explicit-exports-references']\n      }\n  }\n};\n```\n\nFinally, run Babel through your toolchain (Webpack, Jest, etc) or manually:\n\n```bash\nnpx babel src --out-dir dist\n```\n\n## AST Algorithm\n\n> To see detailed output on how this plugin transforms your code, enable [debug\n> mode][2]:\n> `DEBUG='babel-plugin-explicit-exports-references:*' npx jest your-test-file`\n\nThe plugin begins by looking for default and named export declarations in a\nprogram.\n\nFor default exports, it looks for function declarations and class declarations\nthat have ids (i.e. variable names), like `export default function main() {}`,\nand updates any Identifiers referencing that id.\n\nFor named exports, it looks for function and class declarations too, but also\nvariable declarations like `export const foo = 5;` and\n`export { x as default, y, x as z };`. **Enums are explicitly ignored.** Any\nIdentifiers that reference the declaration's id or specifier are updated.\n\nWhen updating references, by default only Identifiers are transformed.\nAssignment Expressions can also be transformed, but doing so is [currently\nunstable][1]. All other reference types are ignored, including TypeScript types\nand Identifiers within their own declarations.\n\nThe following enables transforming Assignment Expressions along with\nIdentifiers:\n\n<!-- prettier-ignore-start -->\n```javascript\nmodule.exports = {\n  plugins: [\n    ['explicit-exports-references', { transformAssignExpr: true }]\n  ]\n};\n```\n<!-- prettier-ignore-end -->\n\n## Motivation\n\nSuppose we have the following `myModule.ts` TypeScript file:\n\n```typescript\n// file: myModule.ts\n\nexport function foo() {\n  // This function works fine in production but throws on our local test machine\n  throw new Error('failed to do expensive network stuff');\n  return;\n}\n\nexport function bar() {\n  // ...\n  foo();\n  return 5;\n}\n\nexport function baz() {\n  // ...\n  foo();\n  return 50;\n}\n```\n\nLets say we want to unit test `myModule.ts`. Specifically, we want to test `bar`\nand `baz`. We don't want to unit test `foo` because a) attempting to run it on\nour local machine will always fail, which is why b) it is covered by our\nintegration tests instead. We simply want to ensure `bar` and `baz` work, and\nthat they both _call_ `foo` without _running_ `foo`.\n\nIf we expect a function to be called, and we want an alternative implementation\nrun when it is called, the easy and obvious solution is to [mock it][3].\n\nSo suppose we create the following `myModule.test.ts` Jest test file, mocking\n`foo` with a [noop](<https://en.wikipedia.org/wiki/NOP_(code)>):\n\n```typescript\n// file: myModule.test.ts\n\nimport * as myModule from './myModule';\n\nit('bar does what I want', () => {\n  const spy = jest.spyOn(myModule, 'foo').mockImplementation(() => undefined);\n\n  expect(myModule.bar()).toBe(5);\n  expect(spy).toBeCalled();\n\n  spy.mockRestore();\n});\n\nit('baz does what I want', () => {\n  const spy = jest.spyOn(myModule, 'foo').mockImplementation(() => undefined);\n\n  expect(myModule.baz()).toBe(50);\n  expect(spy).toBeCalled();\n\n  spy.mockRestore();\n});\n```\n\nThis file tests that `bar` and `baz` do what we want, and whenever they call\n`foo` the dummy version is called instead and no error is thrown. Or rather,\nthat seems like it should be the thing that happens. Unfortunately, if we run\nthis code, the above tests will fail because `foo` throws\n_`failed to do expensive network stuff`_.\n\nIs this a bug?\n\nAfter encountering this problem over five years ago, someone posed the question\nto the Jest project:\n[how do you mock a specific function in a module?](https://github.com/facebook/jest/issues/936),\nto which a contributor\n[responded](https://github.com/facebook/jest/issues/936#issuecomment-214939935):\n\n> Supporting the above by mocking a function after requiring a module is\n> impossible in JavaScript – there is (almost) no way to retrieve the binding\n> that foo refers to and modify it.\n>\n> However, if you change your code to this:\n>\n> ```typescript\n> var foo = function foo() {};\n> var bar = function bar() {\n>   exports.foo();\n> };\n>\n> exports.foo = foo;\n> exports.bar = bar;\n> ```\n>\n> and then in your test file you do:\n>\n> ```typescript\n> var module = require('../module');\n> module.foo = jest.fn();\n> module.bar();\n> ```\n>\n> it will work just as expected. This is what we do at Facebook where we don't\n> use ES2015.\n>\n> While ES2015 modules may have immutable bindings for what they export, the\n> underlying compiled code that babel compiles to right now doesn't enforce any\n> such constraints. I see no way currently to support exactly what you are\n> asking...\n\nEssentially, this plugin aims to automate the suggestion above, allowing you to\nmock a specific module function using standard Jest spies by automatically\nreplacing references to exported identifiers with an explicit reference of the\nform `module.exports.${identifier}`. No assembly required.\n\nWith this plugin loaded into Babel, the tests in the motivating example above\npass! 🎉\n\n### Prior Art\n\nPrior solutions include:\n\n- [Manually rewrite all refs to exported identifiers as `exports.${identifier}`](https://github.com/facebook/jest/issues/936#issuecomment-611860173)\n- [Manually rewrite all function and class declarations as expressions](https://github.com/facebook/jest/issues/936#issuecomment-545080082)\n- [Manually place every function and class declaration in a separate file](https://github.com/facebook/jest/issues/936#issuecomment-687632079)\n  (yikes)\n- [Rewrite your tests to use `rewire` dark magic](https://github.com/facebook/jest/issues/936#issuecomment-611860173)\n- [Spend an hour hand-crafting a bespoke nth-level module mock](https://github.com/facebook/jest/issues/936#issuecomment-743688960)\n\nFurther reading and additional solutions:\n\n- https://medium.com/@DavideRama/mock-spy-exported-functions-within-a-single-module-in-jest-cdf2b61af642\n- https://medium.com/@qjli/how-to-mock-specific-module-function-in-jest-715e39a391f4\n- https://kennethteh90.medium.com/jest-how-to-mock-functions-that-reference-each-other-from-the-same-module-9f1d3293ec81\n- https://github.com/facebook/jest/issues/936\n\n## Documentation\n\nFurther documentation can be found under [`docs/`][docs].\n\n## Contributing and Support\n\n**[New issues][choose-new-issue] and [pull requests][pr-compare] are always\nwelcome and greatly appreciated! 🤩** Just as well, you can [star 🌟 this\nproject][link-repo] to let me know you found it useful! ✊🏿 Thank you!\n\nSee [CONTRIBUTING.md][contributing] and [SUPPORT.md][support] for more\ninformation.\n\n[badge-blm]: https://api.ergodark.com/badges/blm 'Join the movement!'\n[link-blm]: https://secure.actblue.com/donate/ms_blm_homepage_2019\n[badge-maintenance]:\n  https://img.shields.io/maintenance/active/2022\n  'Is this package maintained?'\n[link-repo]:\n  https://github.com/xunnamius/babel-plugin-explicit-exports-references\n[badge-last-commit]:\n  https://img.shields.io/github/last-commit/xunnamius/babel-plugin-explicit-exports-references\n  'When was the last commit to the official repo?'\n[badge-issues]:\n  https://isitmaintained.com/badge/open/Xunnamius/babel-plugin-explicit-exports-references.svg\n  'Number of known issues with this package'\n[link-issues]:\n  https://github.com/Xunnamius/babel-plugin-explicit-exports-references/issues?q=\n[badge-pulls]:\n  https://img.shields.io/github/issues-pr/xunnamius/babel-plugin-explicit-exports-references\n  'Number of open pull requests'\n[link-pulls]:\n  https://github.com/xunnamius/babel-plugin-explicit-exports-references/pulls\n[badge-codecov]:\n  https://codecov.io/gh/Xunnamius/babel-plugin-explicit-exports-references/branch/main/graph/badge.svg?token=HWRIOBAAPW\n  'Is this package well-tested?'\n[link-codecov]:\n  https://codecov.io/gh/Xunnamius/babel-plugin-explicit-exports-references\n[package-json]: package.json\n[badge-license]:\n  https://img.shields.io/npm/l/babel-plugin-explicit-exports-references\n  \"This package's source license\"\n[link-license]:\n  https://github.com/Xunnamius/babel-plugin-explicit-exports-references/blob/main/LICENSE\n[badge-npm]:\n  https://api.ergodark.com/badges/npm-pkg-version/babel-plugin-explicit-exports-references\n  'Install this package using npm or yarn!'\n[link-npm]:\n  https://www.npmjs.com/package/babel-plugin-explicit-exports-references\n[badge-semantic-release]:\n  https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg\n  'This repo practices continuous integration and deployment!'\n[link-semantic-release]: https://github.com/semantic-release/semantic-release\n[side-effects-key]:\n  https://webpack.js.org/guides/tree-shaking/#mark-the-file-as-side-effect-free\n[exports-main-key]:\n  https://github.com/nodejs/node/blob/8d8e06a345043bec787e904edc9a2f5c5e9c275f/doc/api/packages.md#package-entry-points\n[choose-new-issue]:\n  https://github.com/Xunnamius/babel-plugin-explicit-exports-references/issues/new/choose\n[pr-compare]:\n  https://github.com/Xunnamius/babel-plugin-explicit-exports-references/compare\n[contributing]: CONTRIBUTING.md\n[support]: .github/SUPPORT.md\n[docs]: docs\n[1]:\n  https://github.com/Xunnamius/babel-plugin-explicit-exports-references/issues/2\n[2]: https://www.npmjs.com/package/debug\n[3]: https://jestjs.io/docs/jest-object#jestspyonobject-methodname\n","readmeFilename":"README.md"}