P
P
Petr Muhurov2018-12-05 18:50:21
JavaScript
Petr Muhurov, 2018-12-05 18:50:21

How to cut a module from a build?

Good afternoon. There is an invariant module, which essentially provides a wrapper for logging to the console (warn, error, log) on ​​a true/false condition. The module hangs in node_modules and is used everywhere in the code of projects in the form of code snippets:

import invariant from "ui-invariant";
...
invariant(condition, "message", "warn");

I would like to cut out this module from the build and, accordingly, all the code associated with it. A bunch of webpack+babel+nodejs.
Maybe someone has come across and knows ready-made plugins / loaders / libs for this garbage? I really don’t want to write my own loader and kill myself in regexps)
Thanks
PS For react prop-types, I found the babel-plugin-transform-react-remove-prop-types plugin, about the same is needed for a custom module

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Tsvetkov, 2018-12-06
@pterodaktil

You don't have to cut anything. In production mode, this lib only outputs errors, at least that's what their documentation says.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question