@@ -7,13 +7,14 @@ module Try.Loader
77import Prelude
88
99import Control.Bind (bindFlipped )
10- import Control.Monad.Except (ExceptT )
10+ import Control.Monad.Except (ExceptT , throwError )
1111import Control.Parallel (parTraverse )
12+ import Data.Array (foldMap )
1213import Data.Array as Array
1314import Data.Array.NonEmpty as NonEmpty
1415import Data.Maybe (Maybe (..), fromMaybe )
1516import Data.Newtype (unwrap )
16- import Data.String (Pattern (..))
17+ import Data.String (Pattern (..), joinWith )
1718import Data.String as String
1819import Data.String.Regex (Regex )
1920import Data.String.Regex as Regex
@@ -112,10 +113,20 @@ makeLoader rootPath = Loader (go Object.empty <<< parseDeps "<file>")
112113 deps = { name: _, path: Nothing } <$> shim.deps
113114 pure { name, path, deps, src }
114115 Nothing ->
115- pure { name, path, deps: [] , src: ffiDep name }
116+ throwError (missingFFIDep name)
116117 liftEffect $ putModule name mod
117118 pure mod
118119
120+ missingFFIDep :: String -> String
121+ missingFFIDep name =
122+ joinWith " \n " $
123+ [ " Compilation succeeded, but the following FFI dependency is missing:"
124+ , " - " <> name
125+ , " "
126+ , " We don't provide FFI shims for all libraries; for example, Node libraries are not supported on Try PureScript."
127+ , " If you would like to suggest a new FFI shim be supported, please open an issue."
128+ ]
129+
119130 go :: Object JS -> Array Dependency -> ExceptT String Aff (Object JS )
120131 go ms [] = pure ms
121132 go ms deps = do
@@ -130,6 +141,3 @@ makeLoader rootPath = Loader (go Object.empty <<< parseDeps "<file>")
130141 # bindFlipped _.deps
131142 # Array .nubBy (comparing _.name)
132143 # go ms'
133-
134- ffiDep :: String -> JS
135- ffiDep name = JS $ " throw new Error('FFI dependency not provided: " <> name <> " ');"
0 commit comments