{"id":13605682,"url":"https://github.com/davidmyersdev/vite-plugin-node-polyfills","last_synced_at":"2025-05-14T02:06:09.682Z","repository":{"id":59144972,"uuid":"528683893","full_name":"davidmyersdev/vite-plugin-node-polyfills","owner":"davidmyersdev","description":"A Vite plugin to polyfill Node's Core Modules for browser environments.","archived":false,"fork":false,"pushed_at":"2025-03-23T21:17:44.000Z","size":77662,"stargazers_count":350,"open_issues_count":31,"forks_count":28,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-05-08T19:43:51.632Z","etag":null,"topics":["polyfill","vite","vite-plugin"],"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/davidmyersdev.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},"funding":{"github":"davidmyersdev","ko_fi":"davidmyersdev","open_collective":"davidmyersdev","patreon":"davidmyersdev"}},"created_at":"2022-08-25T03:44:55.000Z","updated_at":"2025-05-08T16:08:22.000Z","dependencies_parsed_at":"2023-10-01T20:41:40.020Z","dependency_job_id":"1b95dd3c-3a37-42ab-abb1-4bfefc95b664","html_url":"https://github.com/davidmyersdev/vite-plugin-node-polyfills","commit_stats":{"total_commits":116,"total_committers":11,"mean_commits":"10.545454545454545","dds":"0.11206896551724133","last_synced_commit":"4566d762b948f3cd29e8fa31bd2f3b9272b8de5d"},"previous_names":["voracious/vite-plugin-node-polyfills"],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidmyersdev%2Fvite-plugin-node-polyfills","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidmyersdev%2Fvite-plugin-node-polyfills/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidmyersdev%2Fvite-plugin-node-polyfills/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidmyersdev%2Fvite-plugin-node-polyfills/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/davidmyersdev","download_url":"https://codeload.github.com/davidmyersdev/vite-plugin-node-polyfills/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253633120,"owners_count":21939389,"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":["polyfill","vite","vite-plugin"],"created_at":"2024-08-01T19:01:01.554Z","updated_at":"2025-05-14T02:06:09.629Z","avatar_url":"https://github.com/davidmyersdev.png","language":"TypeScript","funding_links":["https://github.com/sponsors/davidmyersdev","https://ko-fi.com/davidmyersdev","https://opencollective.com/davidmyersdev","https://patreon.com/davidmyersdev"],"categories":["Plugins"],"sub_categories":["Framework-agnostic Plugins"],"readme":"[![Sponsor me](https://img.shields.io/badge/sponsor-DB61A2?style=for-the-badge\u0026logo=GitHub-Sponsors\u0026logoColor=white)](https://voracious.link/sponsor)\n[![Donate](https://img.shields.io/badge/donate-FF5F5F?style=for-the-badge\u0026logo=ko-fi\u0026logoColor=white)](https://voracious.link/donate)\n\n# vite-plugin-node-polyfills\n\nA Vite plugin to polyfill Node's Core Modules for browser environments. Supports [`node:` protocol imports](https://nodejs.org/dist/latest-v16.x/docs/api/esm.html#node-imports).\n\n## Why do I need this?\n\n```\nModule \"stream\" has been externalized for browser compatibility. Cannot access \"stream.Readable\" in client code.\n```\n\nSince browsers do not support Node's [Core Modules](https://nodejs.org/dist/latest-v16.x/docs/api/modules.html#core-modules), packages that use them must be polyfilled to function in browser environments. In an attempt to prevent runtime errors, Vite produces [errors](https://github.com/vitejs/vite/issues/9200) or [warnings](https://github.com/vitejs/vite/pull/9837) when your code references builtin modules such as `fs` or `path`.\n\n## Getting Started\n\nInstall the package as a dev dependency.\n\n```sh\n# npm\nnpm install --save-dev vite-plugin-node-polyfills\n\n# pnpm\npnpm install --save-dev vite-plugin-node-polyfills\n\n# yarn\nyarn add --dev vite-plugin-node-polyfills\n```\n\nAdd the plugin to your `vite.config.ts` file.\n\n```ts\nimport { defineConfig } from 'vite'\nimport { nodePolyfills } from 'vite-plugin-node-polyfills'\n\n// https://vitejs.dev/config/\nexport default defineConfig({\n  plugins: [\n    nodePolyfills(),\n  ],\n})\n```\n\n### Customizable when you need it\n\nThe following options are available to customize it for your needs.\n\n```ts\nimport { defineConfig } from 'vite'\nimport { nodePolyfills } from 'vite-plugin-node-polyfills'\n\n// https://vitejs.dev/config/\nexport default defineConfig({\n  plugins: [\n    nodePolyfills({\n      // To add only specific polyfills, add them here. If no option is passed, adds all polyfills\n      include: ['path'],\n      // To exclude specific polyfills, add them to this list. Note: if include is provided, this has no effect\n      exclude: [\n        'http', // Excludes the polyfill for `http` and `node:http`.\n      ],\n      // Whether to polyfill specific globals.\n      globals: {\n        Buffer: true, // can also be 'build', 'dev', or false\n        global: true,\n        process: true,\n      },\n      // Override the default polyfills for specific modules.\n      overrides: {\n        // Since `fs` is not supported in browsers, we can use the `memfs` package to polyfill it.\n        fs: 'memfs',\n      },\n      // Whether to polyfill `node:` protocol imports.\n      protocolImports: true,\n    }),\n  ],\n})\n```\n\n### All polyfills\n\n- If protocolImports is true, also adds node:[module]\n\n```js\n[\n  '_stream_duplex',\n  '_stream_passthrough',\n  '_stream_readable',\n  '_stream_transform',\n  '_stream_writable',\n  'assert',\n  'buffer',\n  'child_process',\n  'cluster',\n  'console',\n  'constants',\n  'crypto',\n  'dgram',\n  'dns',\n  'domain',\n  'events',\n  'fs',\n  'http',\n  'http2',\n  'https',\n  'module',\n  'net',\n  'os',\n  'path',\n  'process',\n  'punycode',\n  'querystring',\n  'readline',\n  'repl',\n  'stream',\n  'string_decoder',\n  'sys',\n  'timers',\n  'timers/promises',\n  'tls',\n  'tty',\n  'url',\n  'util',\n  'vm',\n  'zlib',\n]\n```\n\n## About the author\n\nHello! My name is David, and in my spare time, I build tools to help developers be more productive. If you find my work valuable, I would really appreciate a [sponsorship](https://voracious.link/sponsor) or [donation](https://voracious.link/donate). If you want to see more of my work, check out [davidmyers.dev](https://davidmyers.dev).\n\nThanks for your support! 🪴\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidmyersdev%2Fvite-plugin-node-polyfills","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavidmyersdev%2Fvite-plugin-node-polyfills","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidmyersdev%2Fvite-plugin-node-polyfills/lists"}