Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

systemjs-assetgraph

Package Overview
Dependencies
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

systemjs-assetgraph

AssetGraph transform for optimizing SystemJS pages for production

  • 0.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
2
Weekly downloads
 
Created
Source

SystemJS AssetGraph

An AssetGraph transform plugin to automatically detect and optimize the use of SystemJS in HTML files.

It works out the main entry point and configuration file for the HTML asset, and then generates the SystemJS bundle, or injects the depcache if using HTTP/2 for optimization.

Installation

npm install assetgraph systemjs-assetgraph

Usage

Consider a simple SystemJS application:

app/main.html

<html>
  <script src="system.js"></script>
  <script src="config.js"></script>
  <script>System.import('main')</script>

We can build this with:

build.js

var AssetGraph = require('assetgraph');
var systemJsAssetGraph = require('systemjs-assetgraph');

var outRoot = 'app-built';

new AssetGraph({root: 'app'})
  .loadAssets(['*.html', '*.js'])
  .queue(systemJsAssetGraph({
    outRoot: 'app-built',
    bundle: true,
    builderConfig: {
      sourceMaps: true,
      lowResSourceMaps: true,
      minify: true,
      mangle: true,
      config: {
        map: {
          app: 'app-compiled',
        },
      }
  }
  }))
  .writeAssetsToDisc({url: /^file:/}, 'app-built')
  .run(function (err) {
    if (err) throw err;
    console.log('Done');
  });

The SystemJS transform will automatically detect the System.config(...) and know to bundle main.

It will then update the config to reference the bundled file, with full source maps support.

Config Overrides

It can be useful to specify configuration overrides that are specifically for the production / build config.

This can be added with the builderConfig.config option:

  .queue(systemJsAssetGraph({
    outRoot: 'app-built',
    bundle: true,
    builderConfig: {
      config: {
        map: {
          'some/module': 'production/module'
        }
      }
    }
  }))

HTTP/2 Optimization

In HTTP/2, rather than generating a single bundle file, we can inject the dependency tree into the page, so that all modules are loaded in parallel.

This mode is enabled by setting bundle: false in the options.

In addition, each of the separate module files will be moved to a hashed file name and the hashes injected into the configuration so that when making application updates, only those modules that have changed need to be reloaded in the browser cache.

License

MIT

FAQs

Package last updated on 02 Feb 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc