{"id":24738613,"url":"https://github.com/zweifisch/simple-require","last_synced_at":"2025-10-10T07:32:53.844Z","repository":{"id":6368773,"uuid":"7606113","full_name":"zweifisch/simple-require","owner":"zweifisch","description":"nodejs like require/exports for browser","archived":false,"fork":false,"pushed_at":"2013-03-22T02:29:45.000Z","size":212,"stargazers_count":4,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-03T23:53:23.664Z","etag":null,"topics":[],"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/zweifisch.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":"2013-01-14T14:55:45.000Z","updated_at":"2018-09-25T02:30:16.000Z","dependencies_parsed_at":"2022-09-06T21:41:08.852Z","dependency_job_id":null,"html_url":"https://github.com/zweifisch/simple-require","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/zweifisch/simple-require","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zweifisch%2Fsimple-require","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zweifisch%2Fsimple-require/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zweifisch%2Fsimple-require/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zweifisch%2Fsimple-require/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zweifisch","download_url":"https://codeload.github.com/zweifisch/simple-require/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zweifisch%2Fsimple-require/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278717889,"owners_count":26033642,"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","status":"online","status_checked_at":"2025-10-07T02:00:06.786Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":"2025-01-27T22:55:01.373Z","updated_at":"2025-10-10T07:32:53.523Z","avatar_url":"https://github.com/zweifisch.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# simple-require\n\nnodejs like require/exports for browser\n\n## how to use\n\nasumming following project structure\n```\nindex.html\nmain.js\nlib\n\tmy-math-helpers.js\n\tmy-time-helpers.js\nvender\n\tsimplre-require.js\n```\n\ninclude `simplre-require.js` in `index.html`, `data-main=\"main\"` here claims that the entry script is `main.js`\n```html\n\u003cscript data-main=\"main\" type=\"text/javascript\" src=\"vender/simple-require.js\"\u003e\u003c/script\u003e\n```\n\ncontent of `lib/my-math-helpers.js`\n```javascript\nexports.version = 'v0.0.1';\nexports.divide = function(n,n2){\n\treturn Math.floor(n/n2);\n}\n```\n\ncontent of `lib/my-time-helpers.js`\n```javascript\nvar math = require('./my-math-helpers');\nexports.getTimestamp = function(){\n\treturn math.divide(+new Date(),1000);\n}\n```\n\nfinally `main.js`\n```javascript\nvar time = require('./lib/my-time-helpers');\nconsole.log(time.getTimestamp());\n```\n\n## why use it\n\n* code sharing between browser and nodejs made easy\n* simplicity(about 100 lines of coffeescript)\n\n## how to pack\n\ninstall simple-require via npm\n\n```sh\nnpm install -g simple-require\n```\n\n```sh\nsimple-require --build main.js \u003e! packed.js\n```\n\nthere is also a `--minify` option, if set, the concated script will be passed\nto uglify-js\n\n### including libraries\n\nprepare a text file with a list of libraries inside\n```\nvender/jquery\nvender/some-other-lib\n```\n\nset the data-shims attribute\n```html\n\u003cscript type=\"text/javascript\" src=\"vender/simple-require.js\"\n\tdata-main=\"main\" data-shims=\"shims.txt\"\u003e\u003c/script\u003e\n```\n\nwhen packing scripts, use the `--shims` option\n\n### more options\n\nusing `--list-dependency` or `-l` for short to list dependencies of a file\n```sh\nsimple-require --list-dependency main.js\n```\n\n`--json` for json output, `--flat` for more simpler output\n\n### pack manually\n\nprepare a `build.txt`, the entry script must be placed at the top of it\n```\nmain\nlib/my-math-helper\nlib/time-helper\n```\nthen run\n```sh\nsimple-require --concat-scripts build.txt \u003e! build.js\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzweifisch%2Fsimple-require","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzweifisch%2Fsimple-require","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzweifisch%2Fsimple-require/lists"}