{"id":19039,"library":"babel-plugin-define-var","title":"babel-plugin-define-var","description":"A Babel plugin (v0.1.0) that adds missing variable declarations in the root scope after wyw-in-js pre-evaluation removes some identifiers, fixing '_c is not defined' errors. Useful for projects using MUI system, emotion, or styled-components with React Refresh (Next.js, Vite). The plugin is minimal and specific—there are no alternatives with the same narrow fix. Release cadence is low; this is the only version. No breaking changes expected due to simple scope.","status":"active","version":"0.1.0","language":"javascript","source_language":"en","source_url":"https://github.com/siriwatknp/babel-plugin-define-var","tags":["javascript","typescript"],"install":[{"cmd":"npm install babel-plugin-define-var","lang":"bash","label":"npm"},{"cmd":"yarn add babel-plugin-define-var","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-plugin-define-var","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Babel plugin API dependency, used at runtime","package":"@babel/core","optional":false}],"imports":[{"note":"ESM only; no named export.","wrong":"const plugin = require('babel-plugin-define-var')","symbol":"default","correct":"import plugin from 'babel-plugin-define-var'"},{"note":"Configure via string in Babel config, not imported directly.","wrong":"","symbol":"plugin","correct":"// .babelrc\n{\n  \"plugins\": [\"babel-plugin-define-var\"]\n}"},{"note":"In CommonJS, must use .default because plugin is a default export.","wrong":"const plugin = require('babel-plugin-define-var')","symbol":"plugin","correct":"const plugin = require('babel-plugin-define-var').default"}],"quickstart":{"code":"// Install first: npm install babel-plugin-define-var\n// .babelrc\n{\n  \"plugins\": [\"babel-plugin-define-var\"]\n}\n// Or in babel.config.js:\nmodule.exports = {\n  plugins: ['babel-plugin-define-var'],\n};\n// The plugin will automatically add missing var declarations like '_c = ...'","lang":"javascript","description":"Configures Babel plugin to fix missing variable declarations after wyw-in-js pre-evaluation with React Refresh."},"warnings":[{"fix":"Check plugin source or file an issue if nested vars are missing.","message":"Plugin only targets root scope; if missing declarations are nested, it won't fix them.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Ensure wyw-in-js is in your Babel chain and produces the missing var problem.","message":"Only works when wyw-in-js is used; plugin does nothing otherwise.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Add babel-plugin-define-var to your Babel plugins.","cause":"wyw-in-js pre-evaluation removes variable declaration for '_c' when paired with React Refresh.","error":"_c is not defined"},{"fix":"Add babel-plugin-define-var to your Babel plugins.","cause":"Same as above but for second variable.","error":"_c1 is not defined"},{"fix":"Ensure React Refresh is properly set up (e.g., in Next.js or Vite) and wyw-in-js config removes it.","cause":"React Refresh global not available during wyw-in-js evaluation; plugin does not fix this.","error":"$RefreshReg$ is not defined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}