Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include full file path in CJS requires. #3314

Merged
merged 1 commit into from Apr 23, 2018
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Include full file path in CJS requires.

  • Loading branch information...
chexxor committed Apr 21, 2018
commit 1fce3ccaba051d4146b51cdcce625b1f356ffe8c
@@ -104,7 +104,8 @@ moduleToJs (Module coms mn _ imps exps foreigns decls) foreign_ =
importToJs :: M.Map ModuleName (Ann, ModuleName) -> ModuleName -> m AST
importToJs mnLookup mn' = do
let ((ss, _, _, _), mnSafe) = fromMaybe (internalError "Missing value in mnLookup") $ M.lookup mn' mnLookup
let moduleBody = AST.App Nothing (AST.Var Nothing "require") [AST.StringLiteral Nothing (fromString (".." </> T.unpack (runModuleName mn')))]
let moduleBody = AST.App Nothing (AST.Var Nothing "require")
[AST.StringLiteral Nothing (fromString (".." </> T.unpack (runModuleName mn') </> "index.js"))]
withPos ss $ AST.VariableIntroduction Nothing (moduleNameToJs mnSafe) (Just moduleBody)

-- | Replaces the `ModuleName`s in the AST so that the generated code refers to
@@ -148,7 +148,7 @@ buildMakeActions outputDir filePathMap foreigns usePrefix =
return Nothing
| otherwise -> do
checkForeignDecls modSS m path
return $ Just $ Imp.App Nothing (Imp.Var Nothing "require") [Imp.StringLiteral Nothing "./foreign"]
return $ Just $ Imp.App Nothing (Imp.Var Nothing "require") [Imp.StringLiteral Nothing "./foreign.js"]
Nothing | requiresForeign m -> throwError . errorMessage' modSS $ MissingFFIModule mn
| otherwise -> return Nothing
rawJs <- J.moduleToJs m foreignInclude
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.