Q:

How do I bundle a reuseable angular 2 component for multiple apps?

I want to create a reusable component that I can bundle into a single js file and share with different angular 2 apps. However, I keep getting Error: (SystemJS) Unexpected value 'undefined' declared by the module 'AppModule'
I use gulp to build my packages.  The output looks like this:
build/pkg/basic.js (this is my reusable package)
build/app/main.js (this is one test app trying to use the package)
build/app/app.module.js
build/app/app.component.js
build/systemjs.config.js
build.index.html

I know that pkg/basic.js does get downloaded via the webpage (I can see the file in dev tools).  
main.ts
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app.module';

const platform = platformBrowserDynamic();
platform.bootstrapModule(AppModule);

app.module.ts
import { BasicComponent } from 'basic/basic.component';
import { NgModule }      from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent }   from './app.component';

@NgModule({
  imports:      [ BrowserModule ],
  declarations: [ AppComponent, BasicComponent],
  bootstrap:    [ AppComponent, BasicComponent]
})
export class AppModule { }

app.component.ts
import { BasicComponent }   from 'basic/basic.component';
import { Component } from '@angular/core';

@Component({
  selector: 'my-app',
  template: '<h1>My First Angular App</h1><basic></basic>' 
})
export class AppComponent { }

basic.component.ts (my reusable component package)
import { Component } from '@angular/core';

@Component({
  selector: 'basic',
  template: 'HI BASIC'
})
export class BasicComponent { }

systemjs.config.js
function (global) {
    System.config({
        paths: {
            // paths serve as alias
            'npm:': 'lib/',
            'pkg:': 'pkg/'
        },
        // map tells the System loader where to look for things
        map: {
            // our app is within the app folder
            app: 'app',
            // angular bundles
            '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
            '@angular/common': 'npm:@angular/common/bundles/common.umd.js',
            '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
            '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
            '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
            '@angular/http': 'npm:@angular/http/bundles/http.umd.js',
            '@angular/router': 'npm:@angular/router/bundles/router.umd.js',
            '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
            // other libraries
            'rxjs': 'npm:rxjs',

            //pkg
            'basic/basic.component': 'pkg:basic.js',
        },
        // packages tells the System loader how to load when no filename and/or no extension
        packages: {
            'basic/basic.component': {
                defaultExtension: 'js'
            },
            app: {
                main: './main.js',
                defaultExtension: 'js'
            },
            rxjs: {
                defaultExtension: 'js'
            }
        }
    });
})(this);

index.html 
<html>
  <head>
    <title>Angular QuickStart</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 1. Load libraries -->
     <!-- Polyfill(s) for older browsers -->
    <script src="lib/core-js/client/shim.min.js"></script>

    <script src="lib/zone.js/dist/zone.js"></script>
    <script src="lib/reflect-metadata/Reflect.js"></script>
    <script src="lib/systemjs/dist/system.src.js"></script>

    <!-- 2. Configure SystemJS -->
    <script src="systemjs.config.js"></script>
    <script>
      System.import('app').catch(function(err){ console.error(err); });
    </script>
  </head>
  <!-- 3. Display the application -->
  <body>
    <div style="float:left">
        <my-app>Loading...</my-app>
    </div>

  </body>
</html>

key parts of my gulpfile
gulp.task("app:compile", [], () => {
    let tsResult = gulp.src(["src/**/*.ts", "!src/basic/**/*.ts"])
        .pipe(sourcemaps.init())
        .pipe(tsc(tsProject))
        .pipe(sourcemaps.write(".", {sourceRoot: '/src'}))
        .pipe(gulp.dest("build"));
});

gulp.task("pkg:basic:compile", [], () => {
    let tsResult = gulp.src("src/basic/**/*.ts")
        .pipe(sourcemaps.init())
        .pipe(inlineNg2Template())
        .pipe(tsc({
            typescript: require('typescript'), // In my package.json I have "typescript": "~1.8.0-dev.20151128"
            target: 'ES5',
            module: 'System',
            experimentalDecorators: true,
            emitDecoratorMetadata: true,
            outFile: 'basic.js',
            "rootDir": "./src",
             "outDir": "./build",
            moduleResolution: "node",
        }))
        .pipe(sourcemaps.write(".", {sourceRoot: '/src'}))
        .pipe(gulp.dest("build/pkg"));
});

/**
 * Copy all resources that are not TypeScript files into build directory.
 */
gulp.task("resources", () => {
    return gulp.src(["src/**/*", "!**/*.ts"])
        .pipe(gulp.dest("build"));
});

/**
 * Copy all required libraries into build directory.
 */
gulp.task("libs", () => {
    return gulp.src([
            'core-js/client/shim.min.js',
            'systemjs/dist/system-polyfills.js',
            'systemjs/dist/system.src.js',
            'reflect-metadata/Reflect.js',
            'rxjs/**',
            'zone.js/dist/**',
            '@angular/**',
            'q/q.js',
            'aws-sdk/dist/aws-sdk.min.js'
        ], {cwd: "node_modules/**"}) /* Glob required here. */
        .pipe(gulp.dest("build/lib"));
});

gulp.task("static", () => {
    return gulp.src([
            'systemjs.config.js'
        ]) /* Glob required here. */
        .pipe(gulp.dest("build"));
});

/**
 * Build the project.
 */
gulp.task("build", ['app:compile', 'pkg:basic:compile','resources', 'libs', 'static'], () => {
    console.log("Building the project ...");
});

A:

A method to create re-usable libraries has been posted in the article
How to create an Angular 2 component library, and how to consume it using SystemJs or Webpack.  The example git repository is here.  I was able to re-implement my approach above using this example.  

