{"id":22295,"library":"rollup-plugin-wp-resolve","title":"rollup-plugin-wp-resolve","description":"A Rollup plugin that externalizes WordPress and Gutenberg dependencies, converting imports like '@wordpress/components' to global 'wp.*' globals (e.g., 'wp.components.ToggleControl'). Works with Rollup >=1.0.0. Inspired by WordPress dependency-extraction-webpack-plugin, it automatically handles @wordpress/* packages and common bundled libraries (jQuery, lodash, moment, React, ReactDOM). Avoids issues with camelCase conversions since v1.0.8. Stable at v1.0.9 but no recent updates; does not generate PHP dependency files for block registration.","status":"active","version":"1.0.9","language":"javascript","source_language":"en","source_url":"https://github.com/kshaner/rollup-plugin-wp-resolve","tags":["javascript","rollup","plugin","wordpress","gutenberg"],"install":[{"cmd":"npm install rollup-plugin-wp-resolve","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-wp-resolve","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-wp-resolve","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency for Rollup plugin runtime","package":"rollup","optional":false}],"imports":[{"note":"ESM-only package; CommonJS require will fail.","wrong":"const wpResolve = require('rollup-plugin-wp-resolve');","symbol":"wpResolve","correct":"import wpResolve from 'rollup-plugin-wp-resolve';"},{"note":"Default export only; named import will be undefined.","wrong":"import { wpResolve } from 'rollup-plugin-wp-resolve';","symbol":"default","correct":"import wpResolve from 'rollup-plugin-wp-resolve';"},{"note":"Namespace import results in { default: ... }. Use default import instead.","wrong":"import * as wpResolve from 'rollup-plugin-wp-resolve';","symbol":"wpResolve","correct":"import wpResolve from 'rollup-plugin-wp-resolve';"}],"quickstart":{"code":"import wpResolve from 'rollup-plugin-wp-resolve';\n\nexport default {\n  input: 'src/index.js',\n  output: {\n    dir: 'output',\n    format: 'iife'\n  },\n  plugins: [wpResolve()]\n};","lang":"javascript","description":"Basic Rollup configuration using wpResolve to externalize WordPress dependencies to global wp.* variables."},"warnings":[{"fix":"Consider using @wordpress/dependency-extraction-webpack-plugin with webpack or migrating to a maintained alternative.","message":"Package has not been updated since 2020; may not support latest Rollup versions.","severity":"deprecated","affected_versions":">=1.0.9"},{"fix":"Upgrade to >=1.0.8","message":"Versions < 1.0.8 had a camelCasing bug that mapped 'wp.i18n' to 'wp.i18N' for certain imports.","severity":"breaking","affected_versions":"<1.0.8"},{"fix":"Manually add wp_deregister_script / wp_register_script calls, or use dependency-extraction-webpack-plugin if PHP output is needed.","message":"Does not generate PHP files for block registration; only externalizes dependencies in the Rollup output.","severity":"gotcha","affected_versions":"all"},{"fix":"Use the 'include' or 'exclude' options if available, but the plugin has no such configuration. Extend by forking or using other tools.","message":"Only converts known @wordpress/* packages and a limited set of third-party libraries (jQuery, lodash, moment, React, ReactDOM).","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use import statement or configure Node.js to support ESM.","cause":"Using CommonJS require() on an ESM-only package.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module ... from ... not supported."},{"fix":"Change to: import wpResolve from 'rollup-plugin-wp-resolve';","cause":"Using named import { wpResolve } instead of default import wpResolve.","error":"TypeError: wpResolve is not a function"},{"fix":"Ensure WordPress backend enqueues necessary scripts (wp-editor, wp-components, etc.) via wp_enqueue_script or register_block_type.","cause":"Global 'wp' object not available at runtime because WordPress script enqueuing is missing.","error":"Unresolved import: @wordpress/... (missing global variable wp...)"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}