{"id":16900501,"url":"https://github.com/btipling/iso-babel","last_synced_at":"2025-07-02T09:34:04.317Z","repository":{"id":57277999,"uuid":"44891308","full_name":"btipling/iso-babel","owner":"btipling","description":"iso-babel is a Babel plugin that helps you solve server or client only problems in isomorphic code bases.","archived":false,"fork":false,"pushed_at":"2015-10-26T05:01:34.000Z","size":176,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T05:06:09.740Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/btipling.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}},"created_at":"2015-10-25T01:02:51.000Z","updated_at":"2016-08-09T06:44:55.000Z","dependencies_parsed_at":"2022-09-13T19:02:59.577Z","dependency_job_id":null,"html_url":"https://github.com/btipling/iso-babel","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/btipling%2Fiso-babel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/btipling%2Fiso-babel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/btipling%2Fiso-babel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/btipling%2Fiso-babel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/btipling","download_url":"https://codeload.github.com/btipling/iso-babel/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247339135,"owners_count":20923009,"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-10-13T17:54:58.777Z","updated_at":"2025-04-05T12:42:27.971Z","avatar_url":"https://github.com/btipling.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"#iso-babel\n\nThis package is a [Babel](https://github.com/babel/babel) plugin that lets you target the\nserver or client directly in isomorphic JavaScript.\n\nFor example this:\n\n```javascript\nimport {isServer, isClient} from 'iso-babel';\n\nif (isServer) {\n  console.log(isServer);\n}\nif (isClient) {\n  console.log(isClient);\n}\n```\n\n...becomes this on the server:\n\n```javascript\nimport {isServer} from 'iso-babel';\n\nconsole.log(isServer);\n```\n\n...and becomes this on the client:\n\n```javascript\nimport {isClient} from 'iso-babel';\n\nconsole.log(isClient);\n```\n\nThis also works:\n\n```\nif (isServer) {\n  console.log('This is the server.');\n} else {\n  console.log('We are running on client!');\n}\n```\n\nThis is too:\n\n```\nif (isServer) {\n  console.log(isServer);\n} else if (isClient) {\n  console.log(isClient);\n  if (isServer) {\n    // This code will never appear anywhere or run.\n  }\n} else {\n  console.log('This code will never appear anywhere and will never run.');\n}\n```\n\n##Usage\n\n```\nnpm i iso-babel\n```\nFor server:\n```bash\nbabel --plugins iso-babel/is-server myscript.js \u003e server.js\n```\nFor client:\n```bash\nbabel --plugins iso-babel/is-client myscript.js \u003e client.js\n```\n\nFrom JavaScript:\n\n```javascript\nconst fs = require('fs');\nconst babel = require('babel')\n\nfs.readFile('./example.js', 'utf8', (err, contents) =\u003e {\n\n  const result = babel.transform(contents, {\n    plugins: ['iso-babel/is-server'],\n  });\n\n  fs.writeFile('./bundle.js', result.code, {encoding: 'utf8'}, err =\u003e {\n    if (err) {\n      console.log('Received an error', err);\n      process.exit(1);\n    }\n  });\n});\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbtipling%2Fiso-babel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbtipling%2Fiso-babel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbtipling%2Fiso-babel/lists"}