{"id":13447750,"url":"https://github.com/browserify/static-module","last_synced_at":"2025-06-30T06:32:56.601Z","repository":{"id":16219133,"uuid":"18966328","full_name":"browserify/static-module","owner":"browserify","description":"convert module usage to inline expressions","archived":false,"fork":false,"pushed_at":"2024-12-21T09:59:26.000Z","size":186,"stargazers_count":75,"open_issues_count":14,"forks_count":23,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-06-10T13:03:44.339Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/browserify.png","metadata":{"files":{"readme":"readme.markdown","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"security.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-04-20T14:45:50.000Z","updated_at":"2024-12-30T13:59:52.000Z","dependencies_parsed_at":"2022-08-19T00:20:39.091Z","dependency_job_id":"de7a1223-e2c5-4283-86bd-9337f0fe6f3c","html_url":"https://github.com/browserify/static-module","commit_stats":{"total_commits":180,"total_committers":20,"mean_commits":9.0,"dds":"0.34444444444444444","last_synced_commit":"397b22b2b96b5af90c153059896aa870a814bf5c"},"previous_names":["substack/static-module"],"tags_count":35,"template":false,"template_full_name":null,"purl":"pkg:github/browserify/static-module","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/browserify%2Fstatic-module","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/browserify%2Fstatic-module/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/browserify%2Fstatic-module/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/browserify%2Fstatic-module/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/browserify","download_url":"https://codeload.github.com/browserify/static-module/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/browserify%2Fstatic-module/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260231296,"owners_count":22978267,"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-07-31T05:01:25.988Z","updated_at":"2025-06-30T06:32:56.578Z","avatar_url":"https://github.com/browserify.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# static-module\n\nconvert module usage to inline expressions\n\n# example\n\nHere's a simplified version of the [brfs](https://npmjs.org/package/brfs) module\nusing static-module.\n\nbrfs converts `fs.readFileSync(file)` calls to inline strings with the contents\nof `file` included in-place.\n\n``` js\nvar staticModule = require('static-module');\nvar quote = require('quote-stream');\nvar fs = require('fs');\n\nvar sm = staticModule({\n    fs: {\n        readFileSync: function (file) {\n            return fs.createReadStream(file).pipe(quote());\n        }\n    }\n}, { vars: { __dirname: __dirname + '/brfs' } });\nprocess.stdin.pipe(sm).pipe(process.stdout);\n```\n\ninput:\n\n```\n$ cat brfs/source.js\nvar fs = require('fs');\nvar src = fs.readFileSync(__dirname + '/x.txt');\nconsole.log(src);\n```\n\noutput:\n\n```\n$ node brfs.js \u003c brfs/source.js \n\nvar src = \"beep boop\\n\";\nconsole.log(src);\n```\n\n# methods\n\n``` js\nvar staticModule = require('static-module')\n```\n\n## var sm = staticModule(modules, opts={})\n\nReturn a transform stream `sm` that transforms javascript source input to\njavascript source output with each property in the `modules` object expanded in\ninline form.\n\nProperties in the `modules` object can be ordinary values that will be included\ndirectly or functions that will be executed with the [statically\nevaluated](https://npmjs.org/package/static-eval) arguments from the source\nunder an optional set of `opts.vars` variables.\n\nProperty functions can return streams, in which case their contents will be\npiped directly into the source output.\n\nOtherwise, the return values of functions will be inlined into the source in\nplace as strings.\n\nUse `opts.varModules` to map whitelisted module names to definitions that can be\ndeclared in client code with `var` and will appear in static expressions like\n`opts.vars`.\n\nFor example, to make this code with `path.join()` work:\n\n``` js\nvar fs = require('fs');\nvar path = require('path');\nvar src = fs.readFileSync(path.join(__dirname, 'x.txt'), 'utf8');\nconsole.log(src);\n```\n\nyou can do:\n\n``` js\nvar staticModule = require('static-module');\nvar quote = require('quote-stream');\nvar fs = require('fs');\n\nvar sm = staticModule({\n    fs: {\n        readFileSync: function (file) {\n            return fs.createReadStream(file).pipe(quote());\n        }\n    },\n    varMods: { path: require('path') }\n}, { vars: { __dirname: __dirname + '/brfs' } });\nprocess.stdin.pipe(sm).pipe(process.stdout);\n```\n\nUse `opts.parserOpts` to set additional options for the\n[acorn](https://github.com/acornjs/acorn) parser.\n\nSet `opts.sourceMap` to `true` to generate a source map and add it as an inline\ncomment. You can add `opts.inputFilename` to configure the original file name\nthat will be listed in the source map.\n\n# install\n\nWith [npm](https://npmjs.org) do:\n\n```\nnpm install static-module\n```\n\n# license\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrowserify%2Fstatic-module","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrowserify%2Fstatic-module","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrowserify%2Fstatic-module/lists"}