{"id":22018,"library":"rollup-plugin-external-globals","title":"rollup-plugin-external-globals","description":"A Rollup plugin that transforms external import statements (static and dynamic) into global variable references, similar to Rollup's built-in output.globals option but with broader support. Version 0.13.0 requires Rollup ^2.25.0 || ^3.3.0 || ^4.1.4. It uses a moduleId-to-variableName map (object or function) to rewrite imports to direct globals, helping in scenarios like bundling for browser environments where dependencies are loaded via script tags. Key differentiators: it works with dynamic imports, supports include/exclude patterns via picomatch, provides a custom dynamic wrapper, and can use const bindings via the constBindings option. It ships TypeScript types.","status":"active","version":"0.13.0","language":"javascript","source_language":"en","source_url":"https://github.com/eight04/rollup-plugin-external-globals","tags":["javascript","rollup-plugin","es","transform","external","globals","typescript"],"install":[{"cmd":"npm install rollup-plugin-external-globals","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-external-globals","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-external-globals","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency; plugin is designed to work with Rollup's build system","package":"rollup","optional":true}],"imports":[{"note":"Esm-only; CommonJS require is not supported","wrong":"const externalGlobals = require('rollup-plugin-external-globals')","symbol":"default","correct":"import externalGlobals from 'rollup-plugin-external-globals'"},{"note":"Named export 'createPlugin' is available, but default export is the same function (these are equivalent)","wrong":"","symbol":"createPlugin","correct":"import { createPlugin } from 'rollup-plugin-external-globals'"},{"note":"The package exports TypeScript types; import type for type declarations","wrong":"","symbol":"Plugin","correct":"import type { Plugin } from 'rollup-plugin-external-globals'"}],"quickstart":{"code":"import externalGlobals from 'rollup-plugin-external-globals';\n\nexport default {\n  input: 'src/index.js',\n  output: {\n    dir: 'dist',\n    format: 'es'\n  },\n  plugins: [\n    externalGlobals({\n      jquery: '$'\n    })\n  ]\n};","lang":"javascript","description":"Shows basic usage: map jquery import to global $ variable in a Rollup configuration."},"warnings":[{"fix":"If you rely on variable hoisting, the default `var` might be fine; if you need `const`, set `constBindings: true`. Avoid `export * from` with external globals.","message":"v0.12.0 changed variable declaration from `var` to `const`? Actually default is `var`, with `constBindings` option. Also throws on export all declaration.","severity":"breaking","affected_versions":">=0.12.0"},{"fix":"Update Rollup to version 4 or later.","message":"v0.9.0 bumped minimal Rollup version to 4.x.","severity":"breaking","affected_versions":">=0.9.0"},{"fix":"Place this plugin after rollup-plugin-commonjs or other CJS transformers.","message":"Plugin does not transform require() calls; only import/export statements.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Ensure the global variable returns the expected default or shape; consider setting `dynamicWrapper` to adjust.","message":"Dynamic import transformed to `Promise.resolve(global)` – the resolved object is always a module namespace, but global variable might not be.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Update include/exclude patterns to picomatch syntax if you were using older patterns.","message":"v0.13.0 changed include/exclude signature (now uses picomatch).","severity":"deprecated","affected_versions":">=0.13.0"}],"env_vars":null,"search_vec":"'0.13.0':35 '2.25.0':38 '3.3.0':39 '4.1.4':40 'bind':94 'broader':32 'browser':64 'built':26 'built-in':25 'bundl':62 'const':93 'constbind':97 'custom':87 'depend':67 'differenti':74 'direct':56 'dynam':16,78,88 'environ':65 'es':107 'extern':4,11,109 'function':51 'global':5,18,57,110 'help':58 'import':12,54,79 'include/exclude':81 'javascript':103 'key':73 'like':61 'load':69 'map':48 'moduleid':45 'moduleid-to-variablenam':44 'object':49 'option':29,98 'output.globals':28 'pattern':82 'picomatch':84 'plugin':3,8,106 'provid':85 'refer':20 'requir':36 'rewrit':53 'rollup':2,7,23,37,105 'rollup-plugin':104 'rollup-plugin-external-glob':1 'scenario':60 'script':71 'ship':100 'similar':21 'statement':13 'static':14 'support':33,80 'tag':72 'transform':10,108 'type':102 'typescript':101,111 'use':42,92 'variabl':19 'variablenam':47 'version':34 'via':70,83,95 'work':76 'wrapper':89","created_at":"2026-04-27T17:02:57.833595+00:00","updated_at":"2026-04-27T17:02:57.833595+00:00","problems":[{"fix":"Add the module to `output.globals` or ensure it's listed in `external` options.","cause":"The plugin marks the module as external but Rollup cannot resolve it because the module is not installed or not listed in external.","error":"Error: [plugin external-globals] Could not resolve import 'jquery'"},{"fix":"Set `dynamicWrapper` to a function that returns the global variable directly, e.g., `() => 'Promise.resolve({ default: myGlobal })'`.","cause":"Dynamic import transformation returns a global variable that is not an object with a default property, and the code expects a module namespace with default.","error":"TypeError: Cannot read properties of undefined (reading 'default')"},{"fix":"Upgrade Rollup to 3.x or 4.x, or downgrade plugin to 0.12.0.","cause":"Using version >=0.12.1 but Rollup version is 2.x where debug hook is not available.","error":"Error: Unknown plugin hook: 'debug'","affected_versions":">=0.12.1"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/eight04/rollup-plugin-external-globals","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/rollup-plugin-external-globals","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops","web-framework"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-18","next_check":"2026-07-26","install_tag":null}}