-
-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@nestjs/terminus cannot be embedded in a webpack bundle #1423
Comments
Thanks for reporting. I assumed this would be a problem. I assume this is going to be a tricky one to fix and need to investigate what is going to be the best option here! |
@BrunnerLivio We've encountered a similar issue with esbuild. Are there any updates on it? |
@BrunnerLivio we have the same issue with yarn pnp. The I believe a solution would be to dismiss the |
Same issue. Could not find a proper way around this. Not even a improper one. |
I was able to get this working with the following const nodeExternals = require('webpack-node-externals'); // pnpm/yarn add to package.json
module.exports = (config, options, targetOptions) => {
return {
target: 'node', // https://webpack.js.org/configuration/target/
externals: [nodeExternals()], // https://github.com/liady/webpack-node-externals
externalsPresets: { node: true }, // https://github.com/liady/webpack-node-externals
module: {
rules: [
{
// "Fixes" build issue as suggested by @[linsolas](https://github.com/linsolas)
// https://github.com/nestjs/terminus/issues/1423#issue-1002145070
test: /@nestjs\/terminus\/dist\/utils\/.*\.ts$/,
loader: 'null-loader'
}
]
}
};
}; We're using docker, so we install the node dependencies in the Dockerfile, the same as it's done here. Our build output (ie in the docker image in our case) looks like this:
And running with
Externalizing
is this a viable solution ? |
In many reasons, along with the hugeness of I suggest that this issue can be solved by ignoring I've tested by editing the js file inside |
Any updates? |
Hi, same issue. Any updates? |
Hi I am still encountering this issue. |
The following patch fixes the issue for me. diff --git a/dist/utils/checkPackage.util.js b/dist/utils/checkPackage.util.js
index 588531e53cc194a91de222ac3a3dac272863933c..a22c060e2069f586491f07186cc56ff440c37d9c 100644
--- a/dist/utils/checkPackage.util.js
+++ b/dist/utils/checkPackage.util.js
@@ -55,9 +55,9 @@ function checkPackages(packageNames, reason) {
.filter((pkg) => pkg.pkg === null)
.map((pkg) => packageNames[pkg.index]);
if (missingDependenciesNames.length) {
- logger.error(MISSING_REQUIRED_DEPENDENCY(missingDependenciesNames, reason));
- logger_service_1.Logger.flush();
- process.exit(1);
+ // logger.error(MISSING_REQUIRED_DEPENDENCY(missingDependenciesNames, reason));
+ // logger_service_1.Logger.flush();
+ // process.exit(1);
}
return packages.map((pkg) => pkg.pkg);
} |
Still facing the issue as well |
Are there any updates on this issue? |
Terminus is still not working with webpack, so I had to create my own health check module like workaround:
I hope it will help |
I'm submitting a...
Current behavior
Hello,
I'm developing several Nestjs applications, and for deployment purposes, I generally bundle the whole application into one single JS file, using webpack (through the command
nest build --webpack
).My first problem is due to the
require(``${module}``)
statement incheckPackage.util.ts
. In front of such statement, Webpack tries to embed all resources from the sames directory, which includes.d.ts
files (such asnode_modules/@nestjs/terminus/dist/lib/utils/checkPackage.d.ts
. And then it fails saying:It can be avoided by overriding the default
webpack.config.js
with something like this:So now I can build my application... But it does not run anymore, because on runtime,
@nestjs/terminus
tries to load these dependencies from an inexistentnode_modules
directory.Expected behavior
I would like to embed the
@nestjs/terminus
module in my application built with webpack. I would like to be able to skip these pre-checks by Terminus with an option, so Terminus will not throw this exception and quits.What is the motivation / use case for changing the behavior?
To use
@nestjs/terminus
in my Nestjs application built with webpack.Environment
The text was updated successfully, but these errors were encountered: