{"id":26552754,"url":"https://github.com/codex-/swc-plugin-import-meta-env","last_synced_at":"2025-03-22T08:49:28.859Z","repository":{"id":180029793,"uuid":"664405900","full_name":"Codex-/swc-plugin-import-meta-env","owner":"Codex-","description":"Simple @swc plugin to transform import.meta.env to process.env","archived":false,"fork":false,"pushed_at":"2025-03-19T21:00:39.000Z","size":1038,"stargazers_count":8,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-19T22:21:34.911Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","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/Codex-.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":null,"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},"funding":{"ko_fi":"codex0","open_collective":"codex-nz"}},"created_at":"2023-07-09T22:07:33.000Z","updated_at":"2025-03-19T21:00:40.000Z","dependencies_parsed_at":"2023-10-16T06:51:59.096Z","dependency_job_id":"7e9e4b1a-2608-49ee-8322-31275b3ea88f","html_url":"https://github.com/Codex-/swc-plugin-import-meta-env","commit_stats":null,"previous_names":["codex-/swc-plugin-import-meta-env"],"tags_count":60,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Codex-%2Fswc-plugin-import-meta-env","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Codex-%2Fswc-plugin-import-meta-env/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Codex-%2Fswc-plugin-import-meta-env/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Codex-%2Fswc-plugin-import-meta-env/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Codex-","download_url":"https://codeload.github.com/Codex-/swc-plugin-import-meta-env/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244931591,"owners_count":20534011,"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":"2025-03-22T08:49:28.426Z","updated_at":"2025-03-22T08:49:28.852Z","avatar_url":"https://github.com/Codex-.png","language":"Rust","funding_links":["https://ko-fi.com/codex0","https://opencollective.com/codex-nz"],"categories":[],"sub_categories":[],"readme":"# swc-plugin-import-meta-env\n\n\u003e Simple plugin to transform `import.meta.env` to `process.env`\n\n[![npm](https://img.shields.io/npm/v/swc-plugin-import-meta-env.svg)](https://www.npmjs.com/package/swc-plugin-import-meta-env)\n\nThis `@swc` plugin provides a simple transformation from `import.meta.env` to `process.env`.\n\nThe original purpose of this was to allow `@swc` usage in a large Jest test suite while also using Vite for bundling.\n\n## Install 🌱\n\n```shell\nnpm i -D swc-plugin-import-meta-env\n```\n\n## Usage 🚀\n\nSimply add this to the plugins field of your `.swcrc`.\n\n```json\n{\n  \"jsc\": {\n    \"experimental\": {\n      \"plugins\": [[\"swc-plugin-import-meta-env\", {}]]\n    }\n  }\n}\n```\n\nOr programmatically as an extension to your existing `.swcrc` parsing:\n\n```js\nconst swcrc = JSON.parse(fs.readFileSync(\".swcrc\", \"utf8\"));\n((swcrc.jsc ??= {}).experimental ??= {}).plugins = [\n  [\"swc-plugin-import-meta-env\", {}],\n]; // This may need updating to suit your requirements\n```\n\n## How do I populate my environment? 🤔\n\nThe purpose of this plugin currently is to keep this transformation simple. There are many tools and utilities to load `.env` files into your environment already, such as performing this during your `setupTests` phase of testing.\n\n- [`dotenv`](https://github.com/motdotla/dotenv)\n  - This is what [Vite itself uses to populate the env](https://vitejs.dev/guide/env-and-mode.html#env-files), so it makes sense to also do the same here.\n\nIf there is enough demand I can investigate adding this as core functionality to this plugin.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodex-%2Fswc-plugin-import-meta-env","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodex-%2Fswc-plugin-import-meta-env","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodex-%2Fswc-plugin-import-meta-env/lists"}