{"id":23410404,"url":"https://github.com/shaobeichen/babel-plugin-client-variable","last_synced_at":"2026-04-19T10:31:40.238Z","repository":{"id":269212191,"uuid":"836579255","full_name":"shaobeichen/babel-plugin-client-variable","owner":"shaobeichen","description":"Preventing client variables from reporting errors on the server is very useful in SSR. 防止客户端变量在服务端报错，在SSR里使用很有用。","archived":false,"fork":false,"pushed_at":"2024-08-13T04:09:17.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-03T11:38:33.175Z","etag":null,"topics":["babel","babel-plugin","client","server","ssr","variable","variables"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/shaobeichen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2024-08-01T06:33:40.000Z","updated_at":"2024-08-27T08:12:36.000Z","dependencies_parsed_at":"2024-12-21T20:19:48.712Z","dependency_job_id":"709e8902-6d1b-47c6-b309-660f9ff51917","html_url":"https://github.com/shaobeichen/babel-plugin-client-variable","commit_stats":null,"previous_names":["shaobeichen/babel-plugin-client-variable"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/shaobeichen/babel-plugin-client-variable","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shaobeichen%2Fbabel-plugin-client-variable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shaobeichen%2Fbabel-plugin-client-variable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shaobeichen%2Fbabel-plugin-client-variable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shaobeichen%2Fbabel-plugin-client-variable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shaobeichen","download_url":"https://codeload.github.com/shaobeichen/babel-plugin-client-variable/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shaobeichen%2Fbabel-plugin-client-variable/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32003993,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T20:23:30.271Z","status":"online","status_checked_at":"2026-04-19T02:00:07.110Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["babel","babel-plugin","client","server","ssr","variable","variables"],"created_at":"2024-12-22T17:22:42.520Z","updated_at":"2026-04-19T10:31:39.982Z","avatar_url":"https://github.com/shaobeichen.png","language":"JavaScript","readme":"# babel-plugin-client-variable\n\n## 安装\n\n使用 npm 安装\n\n```bash\nnpm install babel-plugin-client-variable -D\n```\n\n## 使用\n\n在 babel.config.js 中添加\n\n```diff\n+  const clientVariable = require('babel-plugin-client-variable');\n\nmodule.exports = {\n+  plugins: [\n+    clientVariable\n+  ]\n}\n```\n\n## 使用后效果\n\n使用前打包编译成\n\n```js\nfunction name1() {\n  const aaa = document.querySelector('body')\n  console.warn(aaa)\n}\n\nname1()\n```\n\n使用后打包编译成\n\n```js\nfunction name1() {\n  const aaa = process.client ? document.querySelector('body') : {}\n  console.warn(aaa)\n}\n\nname1()\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshaobeichen%2Fbabel-plugin-client-variable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshaobeichen%2Fbabel-plugin-client-variable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshaobeichen%2Fbabel-plugin-client-variable/lists"}