{"id":22975769,"url":"https://github.com/togatech/require-browser","last_synced_at":"2025-04-02T08:14:04.483Z","repository":{"id":129778950,"uuid":"367473416","full_name":"TogaTech/require-browser","owner":"TogaTech","description":"Use node.js-style require and exports syntax in the browser","archived":false,"fork":false,"pushed_at":"2021-10-25T00:29:39.000Z","size":36,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-07T22:49:39.849Z","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":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TogaTech.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-05-14T20:32:37.000Z","updated_at":"2021-10-25T00:29:41.000Z","dependencies_parsed_at":"2023-04-11T07:49:27.600Z","dependency_job_id":null,"html_url":"https://github.com/TogaTech/require-browser","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TogaTech%2Frequire-browser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TogaTech%2Frequire-browser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TogaTech%2Frequire-browser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TogaTech%2Frequire-browser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TogaTech","download_url":"https://codeload.github.com/TogaTech/require-browser/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246777834,"owners_count":20832032,"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-12-15T00:39:02.087Z","updated_at":"2025-04-02T08:14:04.469Z","avatar_url":"https://github.com/TogaTech.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# require-browser\nUse node.js-style require and exports syntax in the browser\n\n## Install\nTo use the require-browser tool in your front-end application, move the `require-browser.js` file into the root directory of your project and use the following script tag in all HTML files:\n```html\n\u003cscript type=\"text/javascript\" src=\"/require-browser.js\"\u003e\u003c/script\u003e\n```\n\n## Documentation\n\n### Paths\nThere are multiple different types of paths that can be used to require code.\n - Files: all file paths must include a `/` (easiest way to do this is to have the file path start with `/` or `./`) and end in `.js`.\n - Folders: `require-browser` will search for the folder with the name of the path if the file path is not a file (above conditions), if the file path contains a `/`, and if the file path does not contain `@`. `require-browser` will assume that you are requiring a file from the path specified.\n \t - By default, `index.js` in the folder will be used.\n \t - If `package.json` exists in the folder, the file in the `main` field will be used.\n \t - If the `browser` field exists in the `package.json`, whatever file was selected before will be mapped to the browser field's file if the mapping exists.\n - Node Modules: if none of the above conditions are met, `require-browser` will assume that you are requiring a node module and search in the default `node_modules` directory.\n \t - By default, `index.js` in the folder will be used.\n \t - If `package.json` exists in the folder, the file in the `main` field will be used.\n \t - If the `browser` field exists in the `package.json`, whatever file was selected before will be mapped to the browser field's file if the mapping exists.\n\n### Installing Code\nDue to the asynchronous nature of HTTP requests, all code that will be required must first be installed to the client. To install, use the following command:\n```javascript\ninstall(path, options);\n```\n\nIf you would like to install multiple files, use the following command:\n```javascript\ninstallAll([path1, path2, path3], options);\n```\n\n#### Options\nOptions are an additional feature to change the configuration settings of the installation. If options are not included, the default settings are used.\n - `node_modules`: The path to the node_modules folder (default: `/node_modules/`)\n - `path`: a relative path to a certain file, best used with repetitive start paths in `installAll` (default: blank)\n - `reinstall`: reinstall a module in case it has already been installed (default: `false`)\n - `installDependencies`: install any modules listed in the `dependencies` portion of a `package.json` file (default: `true`)\n - `installDevDependencies`: install any modules listed in the `devDependencies` portion of a `package.json` file (default: `false`)\n - `name`: the name used to install that module later (default: path)\n\n### Requiring Code\nIf you would like to require code, the code imported must use `module.exports`, `exports`, or browser code. If you have `module.exports` or `exports`, use the following command:\n```javascript\nrequire(path_or_name);\n```\n\nIf you have browser code or the `browser` parameter in `package.json`, use the following command:\n```javascript\nrequireBrowser(path_or_name);\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftogatech%2Frequire-browser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftogatech%2Frequire-browser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftogatech%2Frequire-browser/lists"}