{"id":19055,"library":"babel-plugin-extensible-destructuring","title":"babel-plugin-extensible-destructuring","description":"Babel plugin that transforms destructuring assignments to calls to a runtime function, enabling custom behavior like Immutable.js support or safe access (avoiding undefined). Version 4.3.1 works with Babel 6 and 7 (using full plugin name for Babel 7). It requires the separate runtime package `extensible-runtime` and offers three implementations: normal (ES6 compatible), immutable (for Immutable.js Maps/Lists), and safe (default, prevents undefined returns). Provides opt-in/opt-out per-file modes for gradual adoption.","status":"active","version":"4.3.1","language":"javascript","source_language":"en","source_url":"https://github.com/vacuumlabs/babel-plugin-extensible-destructuring","tags":["javascript","babel-plugin","destructuring"],"install":[{"cmd":"npm install babel-plugin-extensible-destructuring","lang":"bash","label":"npm"},{"cmd":"yarn add babel-plugin-extensible-destructuring","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-plugin-extensible-destructuring","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Provides the runtime `__extensible_get__` function used by the transformed code.","package":"extensible-runtime","optional":false}],"imports":[{"note":"For Babel 6, use short name 'extensible-destructuring'. For Babel 7, use full name 'babel-plugin-extensible-destructuring'.","wrong":"// Wrong: using 'babel-plugin-extensible-destructuring' with Babel 6 (works but not short name)\n{\n  \"plugins\": [\"babel-plugin-extensible-destructuring\"]\n}","symbol":"plugin","correct":"// .babelrc\n{\n  \"plugins\": [\"extensible-destructuring\"]\n}"},{"note":"Options must be passed as an array inside the plugins array: [ [pluginName, options] ].","wrong":"// Wrong: omitting double array brackets\n{\n  \"plugins\": [\"extensible-destructuring\", { \"mode\": \"optin\" }]\n}","symbol":"plugin with options","correct":"// .babelrc\n{\n  \"plugins\": [[\"extensible-destructuring\", { \"mode\": \"optin\", \"impl\": \"safe\" }]]\n}"},{"note":"In opt-in mode, you must add 'use extensible' at the top of each file to enable transformation.","wrong":"// Wrong: misspelling\n'use extansible';\nvar {a} = obj;","symbol":"use extensible directive","correct":"// top of file\n'use extensible';\n\nvar {a} = obj;"}],"quickstart":{"code":"// Install dependencies\n// npm install --save-dev babel-plugin-extensible-destructuring\n// npm install --save extensible-runtime\n\n// .babelrc\n{\n  \"presets\": [\"@babel/preset-env\"],\n  \"plugins\": [\"babel-plugin-extensible-destructuring\"]\n}\n\n// src/index.js (opt-in mode by default)\n'use extensible';\nimport { fromJS } from 'immutable';\nconst map = fromJS({ author: { name: { first: \"John\", last: \"Doe\" }, birthdate: \"10-10-2010\" } });\nconst { author: { name: { first, last }, birthdate } } = map;\nconsole.log(first, last, birthdate); // John Doe 10-10-2010","lang":"javascript","description":"Demonstrates setup with Babel 7 and immutable mode destructuring of an Immutable.js Map."},"warnings":[{"fix":"Use 'babel-plugin-extensible-destructuring' in plugins array for Babel 7.","message":"Babel 7 requires full plugin name 'babel-plugin-extensible-destructuring' instead of 'extensible-destructuring'.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Run npm install --save extensible-runtime.","message":"You must install both the plugin and runtime package: 'extensible-runtime' is required at runtime.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Add 'use extensible'; at the beginning of each file, or set mode to 'optout' in options.","message":"Opt-in mode is default; destructuring will not be transformed unless 'use extensible' directive is at top of file.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"npm install --save extensible-runtime","cause":"Runtime package not installed.","error":"Error: Cannot find module 'extensible-runtime'"},{"fix":"Ensure both plugin and runtime are installed and Babel is configured correctly.","cause":"Missing runtime import or Babel not transforming correctly.","error":"ReferenceError: __extensible_get__ is not defined"},{"fix":"Safe mode only prevents undefined; for null, use a default value or check beforehand.","cause":"Using safe mode but the value is null, not undefined.","error":"TypeError: Cannot destructure property 'x' of 'undefined' or 'null'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}