git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Default require path to ../, warn from psc
8735fb0Nicholas Wolverson
psc-bundle/Main.hs+1−2
@@ -119,8 +119,7 @@ options = Options <$> some inputFile
119 requirePath = strOption $
119 requirePath = strOption $
120 short 'r'
120 short 'r'
121 <> long "require-path"
121 <> long "require-path"
122− <> Opts.value ""
123− <> help "The path prefix used in require() calls in the generated JavaScript"
122+ <> help "The path prefix used in require() calls in the generated JavaScript [deprecated]"
124
123
125-- | Make it go.
124-- | Make it go.
126main :: IO ()
125main :: IO ()
psc/Main.hs+1−1
@@ -138,7 +138,7 @@ requirePath :: Parser (Maybe FilePath)
138requirePath = optional $ strOption $
138requirePath = optional $ strOption $
139 short 'r'
139 short 'r'
140 <> long "require-path"
140 <> long "require-path"
141− <> help "The path prefix to use for require() calls in the generated JavaScript"
141+ <> help "The path prefix to use for require() calls in the generated JavaScript [deprecated]"
142
142
143noTco :: Parser Bool
143noTco :: Parser Bool
144noTco = switch $
144noTco = switch $
src/Language/PureScript/Bundle.hs+1−1
@@ -141,7 +141,7 @@ checkImportPath :: Maybe FilePath -> String -> ModuleIdentifier -> S.Set String
141checkImportPath _ "./foreign" m _ =
141checkImportPath _ "./foreign" m _ =
142 Right (ModuleIdentifier (moduleName m) Foreign)
142 Right (ModuleIdentifier (moduleName m) Foreign)
143checkImportPath requirePath name _ names
143checkImportPath requirePath name _ names
144− | Just name' <- stripPrefix (fromMaybe "" requirePath) name
144+ | Just name' <- stripPrefix (fromMaybe "../" requirePath) name
145 , name' `S.member` names = Right (ModuleIdentifier name' Regular)
145 , name' `S.member` names = Right (ModuleIdentifier name' Regular)
146checkImportPath _ name _ _ = Left name
146checkImportPath _ name _ _ = Left name
147
147
src/Language/PureScript/CodeGen/JS.hs+1−1
@@ -111,7 +111,7 @@ moduleToJs (Module coms mn imps exps foreigns decls) foreign_ =
111 importToJs mnLookup mn' = do
111 importToJs mnLookup mn' = do
112 path <- asks optionsRequirePath
112 path <- asks optionsRequirePath
113 let ((ss, _, _, _), mnSafe) = fromMaybe (internalError "Missing value in mnLookup") $ M.lookup mn' mnLookup
113 let ((ss, _, _, _), mnSafe) = fromMaybe (internalError "Missing value in mnLookup") $ M.lookup mn' mnLookup
114− let moduleBody = JSApp Nothing (JSVar Nothing "require") [JSStringLiteral Nothing (maybe id (</>) path $ runModuleName mn')]
114+ let moduleBody = JSApp Nothing (JSVar Nothing "require") [JSStringLiteral Nothing (fromMaybe ".." path </> runModuleName mn')]
115 withPos ss $ JSVariableIntroduction Nothing (moduleNameToJs mnSafe) (Just moduleBody)
115 withPos ss $ JSVariableIntroduction Nothing (moduleNameToJs mnSafe) (Just moduleBody)
116
116
117 -- |
117 -- |
src/Language/PureScript/Errors.hs+5
@@ -148,6 +148,7 @@ data SimpleErrorMessage
148 | CaseBinderLengthDiffers Int [Binder]
148 | CaseBinderLengthDiffers Int [Binder]
149 | IncorrectAnonymousArgument
149 | IncorrectAnonymousArgument
150 | InvalidOperatorInBinder Ident Ident
150 | InvalidOperatorInBinder Ident Ident
151+ | DeprecatedRequirePath
151 deriving (Show)
152 deriving (Show)
152
153
153-- | Error message hints, providing more detailed information about failure.
154-- | Error message hints, providing more detailed information about failure.
@@ -328,6 +329,7 @@ errorCode em = case unwrapErrorMessage em of
328 CaseBinderLengthDiffers{} -> "CaseBinderLengthDiffers"
329 CaseBinderLengthDiffers{} -> "CaseBinderLengthDiffers"
329 IncorrectAnonymousArgument -> "IncorrectAnonymousArgument"
330 IncorrectAnonymousArgument -> "IncorrectAnonymousArgument"
330 InvalidOperatorInBinder{} -> "InvalidOperatorInBinder"
331 InvalidOperatorInBinder{} -> "InvalidOperatorInBinder"
332+ DeprecatedRequirePath{} -> "DeprecatedRequirePath"
331
333
332-- |
334-- |
333-- A stack trace for an error
335-- A stack trace for an error
@@ -974,6 +976,9 @@ prettyPrintSingleError full level showWiki e = flip evalState defaultUnknownMap
974 , line "Only aliases for data constructors may be used in patterns."
976 , line "Only aliases for data constructors may be used in patterns."
975 ]
977 ]
976
978
979+ renderSimpleErrorMessage DeprecatedRequirePath =
980+ line "The require-path option is deprecated and will be removed in PureScript 0.9."
981+
977 renderHint :: ErrorMessageHint -> Box.Box -> Box.Box
982 renderHint :: ErrorMessageHint -> Box.Box -> Box.Box
978 renderHint (ErrorUnifyingTypes t1 t2) detail =
983 renderHint (ErrorUnifyingTypes t1 t2) detail =
979 paras [ detail
984 paras [ detail
src/Language/PureScript/Make.hs+3
@@ -150,6 +150,9 @@ make :: forall m. (Monad m, MonadBaseControl IO m, MonadReader Options m, MonadE
150 -> [Module]
150 -> [Module]
151 -> m Environment
151 -> m Environment
152make MakeActions{..} ms = do
152make MakeActions{..} ms = do
153+ requirePath <- asks optionsRequirePath
154+ when (requirePath /= Nothing) $ tell $ errorMessage DeprecatedRequirePath
155+
153 checkModuleNamesAreUnique
156 checkModuleNamesAreUnique
154
157
155 (sorted, graph) <- sortModules ms
158 (sorted, graph) <- sortModules ms