hapijs / good

hapi process monitoring
Other
525 stars 160 forks source link

Webpack integreation #602

Closed no-more closed 5 years ago

no-more commented 5 years ago

Hi,

I'm trying to use this plugin with webpack but I'm stuck with module parameter. The module parameter seems to only accept a string, and I suppose the module is loader automatically. But this is not compatible with webpack which does not allow dynamic require.

myConsoleReporter: [{
    module: require("good-squeeze"), // what I would expect to work but not allowed by good
    name: "Squeeze",
    args: [{ log: "*", response: "*" }]
}, {
    module: "good-console" // not compatible with webpack
}, "stdout" // probably not compatible with webpack too
],

this is the error i have if I use a syntax compatible with webpack:

AssertionError [ERR_ASSERTION]: Invalid monitorOptions options child "reporters" fails because [child "myConsoleReporter" fails because ["myConsoleReporter" at position 0 does not match any of the allowed types]]

this is the error I have if I use string : Error: Cannot find module 'good-squeeze'

Thank you very much for any help, I currently can't use good anymore.

no-more commented 5 years ago

never mind I manage to found the right syntax:

myConsoleReporter: [{
    module: require("good-squeeze").Squeeze,
    // name: "Squeeze",
    args: [{ log: "*", response: "*" }]
}, {
    module: require("good-console")
}, "stdout"],

Maybe this should be in the docs too.

Marsup commented 5 years ago

This point doesn't need documentation as it's already documented. The examples work perfectly fine, so if you alter them you obviously have to read the full docs to understand what you're doing first.

Also, good is not a frontend module, so there's no point in documenting webpack usage from our point of view.

no-more commented 5 years ago

Thanks for taking time to reply me,

But I didn't find the information in the document, I looked in the source code to try to understand what was going on and found out this syntax. If it's in the doc I wasn't able to find the information.

About webpack, as this syntax works it's fine with webpack. Why I'm using webpack ? because, as a lot of people, I'm developing in typescript so I need to transpîle the code and webpack is a good solution (but not mandatory)

Thanks for your help Have a nice day

Marsup commented 5 years ago

It's all in the module property documentation of the API reference.

I'm not saying webpack is a problem, but using a package purely made for the backend makes no sense.

SimonStiph commented 5 years ago

It's all in the module property documentation of the API reference.

I'm not saying webpack is a problem, but using a package purely made for the backend makes no sense.

Webpack is not only a front-end tool. It can and is also used for transpiling backend code.

lock[bot] commented 4 years ago

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.