index.js 690 B

123456789101112131415161718192021222324
  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. }
  12. module.exports = function transpile (code, opts) {
  13. if (opts) {
  14. opts = Object.assign({}, defaultOptions, opts)
  15. opts.transforms = Object.assign({}, defaultOptions.transforms, opts.transforms)
  16. } else {
  17. opts = defaultOptions
  18. }
  19. var code = buble.transform(code, opts).code
  20. // console.log(code)
  21. return code
  22. }