tsdx icon indicating copy to clipboard operation
tsdx copied to clipboard

Provide an easy way to remove minification

Open tychota opened this issue 4 years ago • 8 comments

Current Behavior

Currently, TSDX (v0.9, couldn't upgrade to 0.10 due to various problems already reported) behavior concerning minification is:

if (opts.minify !== null && opts.minify !== null) { 
 // respect the set option
} else {
 switch (process.env.NODE_ENV) {
  case "PRODUCTION":
    opts.minify = true;
    break;
  defaut:
    opts.minify = false
  }
}

// later
if (opts.minify) {
  plugins.add(new Terser({});
}

The impact on me is the following. When building a NestJS, the swagger looks like this.

image 💩

There is an issue for Terser mangle options: #136

There is also a possibility to use the new "tsdx.config.js" to remove the plugin

// Not transpiled with TypeScript or Babel, so use plain Es6/Node.js!
module.exports = {
  // This function will run for each entry/format/env combination
  rollup(config, options) {
    config.plugins = config.plugins.filter(plugin => plugin.name !== 'terser');
    return config; // always return a config.
  },
};

But that is not easy to do and undocumented

Desired Behavior

An easy and documented way to disable minification.

Suggested Solution

  • Add --minify false to nest CLI
  • Add documentation in the main README.md

I will be super happy to contribute with a PR if you agree on the expected behavior

Who does this impact? Who is this for?

  • Me :) And my team
  • all user wanting to remove minification, such as nestjs user

Describe alternatives you've considered

As stated in Current Behavior:

  • #136
  • tsdx.config.js

tychota avatar Nov 07 '19 09:11 tychota