@weva/babel-plugin-transform-mina-exports
v0.0.3
Published
escape from mina Page/Component
Downloads
2
Maintainers
Readme
wrap default exports with Page/Component (or whatever you want)
Usage
yarn add -D @weva/babel-plugin-transform-mina-exports
// src/lib/page
exports.Page = ({ ...props }) => {
return {
onLoad(query) {
this.$query = decode(query)
props.onLoad.call(this, this.$query)
},
...rest,
}
}
// src/pages/index/index.js
// or 'export default { ... }'
module.exports = {
onLoad() {
// ...
}
}
// src/component/a/a.js
module.exports = {
properties: {},
/* ... */
}
// babel config
{
// ...
plugins: [
['@weva/transform-mina-module-exports', {
rules: [
{
files: ['pages/*/*.js'],
wrap: {
file: 'src/lib/page',
exports: 'Page',
},
},
{
files: ['components/*/*.js'],
wrap: 'Component',
},
],
}]
]
}
// src/pages/index/index.js
require('../../lib/page').Page({
onLoad() {
// ...
}
})
// src/components/a/a.js
Component({
properties: {}
})
License
MIT