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

yarn-acquire

v0.0.8

Published

Lightweight client side require() script and file loader with caching

Downloads

14

Readme

Acquire

Lightweight AMD require() script and file loader with caching

Usage

require('/application/bar.js');
Pre-Loader

Set up a preloader so you can use it like require in Node JS.

require.load(
	'/application/bar.js',
	'/application/template.html',
	'/application/circle2.js',  
	'/application/circle1.js');

You can also directly define the paths as in:

require.load({
	'/application/bar.js': function() {
		return 'foo';
	},
	'/application/template.html': '<h1>Yay</h1>',
	'/application/circle2.js': function() {
		console.log('circle-2');
	},  
	'/application/circle1.js': 'eval;require('%2Fapplication%2Fcircle2.js')()%3Bmodule.exports%20%3D%20function()%20%7B%09console.log('circle-1')%3B%7D'});

This is the recommended way when you are ready to bundle and minify your code for production use. As you can see /application/circle1.js is compiled different than the others. This is because there is some other code outside of the module.exports. If you have this same case wrap your entire file using encodeURIComponent. Acquire will evaluate strings that start with eval; following the encoded code.

If you need to wait for the pre loaders you can include a callback at the end of the load method as in:

require.load(
	'/application/bar.js',
	'/application/template.html',
	'/application/circle2.js',  
	'/application/circle1.js',
	function(bar, template, circle2, circle1) {
		require('/test.js');
	});
Path Configuration
require.config({
	application: {
		root: '/application',
		index: 'foobar'
	},
	foobar: '/foobar'
});

require('application/bar'); // will now be the same as require('/application/bar.js')
require('application/bar/'); // will now be the same as require('/application/bar/foobar.js')
require('foobar/bar'); // will now be the same as require('/foobar/bar.js')
require('foobar/bar/'); // will now be the same as require('/foobar/bar/index.js')

Warning: Relative paths like require('application/bar') with no config will default to require('/bower_components/application/bar.js')

No Conflict

acquire('application/bar')

Acquire will check to make sure require isn't already used before using that namespace.

Why not X ?

  • Wanted a combination of Node style (AMD) requiring with optional async callback
  • Wanted a preloader, but didn't want preloading to be a requirement
  • Wanted to auto parse JSON Data
  • Wanted something that would not conflict with other require methods (ie. Cordova)
  • Wanted the ability to control the initial cache if integrating to watchers and optimizers
  • Wanted the ability to overwrite core methods
  • Wanted a simple readable implementation

Works With

  • jQuery
  • Angular - for external modules
  • PhoneGap - using with cordova
  • Gulp - When combining and uglifying
  • Grunt - When combining and uglifying
  • Bower