Registry / devops / babel-plugin-transform-cup-globals

babel-plugin-transform-cup-globals

JSON →
library1.0.2jsnpmunverified

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.

npm install babel-plugin-transform-cup-globals
INSTALL
IMPORT
SIG · BABEL-PLUGIN-TRANS
B
babel-plugin-transform-cup-globals
devopsjavascriptv1.0.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default (plugin)
module.exports = require('babel-plugin-transform-cup-globals'); // or in .babelrc: "plugins": ["transform-cup-globals"]
import plugin from 'babel-plugin-transform-cup-globals';
The package does not export ES modules; uses CommonJS. Importing via ES import will fail unless using a bundler that can handle CJS interop.
plugin reference in Babel config
// .babelrc { "plugins": ["transform-cup-globals"] }
{ "plugins": [["babel-plugin-transform-cup-globals", "some-option"]] }
The plugin accepts no options; passing arguments may cause errors.

Demonstrates installing the plugin and configuring Babel to transform CUP globals like __BROWSER__ into boolean literals.

// Install: npm install --save-dev babel-plugin-transform-cup-globals // Then add to .babelrc: { "plugins": ["transform-cup-globals"] } // Input: const isBrowser = __BROWSER__; // Output: const isBrowser = true; // or false, depending on environment
Debug
Known issues
gotchaPlugin 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.
fix
If not using CUP, consider alternatives like babel-plugin-transform-define or setting environment-specific globals via DefinePlugin.
affects: >=0.0.0
breakingIncompatible with Babel 7+ if the plugin explicitly checks for Babel 6 API. The last release predates Babel 7 and may rely on deprecated APIs.
fix
Use a newer Babel 6 environment or adapt the plugin source code for Babel 7+.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Cannot find module 'babel-plugin-transform-cup-globals'
Plugin not installed or not in node_modules.
fix
Run npm install --save-dev babel-plugin-transform-cup-globals
TypeError: this.plugin is not a function
Plugin is not properly registered in Babel config.
fix
Ensure plugin is listed as a string in the plugins array, e.g., "plugins": ["transform-cup-globals"]
Upgrade
Version history
1.0.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
7 hits · last 30 days
node
6
Resources
babel-plugin-transform-cup-globals — npm install babel-plugin-transform-cup-globals · libregistry