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 🙏

© 2024 – Pkg Stats / Ryan Hefner

ngx-build-modern

v1.1.10

Published

Turnkey solution for differential serving in Angular. Serve fewer bytes -> increase performance

Downloads

595

Readme

ngx-build-modern: Differential Serving for Angular and the CLI

Stop making all of your users pay for IE9 -- Stephen Fluin from the Angular Team at Angular Mix 2018

Features

  • 📦 Create optimized bundles for modern browsers
  • 📦 Create legacy bundles for older browsers
  • 📦 Make the browser load the right set of bundles
  • 📦 Automate this all by providing an CLI extension

Why is this a good idea

Because of downleveling to ES5 and importing lots of polyfills for IE, a simple Hello-World app comes already with an overhead of ~ 70 KB. This overhead increases when the applications becomes bigger and when it uses more parts of Angular and other libraries. This extension to the CLI provides a solution!

Acknowledgments

Big thanks to ...

  • Stephen Fluin from the Angular Team for his inspirational talk at Angular Mix 2018.
  • Rob Wormald from the Angular Team for an enlightening chat about this topic in the context of Angular Elements and Polyfills.
  • The Vue CLI Team for implementing this idea for Vue and sharing their implementation via GitHub.

What you need

  • Angular >= 7.0.0
  • Angular CLI >= 7.0.0

Important: If you've migrated to Angular 7.0 make sure to have a current version of @angular-devkit/build-angular

Getting Started

Using this library is quite automated. You just need the following commands:

ng add ngx-build-plus
ng add ngx-build-modern

After this, you'll find a polyfills.modern.ts file in your project. Make sure, it just contains the polyfills your modern browsers need. The kown polyfills.ts should still contain all polyfills including the ones for legacy browsers.

ng add also creates a npm script build:modern. Use it to create production bundles for modern and legacy browsers:

npm run build:modern

Using ngx-build-modern in monorepos

If you have more than one project in your CLI-based solution, you have to mention the project using the --project flag:

ng add ngx-build-plus --project demo
ng add ngx-build-modern --project demo

In this example, demo is the name of the project in question. To build your project, ng add creates an additional npm script for you:

npm run build:modern:demo

Known Limitations

  • If you use former versions of the CLI or ngx-build-plus, this plugin needs to switch the CLI into verbose mode to prevent a code conflict. This is not needed anymore since:

  • This solution extends the webpack-based builder. Hence, its limited to using webpack under the covers of the CLI.

  • Make sure to use the latest rxjs lib. This lib was successfully tested with version 6.3.3. On the other side, with 6.1.1 there have been some issues regarding tree shaking and the build optimizer in conjunction with ES2015 bundles.

  • Because this plugin is building the application twice -- once for legacy browsers and once for modern ones -- build time doubles. PRs for compensating this by performing the two builds in parallel are welcome.