@@ -34,7 +34,7 @@ import Prelude ()
3434import Prelude.Compat
3535
3636import Data.List (nub, stripPrefix)
37−import Data.Maybe (mapMaybe, catMaybes, fromMaybe)
37+import Data.Maybe (mapMaybe, catMaybes)
3838import Data.Generics (everything, everywhere, mkQ, mkT)
3939import Data.Graph
4040import Data.Version (showVersion)
@@ -134,13 +134,13 @@ printErrorMessage (ErrorInModule mid e) =
134134 name ++ " (" ++ showModuleType ty ++ ")"
135135
136136-- | Calculate the ModuleIdentifier which a require(...) statement imports.
137−checkImportPath :: Maybe FilePath -> String -> ModuleIdentifier -> S.Set String -> Either String ModuleIdentifier
138−checkImportPath _ "./foreign" m _ =
137+checkImportPath :: String -> ModuleIdentifier -> S.Set String -> Either String ModuleIdentifier
138+checkImportPath "./foreign" m _ =
139139 Right (ModuleIdentifier (moduleName m) Foreign)
140−checkImportPath requirePath name _ names
141− | Just name' <- stripPrefix (fromMaybe "../" requirePath) name
140+checkImportPath name _ names
141+ | Just name' <- stripPrefix "../" name
142142 , name' `S.member` names = Right (ModuleIdentifier name' Regular)
143−checkImportPath _ name _ _ = Left name
143+checkImportPath name _ _ = Left name
144144
145145-- | Compute the dependencies of all elements in a module, and add them to the tree.
146146--
@@ -222,8 +222,8 @@ trailingCommaList (JSCTLNone l) = commaList l
222222--
223223-- Each type of module element is matched using pattern guards, and everything else is bundled into the
224224-- Other constructor.
225−toModule :: forall m. (MonadError ErrorMessage m) => Maybe FilePath -> S.Set String -> ModuleIdentifier -> JSAST -> m Module
226−toModule requirePath mids mid top
225+toModule :: forall m. (MonadError ErrorMessage m) => S.Set String -> ModuleIdentifier -> JSAST -> m Module
226+toModule mids mid top
227227 | JSAstProgram smts _ <- top = Module mid <$> traverse toModuleElement smts
228228 | otherwise = err InvalidTopLevel
229229 where
@@ -231,7 +231,7 @@ toModule requirePath mids mid top
231231
232232 toModuleElement :: JSStatement -> m ModuleElement
233233 toModuleElement stmt
234− | Just (importName, importPath) <- matchRequire requirePath mids mid stmt
234+ | Just (importName, importPath) <- matchRequire mids mid stmt
235235 = pure (Require stmt importName importPath)
236236 toModuleElement stmt
237237 | Just (exported, name, decl) <- matchMember stmt
@@ -291,12 +291,11 @@ getExportedIdentifiers mname top
291291
292292-- Matches JS statements like this:
293293-- var ModuleName = require("file");
294−matchRequire :: Maybe FilePath
295− -> S.Set String
294+matchRequire :: S.Set String
296295 -> ModuleIdentifier
297296 -> JSStatement
298297 -> Maybe (String, Either String ModuleIdentifier)
299−matchRequire requirePath mids mid stmt
298+matchRequire mids mid stmt
300299 | JSVariable _ jsInit _ <- stmt
301300 , [JSVarInitExpression var varInit] <- commaList jsInit
302301 , JSIdentifier _ importName <- var
@@ -304,7 +303,7 @@ matchRequire requirePath mids mid stmt
304303 , JSMemberExpression req _ argsE _ <- jsInitEx
305304 , JSIdentifier _ "require" <- req
306305 , [ Just importPath ] <- map fromStringLiteral (commaList argsE)
307− , importPath' <- checkImportPath requirePath importPath mid mids
306+ , importPath' <- checkImportPath importPath mid mids
308307 = Just (importName, importPath')
309308 | otherwise
310309 = Nothing
@@ -590,16 +589,15 @@ bundle :: (MonadError ErrorMessage m)
590589 -> [ModuleIdentifier] -- ^ Entry points. These module identifiers are used as the roots for dead-code elimination
591590 -> Maybe String -- ^ An optional main module.
592591 -> String -- ^ The namespace (e.g. PS).
593− -> Maybe FilePath -- ^ The require path prefix
594592 -> m String
595−bundle inputStrs entryPoints mainModule namespace requirePath = do
593+bundle inputStrs entryPoints mainModule namespace = do
596594 input <- forM inputStrs $ \(ident, js) -> do
597595 ast <- either (throwError . ErrorInModule ident . UnableToParseModule) pure $ parse js (moduleName ident)
598596 return (ident, ast)
599597
600598 let mids = S.fromList (map (moduleName . fst) input)
601599
602− modules <- traverse (fmap withDeps . uncurry (toModule requirePath mids)) input
600+ modules <- traverse (fmap withDeps . uncurry (toModule mids)) input
603601
604602 let compiled = compile modules entryPoints
605603 sorted = sortModules (filter (not . isModuleEmpty) compiled)