Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I have been using the fantastic "<a href="http://browserify.org/" rel="nofollow noreferrer">browserify</a>", which works like a charm. This is an alternative to using <a href="https://github.com/arunoda/meteor-npm" rel="nofollow noreferrer">Arunda's NPM Atmosphere package</a>, or <a href="https://stackoverflow.com/a/16829068/2573589">using Npm.require with package.js</a>, that arguably has some advantages:</p> <ol> <li>My code can use plain old "require" instead of Npm.require or Meteor.require. Obviously this is not a huge deal, but if I want to use this code outside Meteor it's nice to feel it's not dependent on Meteor.</li> <li>I don't have to worry about whether Meteor will once again change the way it thinks about Npm integration again.</li> <li>It allows me to use local development version of my own npm modules using npm link.</li> </ol> <p>Here's how it works:</p> <ol> <li>I create a separate project for npm dependencies in a hidden .npm folder</li> <li>I use browserify to create a bundle.js that will be loaded by meteor</li> <li>I use grunt watch to make sure that every time I install a new npm package, the bundle.js is updated</li> </ol> <p>Here's my directory structure:</p> <pre><code>my_meteor_project/ lib/ bundle.js .npm/ node_modules README.md Gruntfile.js entrypoint.js package.json </code></pre> <p>Here's an example of entrypoint.js (unfortunately I have to use globals so that assert, url, and _ are available in Meteor code)</p> <pre><code>assert = require('assert'); url = require("url"); _ = require('underscore'); </code></pre> <p>Here's the gruntfile:</p> <pre><code>module.exports = function(grunt) { grunt.initConfig({ watch: { build: { files: ['./entrypoint.js', './package.json'], tasks: ['browserify2'], options: { } } }, browserify2: { compile: { entry: './entrypoint.js', compile: '../lib/bundle.js' } }, }); grunt.loadNpmTasks('grunt-browserify2'); grunt.loadNpmTasks('grunt-contrib-watch'); grunt.registerTask('build', ['browserify2']); }; </code></pre> <p>I then use grunt watch to watch for changes to entry.js or new NPM installs</p> <pre><code>$ cd .npm $ grunt watch:build &amp; [2] 44617 $ Running "watch:build" (watch) task Waiting... </code></pre> <p>And then if I install an npm module, or modify entrypoint.js, bundle.js is updated:</p> <pre><code>$ npm install url -save npm http GET https://registry.npmjs.org/punycode npm http GET https://registry.npmjs.org/querystring npm http 304 https://registry.npmjs.org/punycode npm http 304 https://registry.npmjs.org/querystring url@0.7.9 node_modules/url ├── querystring@0.1.0 └── punycode@1.0.0 $ OK &gt;&gt; File "package.json" changed. Running "browserify2:compile" (browserify2) task File written to: ../lib/bundle.js Done, without errors. Completed in 1.256s at Thu Jul 11 2013 11:36:22 GMT-0600 (MDT) - Waiting... </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload