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

asset-pipe-client

Package Overview
Dependencies
Maintainers
2
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

asset-pipe-client

Asset pipe client

  • 1.0.0-beta.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
2
Weekly downloads
 
Created
Source

asset-pipe-client

A client for read an CommonJS module entry point and uploading it as an asset feeds to- and triggering builds of executable asset bundles in the asset-pipe-build-server.

Creating asset bundles with asset-pipe is a two step process. The first step is to upload an asset feed to the asset-pipe-build-server. On an upload the asset-feed will be persisted and the asset-pipe-build-server will return the generated filename of the uploaded asset-feed.

The second step is then to create a bundle out of one or multiple asset-feeds. This is done by providing the unique ID(s) of the asset-feeds one want to use to build an asset bundle to the asset-pipe-build-server. The build server will then create an executable asset bundle out of these asset-feeds and persist this. It will respond with the URL to the bundle.

This client helps with remotly triggering these steps in the asset-pipe-build-server.

Installation

$ npm install asset-pipe-client

Example I

Read an CommonJS module entry point and upload it as an asset-feed to the asset-pipe-build-server:

const Client = require('asset-pipe-client');

const client = new Client({
    files: ['path/to/myFrontendCode.js']
    buildServerUri: 'http://127.0.0.1:7100',
});

client.uploadFeed()
    .then((content) => {
        // content contains filename of created the asset-feed
        console.log(content);
    })
    .catch((error) => {
        console.log(error);
    });

Example II

Build an javascript bundle out of two asset feeds:

const Client = require('asset-pipe-client');
const client = new Client({
    buildServerUri: 'http://127.0.0.1:7100',
});

bundle.createRemoteBundle([
        'f09a737b36b7ca19a224e0d78cc50222d636fd7af6f7913b01521590d0d7fe02.json',
        'c50ca03a63650502e1b72baf4e493d2eaa0e4aa38aa2951825e101b1d6ddb68b.json'
    ])
    .then((content) => {
        // content contains URI to the created bundle
        console.log(content);
    })
    .catch((error) => {
        console.log(error);
    });

API

Under the hood, the asset-pipe project build on browserify. Multiple methods in this module are therefor underlaying Browserify methods where all features found in Browserify can be used. Such methods will in this documentation point to the related documentation in Browserify.

This module have the following API:

constructor(options)

Supported arguments are:

transform()

Same as the Browserify transform method.

plugin()

Same as the Browserify plugin method.

uploadFeed()

Read the CommonJS module entry point given at options.files in the constructor and uploads it as an asset feeds to the asset-pipe-build-server.

Returns a promise.

createRemoteBundle(feeds)

Creates an asset bundle on the asset-pipe-build-server.

  • feeds - Array - List of asset-feed filenames.

Transpilers

Since asset-pipe is built on browserify under the hood, its fully possible to take advantage of the different transpiers available for browserify.

As an example, here is how Babel is applied:

const babelify = require('babelify');
const Client = require('asset-pipe-client');

const client = new Client({
    files: ['path/to/myES6FrontendCode.js']
    buildServerUri: 'http://127.0.0.1:7100',
});

client.transform(babelify, { presets: ['es2015'] });

client.uploadFeed()
    .then((content) => {
        console.log(content);
    })
    .catch((error) => {
        console.log(error);
    });

License

The MIT License (MIT)

Copyright (c) 2017 - Trygve Lie - post@trygve-lie.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Keywords

FAQs

Package last updated on 28 Apr 2017

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