{"id":16528965,"url":"https://github.com/satya164/babel-plugin-optional-require","last_synced_at":"2025-03-16T19:31:26.120Z","repository":{"id":57188883,"uuid":"130056066","full_name":"satya164/babel-plugin-optional-require","owner":"satya164","description":"Babel plugin to optionaly require modules","archived":false,"fork":false,"pushed_at":"2018-12-17T17:30:22.000Z","size":151,"stargazers_count":53,"open_issues_count":0,"forks_count":1,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-02-27T12:26:22.960Z","etag":null,"topics":["babel","babel-plugin","bundler","hacktoberfest"],"latest_commit_sha":null,"homepage":"","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/satya164.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":"2018-04-18T12:05:41.000Z","updated_at":"2024-08-14T11:12:46.000Z","dependencies_parsed_at":"2022-08-28T10:51:44.005Z","dependency_job_id":null,"html_url":"https://github.com/satya164/babel-plugin-optional-require","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/satya164%2Fbabel-plugin-optional-require","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/satya164%2Fbabel-plugin-optional-require/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/satya164%2Fbabel-plugin-optional-require/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/satya164%2Fbabel-plugin-optional-require/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/satya164","download_url":"https://codeload.github.com/satya164/babel-plugin-optional-require/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243826780,"owners_count":20354220,"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":["babel","babel-plugin","bundler","hacktoberfest"],"created_at":"2024-10-11T17:42:33.753Z","updated_at":"2025-03-16T19:31:25.760Z","avatar_url":"https://github.com/satya164.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# babel-plugin-optional-require\n\nBabel plugin to optionaly require modules. Useful with a bundler like [Metro](https://github.com/facebook/metro) which doesn't support optional `require` statements.\n\nThis is primarily useful if you want add an dependency to your library that's optional and you want users to be able to opt-out of it to save bundle size. You can also use it in apps to load configuration files only if they exist.\n\n## Usage\n\nInstall the plugin:\n\n```sh\nyarn add --dev babel-plugin-optional-require\n```\n\nThen include it in your `.babelrc`:\n\n```json\n{\n  \"plugins\": [\n    \"optional-require\"\n  ]\n}\n```\n\n## Options\n\n- `builtins: boolean`: Whether to resolve Node builtins. Default: `false`.\n- `blacklist: string[]`: List of modules we assume to be unavailable without resolving. Default: `[]`.\n- `whitelist: string[]`: List of modules we assume to be available without resolving. Default: `[]`.\n\n## Example\n\nTo optionally `require` a module, you need to wrap it in `try/catch`:\n\n```js\nlet a;\n\ntry {\n  a = require('optional-module');\n} catch (e) {\n  // Handle failure from loading the module\n}\n```\n\nIf the module `optional-module` doesn't exist, the `require` call will be replaced with an IIFE that throws an error, so you can catch it and handle it at runtime. Otherwise, the code is left unchanged.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsatya164%2Fbabel-plugin-optional-require","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsatya164%2Fbabel-plugin-optional-require","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsatya164%2Fbabel-plugin-optional-require/lists"}