/* @flow */

import { extend } from 'shared/util'
import { compile as baseCompile, baseOptions } from 'weex/compiler/index'
import { detectErrors } from 'compiler/error-detector'

export function compile (
  template: string,
  options?: CompilerOptions
): CompiledResult {
  options = options || {}
  const errors = []
  // allow injecting modules/directives
  const baseModules = baseOptions.modules || []
  const modules = options.modules
    ? baseModules.concat(options.modules)
    : baseModules
  const directives = options.directives
    ? extend(extend({}, baseOptions.directives), options.directives)
    : baseOptions.directives
  const compiled = baseCompile(template, {
    modules,
    directives,
    warn: msg => {
      errors.push(msg)
    }
  })
  compiled.errors = errors.concat(detectErrors(compiled.ast))
  return compiled
}

@@ -10,838 +10,50 @@
 */%0A%0A
-import %7B extend %7D from 'shared/util'%0Aimport %7B compile as baseCompile, baseOptions %7D from 'weex/compiler/index'%0Aimport %7B detectErrors %7D from 'compiler/error-detector'%0A%0Aexport function compile (%0A  template: string,%0A  options?: CompilerOptions%0A): CompiledResult %7B%0A  options = options %7C%7C %7B%7D%0A  const errors = %5B%5D%0A  // allow injecting modules/directives%0A  const baseModules = baseOptions.modules %7C%7C %5B%5D%0A  const modules = options.modules%0A    ? baseModules.concat(options.modules)%0A    : baseModules%0A  const directives = options.directives%0A    ? extend(extend(%7B%7D, baseOptions.directives), options.directives)%0A    : baseOptions.directives%0A  const compiled = baseCompile(template, %7B%0A    modules,%0A    directives,%0A    warn: msg =%3E %7B%0A      errors.push(msg)%0A    %7D%0A  %7D)%0A  compiled.errors = errors.concat(detectErrors(compiled.ast))%0A  return compiled%0A%7D
+export %7B compile %7D from 'weex/compiler/index'
 %0A

fix weex tests