Closed prashaantt closed 8 years ago
Hmm. Babel registration needs to happen at the top level of your app (not in a plugin). You cannot guarantee the order in which plugins are called with manifests.
Have you checked out lab-babel
?
Thanks, I didn't know of lab-babel
, will check it out.
Meantime, I've been digging some more and transpiling ahead of time using the Babel API with a build tool (such as gulp) appears to be the better way, which also obviates this issue altogether.
I closed a little too soon, but I had a related question in mind. What would be your config to let hapi-react-views
use pre-transpiled JSX? I came up with this:
server.register(require('vision'), (err) => {
server.views({
engines: {
js: require('hapi-react-views')
}
});
}
But I don't know if this will lead to any performance issues since it might start looking at all .js files.
Seems like you got it right. You can make the extensions anything you want.
I recently opened an issue on Lab that doesn't seem to really have anything to do with it. Since I encountered this while working with
hapi-react-views
, I thought I'd throw this here too, just in case.Looks like Lab doesn't also report coverage errors if I comment out any fixtures in
hapi-react-views
itself. It begins to care about coverage only if I comment out therequire('babel-register')
(of course in addition to other test failures).In my own test project I've tried requiring
babel-register
inside of a dummy plugin, and then registering it at the end after all the other plugins:This somehow defers whatever's causing this issue and makes Lab start reporting coverage again. Would you know what may be the problem and if there's a better way to fix this?