-
Notifications
You must be signed in to change notification settings - Fork 36
Systemjsify Proposal
Dominic Chambers edited this page Oct 8, 2015
·
1 revision
There are two main approaches to integrating BRJS and NPM:
- Multiple Bundles: each project produces a bundle (using browserify or webpack), and we try to bundle all of these bundles in BRJS — this is the approach Kane is investigating in the Dev Week.
- Single Bundle: BRJS takes responsibility for consuming NPM libraries — this is the approach we've been pursuing within BRJS.
This would work as follows:
- We let NPM do the heavy lifting, and take advantage of the easy to consume
node_modules
directories it creates. - We can ship pre-built
node_modules
directories for clients that don't want to use NPM for their library dependencies. - We use SystemJS instead of browser-modules as our module system since it makes it easy to combine modules that have different linking rules (Node.js uses file-based require paths, whereas BRJS is more like ES2016 in using logical require paths).
Here's an example of an NPM module that could not be supported by browser-modules due to its use of file based require paths:
foo:
stuff.js
src
main.js (main entry point):
require('../stuff')
The problems with this approach as it stands include:
- SystemJS can be configured to support CSS and HTML templates, but, the logic to do this is contained within JSPM, which also forces you to use its own package management system instead of NPM.
- The SystemJS Build Tool can bundle NPM libraries if you provide the right configuration, but JSPM chooses to provide config for its own package fetching system only, and there are currently no other alternatives.
- Provide a
systemjsify
command that provides the config needed to allow the SystemJS Build Tool to bundle an NPM library. - Provide the config to support NPM libraries that depend on the CSS & HTML Template plug-ins.
- Clients that don't want to use NPM for packaging would just use the
systemjsify-bundle.js
we make available. - If we don't want to use private repos to make our software available, clients can still use NPM for their other dependencies since we'd ship
node_modules
, and they'd just need to runsystemjsify
for the whole thing. - Clients that only had access to a limited internal repo could use the
node_modules
we ship for the Caplin bits, even if we decided to make these available on the Internet to paid subscribers.