{"_id":"browserify-optional","_rev":"3551630","name":"browserify-optional","description":"A browserify transform that allows optional dependencies in try..catch blocks","dist-tags":{"latest":"1.0.1"},"maintainers":[{"name":"devongovett","email":"devongovett@gmail.com"}],"time":{"modified":"2024-09-19T02:43:35.000Z","created":"2015-03-23T04:54:33.099Z","1.0.1":"2017-08-28T23:09:20.794Z","1.0.0":"2015-03-23T04:54:33.099Z"},"users":{},"author":{"name":"Devon Govett","email":"devongovett@gmail.com"},"repository":{"type":"git","url":"git://github.com/devongovett/browserify-optional.git"},"versions":{"1.0.1":{"name":"browserify-optional","version":"1.0.1","description":"A browserify transform that allows optional dependencies in try..catch blocks","main":"index.js","scripts":{"test":"mocha"},"repository":{"type":"git","url":"git://github.com/devongovett/browserify-optional.git"},"keywords":["browserify","transform","optional"],"author":{"name":"Devon Govett","email":"devongovett@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/devongovett/browserify-optional/issues"},"homepage":"https://github.com/devongovett/browserify-optional","devDependencies":{"concat-stream":"^1.4.7","mocha":"^2.2.1"},"dependencies":{"ast-transform":"0.0.0","ast-types":"^0.7.0","browser-resolve":"^1.8.1"},"gitHead":"8791cc55139d8669905bd151346408a4b935d3bc","_id":"browserify-optional@1.0.1","_shasum":"1e13722cfde0d85f121676c2a72ced533a018869","_from":".","_npmVersion":"3.10.10","_nodeVersion":"6.11.1","_npmUser":{"name":"devongovett","email":"devongovett@gmail.com"},"dist":{"shasum":"1e13722cfde0d85f121676c2a72ced533a018869","size":4499,"noattachment":false,"key":"/browserify-optional/-/browserify-optional-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/browserify-optional/download/browserify-optional-1.0.1.tgz"},"maintainers":[{"name":"devongovett","email":"devongovett@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/browserify-optional-1.0.1.tgz_1503961760700_0.16895781201310456"},"directories":{},"publish_time":1503961760794,"_hasShrinkwrap":false,"_cnpm_publish_time":1503961760794,"_cnpmcore_publish_time":"2021-12-16T16:10:28.832Z"},"1.0.0":{"name":"browserify-optional","version":"1.0.0","description":"A browserify transform that allows optional dependencies in try..catch blocks","main":"index.js","scripts":{"test":"mocha"},"repository":{"type":"git","url":"git://github.com/devongovett/browserify-optional.git"},"keywords":["browserify","transform","optional"],"author":{"name":"Devon Govett","email":"devongovett@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/devongovett/browserify-optional/issues"},"homepage":"https://github.com/devongovett/browserify-optional","devDependencies":{"concat-stream":"^1.4.7","mocha":"^2.2.1"},"dependencies":{"ast-transform":"0.0.0","ast-types":"^0.7.0","browser-resolve":"^1.8.1"},"gitHead":"8f7b7776c06d1bcc875c9bf2e166a73b20622024","_id":"browserify-optional@1.0.0","_shasum":"20cf7ab1e7bf014cbf63782d35d75b62dab4b6f1","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"devongovett","email":"devongovett@gmail.com"},"maintainers":[{"name":"devongovett","email":"devongovett@gmail.com"}],"dist":{"shasum":"20cf7ab1e7bf014cbf63782d35d75b62dab4b6f1","size":1987,"noattachment":false,"key":"/browserify-optional/-/browserify-optional-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/browserify-optional/download/browserify-optional-1.0.0.tgz"},"directories":{},"publish_time":1427086473099,"_hasShrinkwrap":false,"_cnpm_publish_time":1427086473099,"_cnpmcore_publish_time":"2021-12-16T16:10:29.106Z"}},"readme":"# browserify-optional\n\nIt is a common pattern in Node to support optional dependencies via requires in try..catch blocks.\nBrowserify doesn't support this by default and throws a compile time error when it cannot find a \nmodule. You can solve the problem by using browserify's exclude option, but this works globally\ninstead of at a per-module level. This transform fixes the problem by moving the compile time \nerror to a runtime error for requires of missing modules inside try..catch blocks.\n\n## Example\n\nThe transform would transform the following code such that requiring `missing-module` would throw\na runtime error instead of a compile time error, making the code work as expected.\n\n```javascript\ntry {\n  var x = require('missing-module');\n} catch (e) {\n  var x = require('replacement-module');\n}\n```\n\nTo set it up in browserify, add this to your package.json:\n\n```json\n\"browserify\": {\n  \"transform\": [\"browserify-optional\"]\n}\n```\n\n## License\n\nMIT\n","_attachments":{},"homepage":"https://github.com/devongovett/browserify-optional","bugs":{"url":"https://github.com/devongovett/browserify-optional/issues"},"license":"MIT"}