babel-preset-rsmax
raw JSON → 1.3.14 verified Sat Apr 25 auth: no javascript
Babel preset for Remax, a framework for building mini-programs (WeChat, Alipay, etc.) with React. This package (v1.3.14, stable, actively maintained) provides a pre-configured Babel transform pipeline for Remax projects, including JSX handling, TypeScript support, and environment-specific optimizations. Differentiates from generic Babel presets by tailoring transforms for mini-program runtime constraints and Remax's React-like API.
Common errors
error Cannot find module 'babel-preset-rsmax' ↓
cause The package is not installed or is not in node_modules.
fix
Run 'npm install babel-preset-rsmax --save-dev' or 'yarn add babel-preset-rsmax --dev'.
error TypeError: Cannot read property 'bind' of undefined ↓
cause Incorrect usage of preset with object spread without proper configuration.
fix
Ensure you pass options as object in array: ['babel-preset-rsmax', { pluginTarget: 'wechat' }]
error Error: Cannot find module '@babel/core' ↓
cause @babel/core is not installed.
fix
Run 'npm install @babel/core --save-dev'.
error SyntaxError: Unexpected token (1:1) ↓
cause Using wrong file extension or missing parser plugins.
fix
Make sure your file has extension .js/.jsx/.ts/.tsx and that Babel is configured with correct presets.
Warnings
gotcha Preset options must be passed as an array, e.g., ['babel-preset-rsmax', { ... }]. Omitting options can cause unexpected behavior. ↓
fix Always use array syntax with options object, even if empty: ['babel-preset-rsmax', {}]
breaking Version 2.x removed support for React Native and focuses only on mini-programs. Existing projects may break if they rely on the old behavior. ↓
fix Update your project to target mini-programs only, or stick with v1.x if you need React Native support.
deprecated The `importStyle` option was deprecated in v1.2.0 and removed in v2.0.0. Avoid using it. ↓
fix Remove `importStyle` from preset options. Use separate Babel plugins for style imports if needed.
gotcha The preset may not work with Babel versions <7.4.0 due to dependency on `@babel/helper-plugin-utils`. ↓
fix Upgrade @babel/core to at least 7.4.0.
Install
npm install babel-preset-rsmax yarn add babel-preset-rsmax pnpm add babel-preset-rsmax Imports
- default wrong
import preset from 'babel-preset-rsmax';correctmodule.exports = require('babel-preset-rsmax');
Quickstart
// babel.config.js
module.exports = {
presets: [
['babel-preset-rsmax', {
pluginTarget: 'wechat', // or 'alipay', 'toutiao', etc.
typescript: true,
removePropTypes: process.env.NODE_ENV === 'production'
}]
]
};