{"id":28972548,"url":"https://github.com/ember-cli/babel-plugin-debug-macros","last_synced_at":"2025-06-24T11:06:55.178Z","repository":{"id":53677635,"uuid":"80555843","full_name":"ember-cli/babel-plugin-debug-macros","owner":"ember-cli","description":null,"archived":false,"fork":false,"pushed_at":"2024-07-11T16:14:23.000Z","size":687,"stargazers_count":13,"open_issues_count":12,"forks_count":15,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-06-14T04:39:31.682Z","etag":null,"topics":["babel","debugging","feature-flags","macros"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/ember-cli.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"zenodo":null},"funding":{"github":"emberjs","open_collective":"emberjs"}},"created_at":"2017-01-31T19:50:43.000Z","updated_at":"2024-07-11T16:13:37.000Z","dependencies_parsed_at":"2025-04-22T05:34:49.600Z","dependency_job_id":null,"html_url":"https://github.com/ember-cli/babel-plugin-debug-macros","commit_stats":{"total_commits":154,"total_committers":15,"mean_commits":"10.266666666666667","dds":0.577922077922078,"last_synced_commit":"f40c21bdd5d6332ae1862826ed9127317a1778a6"},"previous_names":["chadhietala/babel-debug-macros"],"tags_count":38,"template":false,"template_full_name":null,"purl":"pkg:github/ember-cli/babel-plugin-debug-macros","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ember-cli%2Fbabel-plugin-debug-macros","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ember-cli%2Fbabel-plugin-debug-macros/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ember-cli%2Fbabel-plugin-debug-macros/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ember-cli%2Fbabel-plugin-debug-macros/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ember-cli","download_url":"https://codeload.github.com/ember-cli/babel-plugin-debug-macros/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ember-cli%2Fbabel-plugin-debug-macros/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260577397,"owners_count":23030727,"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":["babel","debugging","feature-flags","macros"],"created_at":"2025-06-24T11:06:54.529Z","updated_at":"2025-06-24T11:06:55.167Z","avatar_url":"https://github.com/ember-cli.png","language":"TypeScript","funding_links":["https://github.com/sponsors/emberjs","https://opencollective.com/emberjs"],"categories":[],"sub_categories":[],"readme":"# Babel Debug Macros And Feature Flags\n\nThis provides debug macros and feature flagging.\n\n## Setup\n\nThe plugin takes 4 types options: `flags`, `svelte`, `debugTools`, and\n`externalizeHelpers`. The `importSpecifier` is used as a hint to this plugin as\nto where macros are being imported and completely configurable by the host.\n\nLike Babel you can supply your own helpers using the `externalizeHelpers`\noptions.\n\n```js\n{\n  plugins: [\n    ['babel-plugin-debug-macros', {\n      // @optional\n      debugTools: {\n        isDebug: true,\n        source: 'debug-tools',\n        // @optional\n        assertPredicateIndex: 0\n      },\n\n      flags: [\n        { source: '@ember/env-flags', flags: { DEBUG: true } },\n        {\n          name: 'ember-source',\n          source: '@ember/features',\n          flags: {\n            FEATURE_A: false,\n            FEATURE_B: true,\n            DEPRECATED_CONTROLLERS: \"2.12.0\"\n          }\n        }\n      ],\n\n      // @optional\n      svelte: {\n        'ember-source': \"2.15.0\"\n      },\n\n      // @optional\n      externalizeHelpers: {\n        module: true,\n        // global: '__my_global_ns__'\n      }\n    }]\n  ]\n}\n```\n\nFlags and features are inlined into the consuming module so that something like UglifyJS will DCE them when they are unreachable.\n\n## Simple environment and feature flags\n\n```javascript\nimport { DEBUG } from '@ember/env-flags';\nimport { FEATURE_A, FEATURE_B } from '@ember/features';\n\nif (DEBUG) {\n  console.log('Hello from debug');\n}\n\nlet woot;\nif (FEATURE_A) {\n  woot = () =\u003e 'woot';\n} else if (FEATURE_B) {\n  woot = () =\u003e 'toow';\n}\n\nwoot();\n```\n\nTransforms to:\n\n```javascript\nif (true /* DEBUG */) {\n  console.log('Hello from debug');\n}\n\nlet woot;\nif (false /* FEATURE_A */) {\n  woot = () =\u003e 'woot';\n} else if (true) {\n  woot = () =\u003e 'toow';\n}\n\nwoot();\n```\n\n## `warn` macro expansion\n\n```javascript\nimport { warn } from 'debug-tools';\n\nwarn('this is a warning');\n```\n\nExpands into:\n\n```javascript\n(true \u0026\u0026 console.warn('this is a warning'));\n```\n\n## `assert` macro expansion\n\nThe `assert` macro can expand in a more intelligent way with the correct\nconfiguration. When `babel-plugin-debug-macros` is provided with the\n`assertPredicateIndex` the predicate is injected in front of the assertion\nin order to avoid costly assertion message generation when not needed.\n\n```javascript\nimport { assert } from 'debug-tools';\n\nassert((() =\u003e {\n  return 1 === 1;\n})(), 'You bad!');\n```\n\nWith the `debugTools: { assertPredicateIndex: 0 }` configuration the following expansion is done:\n\n```js\n(true \u0026\u0026 !((() =\u003e { return 1 === 1;})()) \u0026\u0026 console.assert(false, 'this is a warning'));\n```\n\nWhen `assertPredicateIndex` is not specified, the following expansion is done:\n\n```javascript\n(true \u0026\u0026 console.assert((() =\u003e { return 1 === 1;})(), 'this is a warning'));\n```\n\n## `deprecate` macro expansion\n\n```javascript\nimport { deprecate } from 'debug-tools';\n\nlet foo = 2;\n\ndeprecate('This is deprecated.', foo % 2);\n```\n\nExpands into:\n\n```javascript\nlet foo = 2;\n\n(true \u0026\u0026 !(foo % 2) \u0026\u0026 console.warn('This is deprecated.'));\n```\n\n## Externalized Helpers\n\nWhen you externalize helpers you must provide runtime implementations for the\nabove macros. An expansion will still occur, however we will emit references to\nthose runtime helpers.\n\nA global expansion looks like the following:\n\n```javascript\nimport { warn } from 'debug-tools';\n\nwarn('this is a warning');\n```\n\nExpands into:\n\n```javascript\n(true \u0026\u0026 Ember.warn('this is a warning'));\n```\n\nWhile externalizing the helpers to a module looks like the following:\n\n```javascript\nimport { warn } from 'debug-tools';\n\nwarn('this is a warning');\n```\n\nExpands into:\n\n```javascript\n(true \u0026\u0026 warn('this is a warning'));\n```\n\n# Svelte\n\nSvelte allows for consumers to opt into stripping deprecated code from your\ndependecies. By adding a package name and minimum version that contains no\ndeprecations, that code will be compiled away.\n\nFor example, consider you are on `ember-source@2.10.0` and you have no\ndeprecations. All deprecated code in `ember-source` that is `\u003c=2.10.0` will be\nremoved.\n\n```\n\nsvelte: {\n  \"ember-source\": \"2.10.0\"\n}\n\n```\n\nNow if you bump to `ember-source@2.11.0` you may encounter new deprecations.\nThe workflow would then be to clear out all deprecations and then bump the\nversion in the `svelte` options.\n\n```\nsvelte: {\n  \"ember-source\": \"2.11.0\"\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fember-cli%2Fbabel-plugin-debug-macros","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fember-cli%2Fbabel-plugin-debug-macros","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fember-cli%2Fbabel-plugin-debug-macros/lists"}