{"id":20493,"library":"rax-miniapp-babel-plugins","title":"Rax MiniApp Babel Plugins","description":"A collection of Babel plugins for optimizing Rax mini-program (MiniApp) applications, version 0.2.0. These plugins enable pre-compilation analysis to determine used lifecycle methods, built-in components, and native/npm components, reducing runtime overhead and eliminating dead code. Part of the Rax MiniApp ecosystem, maintained for Alibaba-affiliated mini-program platforms. Key differentiator: performance optimization via compile-time introspection, avoiding full lifecycle registration and component tree traversal common in alternative solutions. Last updated 2022-05-17, with maintenance focused on bug fixes (event handling, WeChat map component).","status":"maintenance","version":"0.2.0","language":"javascript","source_language":"en","source_url":"https://github.com/raxjs/miniapp","tags":["javascript","rax","babel","babel-plugins"],"install":[{"cmd":"npm install rax-miniapp-babel-plugins","lang":"bash","label":"npm"},{"cmd":"yarn add rax-miniapp-babel-plugins","lang":"bash","label":"yarn"},{"cmd":"pnpm add rax-miniapp-babel-plugins","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency for Babel plugin functionality","package":"babel","optional":true}],"imports":[{"note":"CommonJS import; no ESM default export documented.","symbol":"default","correct":"const plugin = require('rax-miniapp-babel-plugins')"},{"note":"ESM import may not be supported; prefer CommonJS.","wrong":"import { NativeLifeCycle } from 'rax-miniapp-babel-plugins'","symbol":"NativeLifeCycle","correct":"const { NativeLifeCycle } = require('rax-miniapp-babel-plugins')"},{"note":"Direct destructuring works; no default export.","wrong":"const UsedBuiltInComponents = require('rax-miniapp-babel-plugins').UsedBuiltInComponents","symbol":"UsedBuiltInComponents","correct":"const { UsedBuiltInComponents } = require('rax-miniapp-babel-plugins')"}],"quickstart":{"code":"// babel.config.js\nmodule.exports = {\n  plugins: [\n    [require('rax-miniapp-babel-plugins').NativeLifeCycle, {}],\n    [require('rax-miniapp-babel-plugins').UsedBuiltInComponents, {}],\n  ],\n};","lang":"javascript","description":"Shows how to configure Babel with NativeLifeCycle and UsedBuiltInComponents plugins for Rax MiniApp optimization."},"warnings":[{"fix":"Upgrade to Babel 7 and use version 0.2.0 of this package.","message":"Requires Babel 7+; not compatible with Babel 6.","severity":"breaking","affected_versions":"<0.1.0"},{"fix":"Consider using `rax-miniapp-runtime-webpack-plugin` instead for automated configuration.","message":"Plugin configuration may be replaced by higher-level Rax CLI tools; manual Babel setup discouraged.","severity":"deprecated","affected_versions":">=0.2.0"},{"fix":"Ensure the plugins array order in babel.config.js matches documentation.","message":"Plugins must be applied in order: first NativeLifeCycle, then UsedBuiltInComponents.","severity":"gotcha","affected_versions":">=0.2.0"},{"fix":"Verify your target platform is supported; if not, seek alternative optimization methods.","message":"Only supports Alibaba-affiliated mini-program platforms (WeChat, ByteDance, Baidu, Kuaishou, Alipay); not for generic web or Node.js.","severity":"gotcha","affected_versions":">=0.2.0"},{"fix":"Use standard Rax lifecycle names: `onShow`, `onHide`, `onLoad`, etc.","message":"NativeLifeCycle plugin expects lifecycle names in camelCase; incorrect casing fails silently.","severity":"breaking","affected_versions":">=0.2.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run `npm install rax-miniapp-babel-plugins --save-dev` and ensure path is correct.","cause":"Package not installed or incorrectly referenced in babel.config.js.","error":"Error: Cannot find module 'rax-miniapp-babel-plugins'"},{"fix":"Use `require('rax-miniapp-babel-plugins').NativeLifeCycle` instead of `require('rax-miniapp-babel-plugins')` directly.","cause":"Using a default export different from CommonJS require; Babel expects a function.","error":"Plugin/Preset files are not allowed to export objects, only functions."},{"fix":"Ensure version >=0.2.0; if not, update package. Check package.json \"main\" field.","cause":"Package exports incorrect structure; possibly due to version mismatch.","error":"TypeError: Cannot read property 'NativeLifeCycle' of undefined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}