index.js 744 B

1234567891011121314151617181920212223242526
  1. var buble = require('./buble.js')
  2. // selectively support some handy ES2015 features in templates.
  3. var defaultOptions = {
  4. transforms: {
  5. modules: false,
  6. // this is a custom feature for stripping with from Vue render functions.
  7. stripWith: true,
  8. // custom feature ensures with context targets functional render
  9. stripWithFunctional: false
  10. },
  11. // allow spread...
  12. objectAssign: 'Object.assign'
  13. }
  14. module.exports = function transpile (code, opts) {
  15. if (opts) {
  16. opts = Object.assign({}, defaultOptions, opts)
  17. opts.transforms = Object.assign({}, defaultOptions.transforms, opts.transforms)
  18. } else {
  19. opts = defaultOptions
  20. }
  21. var code = buble.transform(code, opts).code
  22. // console.log(code)
  23. return code
  24. }