@weva/babel-plugin-transform-mina-exports
escape from mina Page/Component
Last updated 6 months ago by hehex .
MIT · Original npm · Tarball · package.json
$ cnpm install @weva/babel-plugin-transform-mina-exports 
SYNC missed versions from official npm registry.

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

Current Tags

  • 0.0.3                                ...           latest (6 months ago)

3 Versions

  • 0.0.3                                ...           6 months ago
  • 0.0.2                                ...           6 months ago
  • 0.0.1                                ...           6 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (0)
None
Dependents (1)

Copyright 2014 - 2017 © taobao.org |