Skip to content

Alternative NPM Integration Strawman

Dominic Chambers edited this page Nov 19, 2015 · 4 revisions

Introduction

This page describes a simpler alternative to the BladeRunnerJS NPM Integration Strawman that will allow us to start migrating to NPM sooner.

The Plan

We have a very simple solution for bundling NPM libraries with rollup/webpack/browserify/systemjs-builder (see bundle-all-spike) that doesn't require any changes to BRJS. The bundle is simply placed into unbundled-resources, and developers refer to any libraries using npm.libX rather than require('libX').

While it would seem to be possible to use Rollup (which has a very good plugin API) to bundle BRJS libraries by creating a plugin that understood our library layouts, this would then require us to process the aliases XML files, and start bundling non-JavaScript resources parallel to any JavaScript we need to bundle. Instead, we could get Rollup to bundle more of our code by moving it to NPM, but this requires:

  1. That we finish making all dependent testing infrastructure available in NPM.
  2. That we switch to the programmatic service API — this can be still be configured with aliases in BRJS.
  3. That we determine the best compatible I18N micro-library, and create a wrapper so that code internationalized with that library will continue to be internationalized within BRJS.
  4. That we provide a better inclusion story than npm.react and unbundled-resources, and that this inclusion story: 1. Doesn't require people to change how they require existing libraries since that will lead to backwards compatibility issues. 2. Allows non NPM users to continue consuming our libraries. 3. Allows NPM users to include additional NPM libraries over and above the ones we ship BRJS with.
  5. That,finally, we move all of our libraries to NPM.

1, 2 & 5 were already things we were planning on working on as part of the NPM Support Milestone, so our plan now is to make these and the additional issues the highest priority so we can get people making increased use of NPM as soon as possible.

The minimal NPM support is just a first step, and won't include support for libraries that need the following:

  • HTML Resource Service (HTML can instead be required as text, and innerHTMLed into an element).
  • XML Resource Service (libraries needing this service won't be converted)
  • Non-service aliases.

As a consequence of these omissions, some libraries (e.g. 'grid') won't be converted in this initial release.

Clone this wiki locally