Closed mjeanroy closed 1 year ago
The problem is that Loader
isn't nearly stable enough to be part of the public API. In particular, there's been a lot of change recently to how it interacts with its dependencies. I expect more of that in the months to come as we learn about more special cases related to ES modules. If we made Loader
public we'd likely to have to choose between doing much more frequent major releases and leaving ES module bugs un-fixed for years.
What we might consider doing is providing a way for users to supply their own loader, which would do the entire job that Loader
currently does. That's not risk-free (there's a bit more to the implicit contract between Loader
and Jasmine
than might be apparent at first glance) but it seems a lot safer than exposing Loader
.
Closing due to inactivity.
Hi,
Problem
I wanted to implement watching & hot reload and I faced an issue:
import
loading, unless you specifyjsLoader: 'require'
.require
loader, like with Jasmine < 4 by default, you need to be sure that the require cache is invalidated appropriatelyrequireShim
option hereProblem: even if it is possible by the API, it's not easy to override this option, as the loader cannot be imported by default as it is not in the
"exports"
field defined in package.json.If you try to import it using:
const Loader = require('jasmine/lib/loader.js')
, you will get this error:Workaround
The workaround I found is to require the
Loader
using an absolute path, for example:That's not great, and we can probably do better 😉
Suggestion
My suggestion would be to export
Loader
, exactly like theConsoleReporter
:So, we'll be able to do:
This way, it will be easier to implement hot-reloading, we just have to set the
requireShim
and we're good!❓ Would you be ok with a PR to export the
Loader
?