JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2945
  • Score
    100M100P100Q107870F

Easily share data between your server-side and browserify modules.

Package Exports

  • sharify

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (sharify) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

sharify

Easily share data between your server-side and browserify modules.

Example

Given an express app with jade.

app.js

var sharify = require('sharify');
var app = require('express')();
var config = {
  API_URL: 'http://artsy.net/api/v1',
  NODE_ENV: process.env.NODE_ENV
}
sharify(config).use(app);

index.jade

html
  body
    #scripts
      //- Make sure this is above your other scripts
      != sharify.script
      script( src='/jquery.js' )
      script( src='/bundle.js' )

client.js

// Browserify module
var sd = require('sharify').data;
var $ = require('jquery');
$(function() {
  $.ajax({ url: sd.API_URL + '/artwork/andy-warhol-skull' });
});

API

sharify(obj)

Includes a hash to be shared between modules.

sharify.use(app)

Adds sharify to an express app's locals so sharify.script can be injected in views.

sharify.script

Script tag that bootstaps shared data.

sharify.data

The hash of shared data.

Contributing

Please fork the project and submit a pull request with tests. Install node modules npm install and run tests with make test

License

MIT