Safe Haskell | None |
---|---|
Language | Haskell2010 |
Bundles compiled PureScript modules for the browser.
This module takes as input the individual generated modules from Make
and
performs dead code elimination, filters empty modules,
and generates the final JavaScript bundle.
Synopsis
- bundle :: MonadError ErrorMessage m => [(ModuleIdentifier, String)] -> [ModuleIdentifier] -> Maybe String -> String -> m String
- bundleSM :: MonadError ErrorMessage m => [(ModuleIdentifier, Maybe FilePath, String)] -> [ModuleIdentifier] -> Maybe String -> String -> Maybe FilePath -> m (Maybe SourceMapping, String)
- guessModuleIdentifier :: MonadError ErrorMessage m => FilePath -> m ModuleIdentifier
- data ModuleIdentifier = ModuleIdentifier String ModuleType
- moduleName :: ModuleIdentifier -> String
- data ModuleType
- data ErrorMessage
- printErrorMessage :: ErrorMessage -> [String]
- getExportedIdentifiers :: MonadError ErrorMessage m => String -> JSAST -> m [String]
Documentation
:: MonadError ErrorMessage m | |
=> [(ModuleIdentifier, String)] | The input modules. Each module should be javascript rendered from the compiler. |
-> [ModuleIdentifier] | Entry points. These module identifiers are used as the roots for dead-code elimination |
-> Maybe String | An optional main module. |
-> String | The namespace (e.g. PS). |
-> m String |
The bundling function. This function performs dead code elimination, filters empty modules and generates and prints the final JavaScript bundle.
:: MonadError ErrorMessage m | |
=> [(ModuleIdentifier, Maybe FilePath, String)] | The input modules. Each module should be javascript rendered from the compiler. |
-> [ModuleIdentifier] | Entry points. These module identifiers are used as the roots for dead-code elimination |
-> Maybe String | An optional main module. |
-> String | The namespace (e.g. PS). |
-> Maybe FilePath | The output file name (if there is one - in which case generate source map) |
-> m (Maybe SourceMapping, String) |
The bundling function. This function performs dead code elimination, filters empty modules and generates and prints the final JavaScript bundle.
guessModuleIdentifier :: MonadError ErrorMessage m => FilePath -> m ModuleIdentifier Source #
Given a filename, assuming it is in the correct place on disk, infer a ModuleIdentifier.
data ModuleIdentifier Source #
A module is identified by its module name and its type.
Instances
Eq ModuleIdentifier Source # | |
Defined in Language.PureScript.Bundle (==) :: ModuleIdentifier -> ModuleIdentifier -> Bool # (/=) :: ModuleIdentifier -> ModuleIdentifier -> Bool # | |
Ord ModuleIdentifier Source # | |
Defined in Language.PureScript.Bundle compare :: ModuleIdentifier -> ModuleIdentifier -> Ordering # (<) :: ModuleIdentifier -> ModuleIdentifier -> Bool # (<=) :: ModuleIdentifier -> ModuleIdentifier -> Bool # (>) :: ModuleIdentifier -> ModuleIdentifier -> Bool # (>=) :: ModuleIdentifier -> ModuleIdentifier -> Bool # max :: ModuleIdentifier -> ModuleIdentifier -> ModuleIdentifier # min :: ModuleIdentifier -> ModuleIdentifier -> ModuleIdentifier # | |
Show ModuleIdentifier Source # | |
Defined in Language.PureScript.Bundle showsPrec :: Int -> ModuleIdentifier -> ShowS # show :: ModuleIdentifier -> String # showList :: [ModuleIdentifier] -> ShowS # |
moduleName :: ModuleIdentifier -> String Source #
data ModuleType Source #
Modules are either "regular modules" (i.e. those generated by the PureScript compiler) or foreign modules.
Instances
Eq ModuleType Source # | |
Defined in Language.PureScript.Bundle (==) :: ModuleType -> ModuleType -> Bool # (/=) :: ModuleType -> ModuleType -> Bool # | |
Ord ModuleType Source # | |
Defined in Language.PureScript.Bundle compare :: ModuleType -> ModuleType -> Ordering # (<) :: ModuleType -> ModuleType -> Bool # (<=) :: ModuleType -> ModuleType -> Bool # (>) :: ModuleType -> ModuleType -> Bool # (>=) :: ModuleType -> ModuleType -> Bool # max :: ModuleType -> ModuleType -> ModuleType # min :: ModuleType -> ModuleType -> ModuleType # | |
Show ModuleType Source # | |
Defined in Language.PureScript.Bundle showsPrec :: Int -> ModuleType -> ShowS # show :: ModuleType -> String # showList :: [ModuleType] -> ShowS # |
data ErrorMessage Source #
The type of error messages. We separate generation and rendering of errors using a data type, in case we need to match on error types later.
UnsupportedModulePath String | |
InvalidTopLevel | |
UnableToParseModule String | |
UnsupportedExport | |
ErrorInModule ModuleIdentifier ErrorMessage | |
MissingEntryPoint String | |
MissingMainModule String |
Instances
Show ErrorMessage Source # | |
Defined in Language.PureScript.Bundle showsPrec :: Int -> ErrorMessage -> ShowS # show :: ErrorMessage -> String # showList :: [ErrorMessage] -> ShowS # |
printErrorMessage :: ErrorMessage -> [String] Source #
Prepare an error message for consumption by humans.
getExportedIdentifiers :: MonadError ErrorMessage m => String -> JSAST -> m [String] Source #