When comparing JSPM vs RequireJS, the Slant community recommends JSPM for most people. In the question“What are the best frontend JavaScript module bundlers?” JSPM is ranked 7th while RequireJS is ranked 12th. The most important reason people chose JSPM is:
JSPM is registry agnostic, it can pull packages from npm and github and is built in such a way it can support more.
Ranked in these QuestionsQuestion Ranking
Pros
Pro Registry agnostic
JSPM is registry agnostic, it can pull packages from npm and github and is built in such a way it can support more.
Pro Module style agnostic
Loads ES6, AMD, CommonJS and globals.
Pro Can transcompile ES6, JSX and Typescript
Pro Much faster than Webpack or Browserify
While Webpack and Browserify recompile the source code using Babel, jspm is the only packager that can load prebuild/minified code downloaded from the npm registry.
Pro Bundled based on imported modules without any config
Create the bundle file without config and add only the modules imported.
Pro Switch between async or sync load
With a simple command you could change between load the modules async by systemjs or sync with a bundle file.
Pro Easy install packages from npm, github or any git repository
Pro Versioned package urls
It creates a packages folders which are versioned. This makes it future proof for a time where we stop bundling all the code. In the following presentation Guy Bedford calls bundling an anti-pattern.
Pro Very easy to start with
Pro Works with basically every desktop browser, even IE6
RequireJS supports IE6+, FF2+, Safari3.2+, Chrome3+ & Opera 10+.
Pro Well documented
The RequireJS module loader is extremely well documented. So no matter whether you're a pro at JS based web development or just a newbie, you will find the documentation very helpful whenever you're stuck or just starting out. Everything is well-defined and logically placed in proper sections in a manner such that it is very easy to understand.
Pro You don't need a server to get started
One of the best advantages of RequireJS over Browserify is that you don't need a nodejs environment to get started. Just "require" your dependencies and it takes care of loading them. By contrast, Browserify requires a running NodeJS implementation so you can build your one monolithic file, then you can push the file to your static web server.
Pro Has a RequireJS optimizer
After building all the modules to be loaded, the built files can be optimized as well (minified and concatenated), even though this is a completely optional step, but doing so could be a lot beneficial for your site's performance.
Pro Lazily-loaded JS can access already loaded modules by name
Yet its run-time is still competitive if not better than Webpack's at higher density levels of modules.
Pro Always running site unbundled
With other loaders, aka browserify, it isn't possible to run your site without first bundling. Require.js can load everything async which is pretty powerful.
Pro Supports nested dependencies
If your project has nested dependencies, you won't have to worry about resolving them at all. Because RequireJS will do that for you.
Pro Well tested
Since the RequireJS is quite popular among the dev community, that automatically means that problems get sorted out very quickly and most of the core code has already been tested.
Pro AMD & CJS support
While RequireJS is mainly an AMD implementation, it can, with rare exceptions, implement CJS as well.
Pro Simple
Because of its easy to understand documentation, the RequireJS module loader is super simple to use; module definitions are as easy as defining just a key/value pair.
Pro Can load new modules without being recompiled
It's the one of the few modules in this category that can handle IOC-style dependency injection. The others work well for apps that have knowable dependency lists at compile time, but this is the only one that can load new modules without being recompiled.
Pro Supports hot RE-loading
Persistent console logging, generational statefulness, promotes stateless DOM development.
Cons
Con You need to be an expert to write shims
You can load any module. But that comes with the price:
you need to find or write configs to load a particular rare module.
Con Doesn't hide complexity
JSPM doesn't try to hide complexity from the user. I.e. when some issue emerges you need understand a lot to be able to patch it or create a workaround.
Con Watcher has bugs
Watching would benefit from improvements
Con Unstable API
0.17 is still in beta. 0.16 is lacking features.
Con Poor bundler performance
Bundling performance is slow, though offset by the fact that bundling is not required during development, since it can load dependencies asynchronously.
Con On its way out
Latest stable release is 2 months old with little development occurring on Github.
Con Poor handling of circular references
If you create a circular reference between two files, it will typically quietly break - the reference on one side will end up undefined.
Con AMD spec uses globals
The global ‘require’ and ‘define’ methods make namespace collisions likely if building a 3rd party plugin. AMD loaders line require are best if you control the site.