wepy-compiler-babel
raw JSON → 1.5.3 verified Mon Apr 27 auth: no javascript maintenance
Babel compiler plugin for the WePY framework (v1.5.3). This package integrates Babel into WePY's build pipeline, allowing ES2015+ syntax transpilation for WePY projects. It is specifically designed for WePY 1.x and offers configuration via `wepy.config.js`. Unlike generic Babel setups, this plugin seamlessly works with WePY's compilation system. Release cadence is low; the package has been stable with infrequent updates. Key differentiator: tailored for WePY's compiler lifecycle hooks.
Common errors
error Error: Cannot find module 'babel-core' ↓
cause Missing Babel core dependency (peer dependency not installed)
fix
npm install babel-core --save-dev
error Error: Plugin/Preset files are not allowed to export objects, only functions. ↓
cause Using a Babel 7 preset (e.g., @babel/preset-env) with Babel 6 core
fix
Use Babel 6 presets (e.g., 'es2015', 'stage-1') or upgrade to wepy-compiler-babel with Babel 7 support.
Warnings
deprecated Babel presets 'es2015', 'stage-1' are deprecated in Babel 7+ ↓
fix Use @babel/preset-env and @babel/plugin-transform-runtime, and update wepy-compiler-babel if compatible.
gotcha This package only works with WePY 1.x; not compatible with WePY 2.x (wepy-cli v2) ↓
fix For WePY 2.x, use wepy-compiler-babel version that supports @wepy/cli or use built-in babel support.
breaking Requires Node.js 6+ due to Babel peer dependencies ↓
fix Upgrade Node.js to version 6 or later.
Install
npm install wepy-compiler-babel yarn add wepy-compiler-babel pnpm add wepy-compiler-babel Imports
- wepy-compiler-babel wrong
import wepyCompilerBabel from 'wepy-compiler-babel'correct// In wepy.config.js: module.exports = { compilers: { babel: {} } }
Quickstart
// Install: npm install wepy-compiler-babel --save-dev
// wepy.config.js
module.exports = {
compilers: {
babel: {
presets: ['es2015', 'stage-1'],
plugins: [
'transform-export-extensions',
'syntax-export-extensions',
'transform-runtime'
]
}
}
};