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

angular-named-lazy-chunks-webpack-plugin

v2.1.0

Published

Webpack plugin that assigns names to the async chunks generated for lazy routes in an Angular app.

Downloads

396

Readme

Build status

Angular Named Lazy Chunks Webpack Plugin

Assigns names to the async chunks generated by Webpack for lazy routes in an Angular app.

Example:

app.module.ts

export const ROUTES: Routes = [
  { path: '', component: HomeComponent },
  { path: 'gallery', loadChildren: './gallery/gallery.module#GalleryModule' },
  { path: 'about', loadChildren: './about/about.module#AboutModule' }
];

@NgModule({
  imports: [RouterModule.forRoot(ROUTES)],
  declarations: [AppComponent]
})
export class AppModule { }

Webpack build output without the AngularNamedLazyChunksWebpackPlugin:

                        Asset     Size  Chunks           
    0.155b2d62f27ec0c62c13.js  3.92 kB       0  [emitted]
    1.5d938dc52f1919e39aa9.js  3.82 kB       2  [emitted]
  app.9d8bb980840d155d8745.js  13.1 kB       4  [emitted]
                 polyfills.js   6.9 kB       7  [emitted]
                    vendor.js  8.38 kB       9  [emitted]

Webpack build output with the plugin:

                              Asset     Size  Chunks           
    gallery.155b2d62f27ec0c62c13.js  3.92 kB       0  [emitted]
      about.5d938dc52f1919e39aa9.js  3.82 kB       2  [emitted]
        app.9d8bb980840d155d8745.js  13.1 kB       4  [emitted]
                       polyfills.js   6.9 kB       7  [emitted]
                          vendor.js  8.38 kB       9  [emitted]

Installation

$ npm install --save-dev angular-named-lazy-chunks-webpack-plugin

Usage

webpack.config.js

const AngularNamedLazyChunksWebpackPlugin = require('angular-named-lazy-chunks-webpack-plugin');

module.exports = {
  ...
  plugins: [
    ...
    new AngularNamedLazyChunksWebpackPlugin()
  ]
}

Options

{
  // Default: false
  // Set to "true" if you have multiple apps built with one Webpack config and 
  // the build output goes to one folder. In this case the plugin will try to
  // determine the name of the app based on the page to the module (see 
  // "appNameRegex" option) and prefix the chank name with the app name (e.g.
  // app1.gallery.155b2d62f27ec0c62c13.js).
  multiAppMode: boolean,

  // Default: "apps(\\\/|\\\\)(.*?)(\\\/|\\\\)"
  // When "multiAppMode" is set to "true" this regular expression is used for
  // extracting the name of the app from the module file path.
  // E.g. if you have the following file structure:
  // apps/
  //   app1/
  //     module1
  //     module2
  //   app2/
  //     module1
  //     module2
  // The chunks will be named "app1.module1.15..c13.js", 
  // "app2.module1.9d...745.js", etc.
  // 
  // Note: If a custom regex expression is provide, the name of the app is assumed to be the first match group in that regex.
  appNameRegex: string,
  
  // A function that returns the name of the chunk based on the file path of the lazy module.
  // If this function is specified then "multiAppMode" and "appNameRegex" are ignored.   
  nameResolver: (filePath: string) => string | null
}

Credit

Full credit goes to Angular CLI, where this plugin was originally introduced.

This package includes a few tweaks (like multi-app support) and makes it available for Angular apps that are not based on Angular CLI and instead use custom Webpack config.