 
 
 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

    conflict.error = yes

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

allInjected = (required, injected) ->

  defaultImports = importsFor (subtractSets (newSetWith 'Prelude'), (newSetWith moduleName))
  declareImportedByDefault ctx, defaultImports
  compilationFn = (topLevelModule moduleName, defaultImports)
  {request, ir, js} = compileCtxAstToJs compilationFn, ctx, ast
  if request
    if not allInjected request, requiredMap
      return compileModuleTopLevelAst ast, moduleName, request
    else
      {js} = compileCtxIrToJs ctx, ir
  errors = checkTypes ctx
