 
 
 compileModuleTopLevel = (source, moduleName = '@unnamed', requiredMap = newMap()) ->
+  compileModuleTopLevelAst (astFromSource "(#{source})", -1, -1), moduleName, requiredMap
+
+compileModuleTopLevelAst = (ast, moduleName = '@unnamed', requiredMap = newMap()) ->
   addToMap requiredMap, 'Prelude', yes # TODO: Hardcoded prelude dependency
   removeFromMap requiredMap, moduleName
   for requiredModuleName of values requiredMap

  defaultImports = importsFor (subtractSets (newSetWith 'Prelude'), (newSetWith moduleName))
  declareImportedByDefault ctx, defaultImports
  compilationFn = (topLevelModule moduleName, defaultImports)
  {request, ast, ir, js} = compileCtxAstToJs compilationFn, ctx, (astFromSource "(#{source})", -1, -1)
  if request
    if not allInjected request, requiredMap
      return compileModuleTopLevel source, moduleName, request
    else
      {js} = compileCtxIrToJs ctx, ir
  errors = checkTypes ctx

    conflict.error = yes

lookupJs = (moduleName) ->
  compiled = (lookupCompiledModule moduleName)
  if not compiled
    console.error "#{moduleName} not found"
  else
    {js, ast} = compiled
    if not js?
      {js} = compileModuleTopLevelAst ast, moduleName
    js

allInjected = (required, injected) ->
