Safe Haskell | None |
---|---|
Language | Haskell2010 |
Language.PureScript.Bundle
Description
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
Arguments
:: 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.
Arguments
:: 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.
Constructors
ModuleIdentifier String ModuleType |
Instances
Eq ModuleIdentifier Source # | |
Defined in Language.PureScript.Bundle Methods (==) :: ModuleIdentifier -> ModuleIdentifier -> Bool # (/=) :: ModuleIdentifier -> ModuleIdentifier -> Bool # | |
Ord ModuleIdentifier Source # | |
Defined in Language.PureScript.Bundle Methods 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 Methods 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 | |
Ord ModuleType Source # | |
Defined in Language.PureScript.Bundle Methods 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 Methods 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.
Constructors
UnsupportedModulePath String | |
InvalidTopLevel | |
UnableToParseModule String | |
UnsupportedExport | |
ErrorInModule ModuleIdentifier ErrorMessage | |
MissingEntryPoint String | |
MissingMainModule String |
Instances
Show ErrorMessage Source # | |
Defined in Language.PureScript.Bundle Methods 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 #