{"id":14156675,"url":"https://github.com/rspack-contrib/rspack-plugin-virtual-module","last_synced_at":"2025-04-14T10:13:47.011Z","repository":{"id":162058333,"uuid":"619515267","full_name":"rspack-contrib/rspack-plugin-virtual-module","owner":"rspack-contrib","description":"An Rspack plugin that allows you to create virtual modules.","archived":false,"fork":false,"pushed_at":"2025-04-11T16:29:44.000Z","size":331,"stargazers_count":42,"open_issues_count":2,"forks_count":6,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-14T10:13:41.497Z","etag":null,"topics":["plugins","rspack","webpack"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/rspack-contrib.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,"zenodo":null}},"created_at":"2023-03-27T09:44:54.000Z","updated_at":"2025-04-09T02:17:12.000Z","dependencies_parsed_at":null,"dependency_job_id":"a3de3646-9cb5-4f82-8504-450b66ca906f","html_url":"https://github.com/rspack-contrib/rspack-plugin-virtual-module","commit_stats":null,"previous_names":["rspack-contrib/rspack-plugins"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rspack-contrib%2Frspack-plugin-virtual-module","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rspack-contrib%2Frspack-plugin-virtual-module/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rspack-contrib%2Frspack-plugin-virtual-module/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rspack-contrib%2Frspack-plugin-virtual-module/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rspack-contrib","download_url":"https://codeload.github.com/rspack-contrib/rspack-plugin-virtual-module/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248860167,"owners_count":21173342,"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":["plugins","rspack","webpack"],"created_at":"2024-08-17T08:07:54.781Z","updated_at":"2025-04-14T10:13:46.981Z","avatar_url":"https://github.com/rspack-contrib.png","language":"TypeScript","readme":"# rspack-plugin-virtual-module\n\nAn Rspack plugin that allows you to create virtual modules.\n\n\u003cp\u003e\n  \u003ca href=\"https://npmjs.com/package/rspack-plugin-virtual-module\"\u003e\n   \u003cimg src=\"https://img.shields.io/npm/v/rspack-plugin-virtual-module?style=flat-square\u0026colorA=564341\u0026colorB=EDED91\" alt=\"npm version\" /\u003e\n  \u003c/a\u003e\n  \u003cimg src=\"https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square\u0026colorA=564341\u0026colorB=EDED91\" alt=\"license\" /\u003e\n\u003c/p\u003e\n\n## Installation\n\n```bash\n# npm\nnpm install rspack-plugin-virtual-module\n\n# yarn\nyarn add rspack-plugin-virtual-module\n\n# pnpm\npnpm add rspack-plugin-virtual-module\n```\n\n## Usage\n\n```js\n// rspack.config.js\nconst { RspackVirtualModulePlugin } = require(\"rspack-plugin-virtual-module\");\n\nmodule.exports = {\n  plugins: [\n    new RspackVirtualModulePlugin({\n      contents: 'export default \"Hello World\";',\n    }),\n  ],\n};\n```\n\nThen you can import the virtual module in your code:\n\n```js\nimport hello from \"contents\";\n\nconsole.log(hello); // \"Hello World\"\n```\n\nIf you want to dynamically write the contents of the virtual module, you can use the `writeModule` method:\n\n```js\n// rspack.config.js\nconst { RspackVirtualModulePlugin } = require(\"rspack-plugin-virtual-module\");\n\nconst vmp = new RspackVirtualModulePlugin({\n  contents: 'export default \"Hello World\";',\n});\n\n// Write the contents of the virtual module after 1 second\nsetTimeout(() =\u003e {\n  vmp.writeModule('export default \"Hello World 2\";');\n}, 1000);\n\nmodule.exports = {\n  plugins: [vmp],\n};\n```\n\n## License\n\n[MIT](./LICENSE).\n","funding_links":[],"categories":["Plugins","webpack"],"sub_categories":["Rspack Plugins"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frspack-contrib%2Frspack-plugin-virtual-module","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frspack-contrib%2Frspack-plugin-virtual-module","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frspack-contrib%2Frspack-plugin-virtual-module/lists"}