Skip to content
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 module cannot be bundled #285

Open
azaelvaldo opened this issue Jul 17, 2024 · 3 comments
Open

@nestjs/terminus module cannot be bundled #285

azaelvaldo opened this issue Jul 17, 2024 · 3 comments

Comments

@azaelvaldo
Copy link

azaelvaldo commented Jul 17, 2024

When I am building a bundled Webpack from my NestJS application, I get this error:

ERROR in ./node_modules/@nestjs/terminus/dist/utils/checkPackage.util.js.map 1:10
Module parse failed: Unexpected token (1:10)

I am not using any feature from HealthCheck included by default in the module. Is it possible to create a module without the HealthCheck module that uses terminus?

Related error and not solved: nestjs/terminus#1423

@focux
Copy link

focux commented Jul 25, 2024

I'm experiencing the same problem, did you figure out a fix?

@azaelvaldo
Copy link
Author

azaelvaldo commented Jul 25, 2024

I had to clone the module repo and remove the whole feature that implements terminus, then manually added the module to my project without npm, like an own module.

@kachalovsky
Copy link

I faced the same issue.

If you are building an application using Webpack and do not require the health check feature, you can simply mock @nestjs/terminus in the bundle by updating your webpack.config.js file. This approach worked perfectly for me without any errors.

While the solution is not ideal, it serves as a temporary fix, and I hope a cleaner solution will be available in the future.

mock-terminus.js

module.exports = {
    HealthCheckService: class {},
    TerminusModule: class {},
    HealthIndicator: class {},
};

webpack.config.js

    {
        ...
        plugins: [
            ...options.plugins,
            new webpack.NormalModuleReplacementPlugin(
                /@nestjs\/terminus/,
                path.resolve(__dirname, 'mock-terminus.js'), // Replace @nestjs/terminus with mock
            ),
        ],
        ...
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants