npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ngx-uglifier

v1.0.3

Published

ngx-uglifier uglifies your angular library, meaning it shortens class member names to be of a single character.<br/> It utilizes terser to do the uglification, terser is used by the angular compiler to minify the code in build time, so it is already insta

Readme

ngx-uglifier uglifies your angular library, meaning it shortens class member names to be of a single character. It utilizes terser to do the uglification, terser is used by the angular compiler to minify the code in build time, so it is already installed by angular.

The uglification also reduces your library bundle size since it shortens class member names.

Uglifying is not the same as obfuscating which mangles the code. This package only shortens the names of classes/methods/variables.

There are 2 stages for uglifying the code:

  1. building your library as usual, this will produce a transpiled .js files.
  2. uglifying the transpiled files.

When building an angular library, the following names need to remain unchanged, all others can be shortened:

  • public exports, those are usually class names
  • public class methods/variables which should be accessed from outside the class
  • public interfaces AND their properties

All class members declared as protected/private can be uglified. However, since the uglification works on .js file there can be no distinction between public and protected/private members. In order to provide this distinction we need to plan our code for it. My suggestion is to prefix the protected/private members with an underscore or something alike, you can then pass an option to terser telling it to uglify only members which start with underscore.

Here is a sample code for a directive having private variables/methods prefixed with underscore. In this sample the only names that will be preserved after uglification will be the class name MyLibDirective and the public method isEmbed.

@Directive({ selector: '[myLib]' })
export class MyLibDirective {
  private _options;

  constructor(private viewContainer: ViewContainerRef) {
	  this._initOptions();
  }

  private _initOptions() {
	return this._options = { isEmbed: true };
  }

  public isEmbed() {
	return this._options.isEmbed;
  }
}

Installation

npm install -D ngx-uglifier

Uglification

Uglification is made by running a script which processes the built code. The script will contain a config object with the input/output folder names.

const NgxUglifier = require('ngx-uglifier');

const config = { projectName: 'my-lib' }
const ngxUglifier = new NgxUglifier(config);
ngxUglifier.init().then();

config object

The config object mainly contains folder names and optionally some uglification options. The interface name is NgxUglifierConfig.

| name | | |------------- |:-------------| | projectName | the library name | | srcParentFolder | this will usually be 'dist', if you omit this property it will default to 'dist' | | destParentFolder | an optional property which specifies the parent folder where the uglified code will be placed.if you want it to be placed at 'uglified/projectName' then pass 'uglified' here.if you omit this property or have it the same as srcParentFolder then the uglified code will be placed at srcParentFolder/projectName. | | uglifyOptions | an optional object of interface NgxUglifierOptions containing options you want to pass to terser.The options and their default values are described below. |

uglifyOptions object

The uglifyOptions object contain properties which will be used by terser to uglify the code. This object is optional, the default values are optimized for es6 apps. The interface name is NgxUglifierOptions.

| Option | | |------------- |:-------------| | ecma | pass 5, 2015, 2016, etc.default: 2015 | | isModule | Use when minifying an ES6 module.default: true | | sourceMap | generate source maps or not. default: false | | classes | specify class names to preserve, pass a regular expression or true to preserve all.default: /^/     (preserve those which start with underscore).| | functions | specify function names to preserve, pass a regular expression or true to preserve all.default: /^/     (preserve those which start with underscore).| | properties | specify variable names to preserve, pass a regular expression or true to preserve all.default: /^_/     (preserve those which start with underscore).| | topLevel | set to true if you wish to enable top level variable and function name mangling and to drop unused variables and functions.default: false | | isLegacyAccessorsDefinition | typescript 3.7 (used by angular >=9) has breaking changes from earlier versions in regards to setters/getters in the produced definition files (the d.ts files).so if you build your lib with angular 9 and consume it by an angular 8 app, then the app's typescript compiler (version <= 3.5) will not recognize the getters/setters syntax produced by typescript 3.7.passing true will make the setters/getters definition to be produced as the old syntax which is compatible to BOTH the old typescript and and the new one.default: true |