{"id":17216386,"url":"https://github.com/ganeshkbhat/require-urls","last_synced_at":"2026-01-20T09:04:04.932Z","repository":{"id":60649816,"uuid":"544475069","full_name":"ganeshkbhat/require-urls","owner":"ganeshkbhat","description":"Deno and GoLang Mode in commonjs import (require) and ES import syntax: Replace nodejs require function with requireurls function or use loader.mjs replacing import functionality that can fetch remote urls.","archived":false,"fork":false,"pushed_at":"2024-04-19T07:10:43.000Z","size":7592,"stargazers_count":2,"open_issues_count":6,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-24T10:21:15.332Z","etag":null,"topics":["remote","remote-urls-require","require","require-remote-urls","require-urls","urls"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ganeshkbhat.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}},"created_at":"2022-10-02T15:20:28.000Z","updated_at":"2023-05-06T04:48:23.000Z","dependencies_parsed_at":"2024-02-04T02:31:57.924Z","dependency_job_id":"11c3f6d4-7419-4a14-8ebe-0ff346069bbc","html_url":"https://github.com/ganeshkbhat/require-urls","commit_stats":null,"previous_names":["ganeshkbhat/requireurl"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/ganeshkbhat/require-urls","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ganeshkbhat%2Frequire-urls","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ganeshkbhat%2Frequire-urls/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ganeshkbhat%2Frequire-urls/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ganeshkbhat%2Frequire-urls/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ganeshkbhat","download_url":"https://codeload.github.com/ganeshkbhat/require-urls/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ganeshkbhat%2Frequire-urls/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28599850,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-20T08:51:33.170Z","status":"ssl_error","status_checked_at":"2026-01-20T08:51:10.855Z","response_time":117,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["remote","remote-urls-require","require","require-remote-urls","require-urls","urls"],"created_at":"2024-10-15T03:27:38.068Z","updated_at":"2026-01-20T09:04:04.912Z","avatar_url":"https://github.com/ganeshkbhat.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# require-urls\n\n#### `Deno and GoLang Mode in commonjs import (require) and ES import syntax`\n\nReplace nodejs require function with `requireurls` function or `use loader functionality using loader.mjs` replacing import functionality that can fetch remote urls. `require-urls` helps you require remote files (individually or recursively) from `git`, `svn`, `mercurial`, `ftp`, `remote cloud stores` using the `requireurls function. Please check the features section for currently available features.\n\nThis module has a single simple function `requireurls` for URL (git raw file) resolution and parsing meant to have feature parity with node.js core url module.\n\nIt also, by default, allows for cacheing (rather storing) files in a temporary working folder/repository. The files are stored in `.jscache` temporary folder. The file can be pulled from the cache, if already cached. You can force update the cache file if needed. The `.jscache` looks like the folder in the repository saved. You have an option to cache the files into node cache using the [require.cache](https://nodejs.org/api/modules.html#requirecache) option by specifying `cacheFetch` option. Do have a look at it.\n\n### DEMOS\n\nFind the demos in the [demo folder](./demos/)\n\n### INSTALLATION\n\n`npm install require-urls --save`\n\nnpm Package: [require-urls](https://www.npmjs.com/package/require-urls)\n\n### USAGE\n\n```\n\nlet requireurls = require(\"require-urls\");\nlet request = \"https://raw.githubusercontent.com/ganeshkbhat/requireurl/main/index.js\";\nlet options = {};\nrequireurls(request, options);\n\n```\n\nRun the file using the following command:\n\n```\nnode --experimental-loader=./node_modules/require-urls/src/loaders/loader.mjs ./file.js\n```\n\n### FEATURES\n\nCurrently, the project is in development and support the following features:\n\n- Import `remote file` from a remote URL (Github support)\n- Import `remote file and its dependencies recursively` from from a remote URL (Github support)\n- Import files are `cached` in `.jscache` folder in the project\n- [TODO] Minor addition of using `package.json` to import entire package installation for use\n- [TODO] Support of other repositories like `svn`, `mercurial`, `ftp`, or any `other cloud` stores.\n\n\n### OBJECT `options` \n\n\nYou can add all inbuilt default options of require's resolve function. The default require options can be found here: [require.resolve](https://nodejs.org/api/modules.html#requireresolverequest-options). All other options customized for `require-urls` function's `options` argument object are as below:\n\n\nFollowing is a sample `options` object. All are options object and everything have defaults.\n\n\n```\n\n// .... all imports etc\n\nlet options  = {\n  /* You can add all inbuilt default options of require's resolve function */\n\n  // require.resolve options key\n  paths: \"\", \n\n  // Which repository or store the file is being pulled from. options: git, bitbucket\n  baseType: \"git\", \n\n  // Require urls recursively, recursive: will allow for recursive pull and cache of files relative to remote url path\n  recursive: false, \n      \n  // forceUpdate: force update the .jscache folder for the remote url files\n  // if forceUpdate is [A] false, [B] true.  \n  // [A]: 1. if files are present then require from jscache folder, if already downloaded. 2. if files are not present then fetch from remote and save.  \n  // [B]: if files are present then forceUpdate the files. \n  forceUpdate: false, \n\n  // Add logger to the require function, gives detailed logging during fetch. logger: provide a logger function to use. default is console.log\n  logger: console.log, \n\n  // TODO: ReConsidering feature. require from jscache folder, if already downloaded. Conflicting with forceUpdate\n  cacheFetch: true, \n\n  // get individual methods of remoteUrl, recursiveUrl, packageJson\n  getMethods: true, \n\n  // TODO: require \n  noRequire: false, \n\n  // TODO: specify the jscacheDir for caching files \n  jscacheDir: '\\$pwd\\$' \n\n  // TODO: package.json packages download and install options \n  package: { production: false, directories: [], files: [] } \n}\n\nrequireurls(request, options)\n\n```\n\n\n### KEY DETAILS `options` \n\n\n\n```\n/* options: git, bitbucket, gitlab, svn [TODO], ftp [TODO], etc.*/\n/* Default is `git`. */\n\nbaseType: \"git\"\n```\n\n```\n/* recursive: will allow for recursive pull and cache of files relative to remote url path. */\n/* Default is false. */\n\nrecursive: false\n```\n\n```\n/* forceUpdate: force update the .jscache folder for the remote url files.*/\n/* Default is false. */\n\nforceUpdate: false\n```\n\n```\n/* logger: provide a logger function to use.*/\n/* Default is console.log */\n\nlogger: console.log\n```\n\n```\n/* Adds the `.jscache` or remotely fetched files using `require.cache` feature of nodejs */\n/* Default is false */\n\ncacheFetch: true\n```\n\n```\n/* getMethods: Get all the methods of require-urls.*/\n/* Default is false */\n/* Usage: requireurls(\"\", { getMethods: true }) */\n/* Returns an object { remoteUrl, recursiveUrl, packageJson } instead of a requireurls function */\n\ngetMethods: false\n```\n\n```\n/* noRequire: Get all the methods of require-urls.*/\n/* Default is false */\n/* Usage: requireurls(\"\", { noRequire: true }) */\n/*  */\n\nnoRequire: false\n```\n\n```\n/* jscacheDir: The directory for .jscache folder. */\n/* Default is $pwd$ */\n/* Options are $git$, $pwd$, $packagejson$, $svn$, $ftp$, $nodemodules$, './path/to/folder' */\n/* Usage: requireurls(\"\", { jscacheDir: '\\$git\\$' }) */\n/*  */\n\njscacheDir: '\\$pwd\\$'\n```\n\n#### DEMO USAGE CODE\n\n```\n\n\nlet requireurls = require(\"require-urls\");\n\nlet fileone = requireurls(\"https://raw.githubusercontent.com/ganeshkbhat/requireurl/main/index.js\");\nlet filetwo = requireurls(\"https://raw.githubusercontent.com/ganeshkbhat/requireurl/8d8681c4a28d64f23fb473064fa86880a0b930ff/index.js\");\nlet filethree = requireurls(\"https://github.com/ganeshkbhat/requireurl/blob/main/index.js\");\n\n\nlet requireurls = require(\"require-urls\");\nlet c = requireurls(\n              // request remote url\n        \"https://raw.githubusercontent.com/ganeshkbhat/requireurl/8d8681c4a28d64f23fb473064fa86880a0b930ff/index.js\",  \n        {\n            baseType: \"git\", \n            recursive: true, \n            forceUpdate: true,\n            logger: console.log\n        });\n\nc.then(d =\u003e console.log(\"testing\", d));\n\n\n```\n\n```\n\n\n// Importing using the CommonJS and ES import Syntax\n// RUN command with --experimental-loader to run the files through the import syntax support for remote url requires or imports:\n// node --experimental-loader ./node_modules/require-urls/loader.mjs ./file.mjs\n// node --experimental-loader ./node_modules/require-urls/loader.mjs ./file.js\n\nlet c = import(\"https://github.com/cgi-js/cgi-js/blob/main/src/configs.js\");\nconsole.log(\"[require-urls] demo-import.mjs \", cgijs);\n\n\n```\n\n```\n\n\n// Importing using the ES import Syntax\n// RUN command with --experimental-loader to run the files through the import syntax support for remote url requires or imports:\n// node --experimental-loader ./node_modules/require-urls/loader.mjs ./file.mjs\n\nimport  cgijs from \"https://github.com/cgi-js/cgi-js/blob/main/src/index.js\";\nconsole.log(\"[require-urls] demo.mjs \", cgijs);\n\nimport  { default as cgijsd } from \"https://github.com/cgi-js/cgi-js/blob/main/src/index.js\";\nconsole.log(\"[require-urls] demo.mjs \", cgijsd);\n\n\n```\n\n\n```\n\n// Importing remote files and dependencies files recursively\n\nlet requireurls = require(\"require-urls\");\nlet d = requireurls(\"https://github.com/cgi-js/cgi-js/blob/main/src/index.js\", {\n    baseType: \"git\", recursive: true, forceUpdate: true,\n    logger: console.log, cacheFetch: false,\n    getMethods: false, noRequire: false\n    });\nconsole.log(\"[require-urls] demo-recursive.js: Getting cgi-js file: \", d.then(r =\u003e console.log(r)));\n\n```\n\n# ERRORS DOCUMENTATION\n\nDocumented Errors [errors](./docs/errors.md)\n\n### TODO\n\n- [D] Github support for remote files import\n  - [D] single file import.\n  - [D] file import and dependency file imports recursively.\n  - [T] importing project using package.json.\n- [T] Gitlab support for remote files import\n  - [T] single file import.\n  - [T] file import and dependency file imports recursively.\n  - [T] importing project using package.json.\n- [T] Bitbucket support for remote files import and testing for\n  - [T] single file import.\n  - [T] file import and dependency file imports recursively.\n  - [T] importing project using package.json.\n- [P] Naming of folders based on\n  - [P] `domain \u003e user@repo \u003e SHA`\n  - [D] `domain \u003e user@repo \u003e commit`\n  - [P] `domain \u003e user@repo \u003e tag`\n  - [D] `domain \u003e user@repo \u003e branch`\n- [P] Add options to import a remote published or unpublished package using `https://remoteurl/.../package.json` pack of repository.\n- [P] Files imported are documented in `filelock.json` file with their content one-way cryptographic hash.\n- [P] Add verify command for files in `.jscache`.\n- [P] Add support for `.ts` (typescript) files import with transpiling dynamically during import.\n- [P] Add support for `.coffee` (coffeescript) files import with transpiling dynamically during import.\n- [T] Add support for FTP.\n- [T] Add support for SVN.\n- [T] Add support for Mercurial.\n- [T] Consider support for S3.\n- [T] Consider support for Google Cloud.\n- [T] Consider support for Google Drive.\n\n### CONTRIBUTIONS\n\nContributions, Feature Improvements, Bugs, and Issues are invited. [raising an issue](https://github.com/ganeshkbhat/requireurl/issues)\n\n# LICENSE\n\n[MIT License](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fganeshkbhat%2Frequire-urls","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fganeshkbhat%2Frequire-urls","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fganeshkbhat%2Frequire-urls/lists"}