{"id":16048929,"url":"https://github.com/devongovett/browserify-optional","last_synced_at":"2025-10-11T21:33:40.154Z","repository":{"id":29180772,"uuid":"32711612","full_name":"devongovett/browserify-optional","owner":"devongovett","description":"A browserify transform that allows optional dependencies in try..catch blocks","archived":false,"fork":false,"pushed_at":"2017-08-28T23:09:50.000Z","size":3,"stargazers_count":9,"open_issues_count":6,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-27T05:51:12.720Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/devongovett.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-03-23T04:50:44.000Z","updated_at":"2017-08-28T23:09:45.000Z","dependencies_parsed_at":"2022-08-02T12:05:41.496Z","dependency_job_id":null,"html_url":"https://github.com/devongovett/browserify-optional","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devongovett%2Fbrowserify-optional","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devongovett%2Fbrowserify-optional/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devongovett%2Fbrowserify-optional/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devongovett%2Fbrowserify-optional/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devongovett","download_url":"https://codeload.github.com/devongovett/browserify-optional/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243806052,"owners_count":20350775,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-09T00:11:22.389Z","updated_at":"2025-10-11T21:33:35.136Z","avatar_url":"https://github.com/devongovett.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevongovett%2Fbrowserify-optional","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevongovett%2Fbrowserify-optional","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevongovett%2Fbrowserify-optional/lists"}