{"id":19291,"library":"babel-preset-evergreen","title":"babel-preset-evergreen","description":"A Babel preset targeting modern JavaScript (ES2024) with automatic polyfill management via core-js. Current version 0.11.13 requires @babel/core ^7.29.0 and Node >=20.18.0. Unlike other presets like @babel/preset-env, evergreen focuses on evergreen browsers and offers flexible polyfill strategies (global or pure) with mini-program support. Release cadence is irregular; package is part of the best-shot ecosystem.","status":"active","version":"0.11.13","language":"javascript","source_language":"en","source_url":"https://github.com/best-shot/babel-preset-evergreen","tags":["javascript","babel","babel-preset","best-shot","browser","core-js","evergreen","polyfill","preset"],"install":[{"cmd":"npm install babel-preset-evergreen","lang":"bash","label":"npm"},{"cmd":"yarn add babel-preset-evergreen","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-preset-evergreen","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency; required for Babel transformation","package":"@babel/core","optional":false}],"imports":[{"note":"In babel.config.json, the preset name is 'evergreen', not the full package name. Use 'evergreen' as the string in the presets array.","wrong":"{\n  \"presets\": [\"babel-preset-evergreen\"]\n}","symbol":"preset","correct":"{\n  \"presets\": [\"evergreen\"]\n}"},{"note":"The package is ESM-only since v0.11.0. Use import syntax in JS/TS files if programmatically accessing the preset. For babel.config.json, use the string syntax.","wrong":"const preset = require('babel-preset-evergreen');","symbol":"default","correct":"import preset from 'babel-preset-evergreen';"},{"note":"The option is 'polyfill', not 'useBuiltIns'. It supports sub-options 'usage' (global|pure), 'include', 'exclude', and 'mini'. The default is false (no polyfill).","wrong":"{\n  \"presets\": [\n    [\"evergreen\", { \"useBuiltIns\": \"usage\" }]\n  ]\n}","symbol":"polyfill option","correct":"{\n  \"presets\": [\n    [\"evergreen\", { \"polyfill\": { \"usage\": \"global\" } }]\n  ]\n}"}],"quickstart":{"code":"// Install: npm install babel-preset-evergreen @babel/core --save-dev\n// babel.config.json\n{\n  \"targets\": \"chrome >= 60\",\n  \"presets\": [\n    [\n      \"evergreen\",\n      {\n        \"polyfill\": {\n          \"usage\": \"global\"\n        }\n      }\n    ]\n  ]\n}\n// This config transforms modern JS and adds global polyfills for targets chrome >= 60.","lang":"javascript","description":"Configures Babel to transpile modern JS and add global polyfills for Chrome 60+."},"warnings":[{"fix":"Update Node to >=20.18.0 and @babel/core to ^7.29.0.","message":"Requires Node >=20.18.0 and @babel/core ^7.29.0. Older Node or Babel versions will fail.","severity":"breaking","affected_versions":">=0.11.0"},{"fix":"Use import or dynamic import. For babel config, use string preset name 'evergreen', not require().","message":"ESM-only since v0.11.0. CommonJS require() throws ERR_REQUIRE_ESM.","severity":"breaking","affected_versions":">=0.11.0"},{"fix":"Run: npm install core-js@3 --save-dev or pin in package.json.","message":"core-js@2 is not supported; peg core-js@3 to avoid polyfill conflicts.","severity":"deprecated","affected_versions":">=0.11.0"},{"fix":"Choose 'global' for CLIs/libraries, 'pure' for applications to avoid global scope pollution.","message":"When using polyfill option, 'usage: global' adds polyfills globally, possibly impacting other code. 'pure' adds per-file imports.","severity":"gotcha","affected_versions":">=0.11.0"},{"fix":"Avoid using polyfill.mini unless targeting miniprogram environments.","message":"The 'polyfill.mini' option enables miniprogram presets which are rarely used and may be dropped.","severity":"deprecated","affected_versions":">=0.11.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Rename file to babel.config.mjs or use the string preset name: \"presets\": [\"evergreen\"].","cause":"Using require() to load babel-preset-evergreen in babel.config.js (CommonJS) while package is ESM-only.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/babel-preset-evergreen/index.js from /path/to/project/babel.config.js not supported."},{"fix":"Use \"evergreen\" as the preset name. Babel resolves 'evergreen' to 'babel-preset-evergreen'.","cause":"Using the full package name (including 'babel-preset-') in the presets array instead of just 'evergreen'.","error":"Error: [BABEL] unknown preset: \"babel-preset-evergreen\""},{"fix":"Ensure babel.config.json exists with correct presets array and that Babel is run on the files.","cause":"Missing or incorrect Babel configuration; preset not applied.","error":"SyntaxError: Unexpected token 'export' (or modern feature not transpiled)"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}