{"id":13680510,"url":"https://github.com/FormidableLabs/babel-plugin-transform-define","last_synced_at":"2025-04-29T23:31:57.736Z","repository":{"id":5942256,"uuid":"54291452","full_name":"FormidableLabs/babel-plugin-transform-define","owner":"FormidableLabs","description":"Compile time code replacement for babel similar to Webpack's DefinePlugin","archived":false,"fork":false,"pushed_at":"2024-12-19T17:56:28.000Z","size":1450,"stargazers_count":245,"open_issues_count":7,"forks_count":31,"subscribers_count":43,"default_branch":"master","last_synced_at":"2025-04-29T01:42:11.493Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FormidableLabs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2016-03-19T23:18:20.000Z","updated_at":"2025-03-03T15:56:57.000Z","dependencies_parsed_at":"2024-06-16T15:02:01.729Z","dependency_job_id":"98d9b4d1-a1f7-4c8e-933c-e43aa6b0075f","html_url":"https://github.com/FormidableLabs/babel-plugin-transform-define","commit_stats":{"total_commits":94,"total_committers":22,"mean_commits":"4.2727272727272725","dds":0.6595744680851063,"last_synced_commit":"808eb232a7be73c991d253346dbf8da596800126"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FormidableLabs%2Fbabel-plugin-transform-define","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FormidableLabs%2Fbabel-plugin-transform-define/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FormidableLabs%2Fbabel-plugin-transform-define/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FormidableLabs%2Fbabel-plugin-transform-define/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FormidableLabs","download_url":"https://codeload.github.com/FormidableLabs/babel-plugin-transform-define/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251600401,"owners_count":21615702,"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-08-02T13:01:17.893Z","updated_at":"2025-04-29T23:31:52.727Z","avatar_url":"https://github.com/FormidableLabs.png","language":"JavaScript","readme":"\u003ca href=\"https://formidable.com/open-source/\" target=\"_blank\"\u003e\n  \u003cimg alt=\"Babel Plugin Transform Define — Formidable, We build the modern web\" src=\"https://raw.githubusercontent.com/FormidableLabs/babel-plugin-transform-define/master/babel-plugin-transform-define-Hero.png\" /\u003e\n\u003c/a\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca title='Build Status' href=\"https://raw.githubusercontent.com/FormidableLabs/babel-plugin-transform-define/master/LICENSE\"\u003e\n    \u003cimg src='https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square' /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://badge.fury.io/js/babel-plugin-transform-define\"\u003e\n    \u003cimg src=\"https://badge.fury.io/js/babel-plugin-transform-define.svg\" alt=\"npm version\" height=\"18\"\u003e\n  \u003c/a\u003e\n  \u003ca href='https://github.com/FormidableLabs/babel-plugin-transform-define/actions'\u003e\n    \u003cimg src='https://github.com/FormidableLabs/babel-plugin-transform-define/workflows/CI/badge.svg' /\u003e\n  \u003c/a\u003e\n  \u003ca href='https://github.com/FormidableLabs/babel-plugin-transform-define#maintenance-status'\u003e\n    \u003cimg alt=\"Maintenance Status\" src='https://img.shields.io/badge/maintenance-stable-yellow.svg?color=yellow\u0026style=flat' /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n\u003ch4 align=\"center\"\u003e\n  Compile time code replacement for babel similar to Webpack's \u003ca href='https://webpack.js.org/plugins/define-plugin/'\u003eDefinePlugin\u003c/a\u003e\n\u003c/h4\u003e\n\n***\n\n## Quick Start\n\n```shell\n$ npm install --save-dev babel-plugin-transform-define\n```\n\n**.babelrc**\n\n```json\n{\n  \"plugins\": [\n    [\"transform-define\", {\n      \"process.env.NODE_ENV\": \"production\",\n      \"typeof window\": \"object\"\n    }]\n  ]\n}\n```\n\n**.babelrc.js**\n\n```js\n// E.g., any dynamic logic with JS, environment variables, etc.\nconst overrides = require(\"./another-path.js\");\n\nmodule.exports = {\n  plugins: [\n    [\"transform-define\", {\n      \"process.env.NODE_ENV\": \"production\",\n      \"typeof window\": \"object\",\n      ...overrides\n    }]\n  ]\n};\n```\n\n## Reference Documentation\n\n`babel-plugin-transform-define` can transform certain types of code as a babel transformation.\n\n##### `Identifiers`\n\n*.babelrc*\n```json\n{\n  \"plugins\": [\n    [\"transform-define\", {\n      \"VERSION\": \"1.0.0\",\n    }]\n  ]\n}\n```\n\n*Source Code*\n```js\nVERSION;\n\nwindow.__MY_COMPANY__ = {\n  version: VERSION\n};\n```\n\n*Output Code*\n```js\n\"1.0.0\";\n\nwindow.__MY_COMPANY__ = {\n  version: \"1.0.0\"\n};\n```\n***\n##### `Member Expressions`\n\n*.babelrc*\n```json\n{\n  \"plugins\": [\n    [\"transform-define\", {\n      \"process.env.NODE_ENV\": \"production\"\n    }]\n  ]\n}\n```\n\n*Source Code*\n```js\nif (process.env.NODE_ENV === \"production\") {\n  console.log(true);\n}\n```\n\n*Output Code*\n```js\nif (true) {\n  console.log(true);\n}\n```\n***\n##### `Unary Expressions`\n\n*.babelrc*\n```json\n{\n  \"plugins\": [\n    [\"transform-define\", {\n      \"typeof window\": \"object\"\n    }]\n  ]\n}\n```\n\n*Source Code*\n```js\ntypeof window;\ntypeof window === \"object\";\n```\n\n*Output Code*\n```js\n'object';\ntrue;\n```\n\n\n***\n\n## License\n\n[MIT License](http://opensource.org/licenses/MIT)\n\n\n## Maintenance Status\n\n**Stable:** Formidable is not planning to develop any new features for this project. We are still responding to bug reports and security concerns. We are still welcoming PRs for this project, but PRs that include new features should be small and easy to integrate and should not include breaking changes.\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FFormidableLabs%2Fbabel-plugin-transform-define","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FFormidableLabs%2Fbabel-plugin-transform-define","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FFormidableLabs%2Fbabel-plugin-transform-define/lists"}