For thinking about javascipt packages in .Net terms:
Library:
package.json defines a main file which is the entry point to the package. This file (generally index.js) should contain exports for all public classes within the package. This makes a package equivalent to a .Net dll, where all of the public classes are listed in index.js.
Class / Service:
Export from a single js file.
Sharing code:
Import statements are like "using" statements but they aren't optional because javascript has no concept of automatic sharing within namespaces.
index.js example:
import Class1 from './lib/class1.js';
import Service1 from './lib/service1.js';
export {Class1, Service1};
class1.js example:
import Service2 from './service2.js';
export default function thething{ Service2.log('oh yeah');}
Top Level Package:
When loading a package into a browser, because ES6 syntax is not yet supported, systemjs has a global with an import method which returns a promise with the resulting module.
In production this is not required because Systemjs will compile the package into a single js file which can be loaded using a script tag.
Example:
var lodash = null;
System.import('lodash').then(
function(result){ lodash = result;}
);