{"id":26781,"library":"babel-plugin-transform-cup-globals","title":"babel-plugin-transform-cup-globals","description":"Babel plugin that transforms global references for create-universal-package (CUP). At version 1.0.2 (last released in 2019), it is in maintenance mode with no active development. Converts environment-specific globals (e.g., `__BROWSER__`, `__SERVER__`) to boolean literals at compile time. Compared to general-purpose Babel macros or DefinePlugin, this plugin is tightly coupled to CUP and may not work with newer Babel versions (v7+). Requires Node >=6 and a Babel preset or plugin pipeline that invokes it before other transforms.","status":"maintenance","version":"1.0.2","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/rtsao/create-universal-package","tags":["javascript"],"install":[{"cmd":"npm install babel-plugin-transform-cup-globals","lang":"bash","label":"npm"},{"cmd":"yarn add babel-plugin-transform-cup-globals","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-plugin-transform-cup-globals","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The package does not export ES modules; uses CommonJS. Importing via ES import will fail unless using a bundler that can handle CJS interop.","wrong":"import plugin from 'babel-plugin-transform-cup-globals';","symbol":"default (plugin)","correct":"module.exports = require('babel-plugin-transform-cup-globals');\n// or in .babelrc: \"plugins\": [\"transform-cup-globals\"]"},{"note":"The plugin accepts no options; passing arguments may cause errors.","wrong":"{\n  \"plugins\": [[\"babel-plugin-transform-cup-globals\", \"some-option\"]]\n}","symbol":"plugin reference in Babel config","correct":"// .babelrc\n{\n  \"plugins\": [\"transform-cup-globals\"]\n}"}],"quickstart":{"code":"// Install: npm install --save-dev babel-plugin-transform-cup-globals\n// Then add to .babelrc:\n{\n  \"plugins\": [\"transform-cup-globals\"]\n}\n// Input:\nconst isBrowser = __BROWSER__;\n// Output:\nconst isBrowser = true; // or false, depending on environment","lang":"javascript","description":"Demonstrates installing the plugin and configuring Babel to transform CUP globals like __BROWSER__ into boolean literals."},"warnings":[{"fix":"If not using CUP, consider alternatives like babel-plugin-transform-define or setting environment-specific globals via DefinePlugin.","message":"Plugin is designed specifically for create-universal-package (CUP). It may not work correctly in other Babel setups, especially if custom global definitions are not provided.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use a newer Babel 6 environment or adapt the plugin source code for Babel 7+.","message":"Incompatible with Babel 7+ if the plugin explicitly checks for Babel 6 API. The last release predates Babel 7 and may rely on deprecated APIs.","severity":"breaking","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run npm install --save-dev babel-plugin-transform-cup-globals","cause":"Plugin not installed or not in node_modules.","error":"Error: Cannot find module 'babel-plugin-transform-cup-globals'"},{"fix":"Ensure plugin is listed as a string in the plugins array, e.g., \"plugins\": [\"transform-cup-globals\"]","cause":"Plugin is not properly registered in Babel config.","error":"TypeError: this.plugin is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}