es6-micro-loader

raw JSON →
0.2.1 verified Fri May 01 auth: no javascript maintenance

A minimal ES6 System loader polyfill for browsers and Node.js, implementing the System.register() format for ES modules. Current stable version is 0.2.1, with infrequent releases. Unlike full implementations like SystemJS, it focuses on a tiny subset of the spec to maintain ES module semantics while remaining lightweight. Supports anonymous and named modules, basic network fetching in browsers, and direct file import in Node.js. Requires a separate Promise polyfill (es6-promise or bluebird). Not actively maintained; consider upgrading to SystemJS for full spec compliance.

error Error: Cannot find module 'es6-micro-loader'
cause Package not installed or installed incorrectly.
fix
Run 'npm install es6-micro-loader --save' and ensure node_modules contains the package.
error TypeError: System.import is not a function
cause System polyfill not loaded or not correctly imported.
fix
In browser: ensure <script> for system-polyfill.js is included. In Node: use var System = require('es6-micro-loader');
error TypeError: System.import(...).then is not a function
cause Promise not available in the environment.
fix
Load a Promise polyfill (e.g., es6-promise) before calling System.import().
error Error: Module 'named/foo' not found
cause Module not registered or path incorrect.
fix
Ensure module is loaded via <script> tag with correct System.register() name, and use exact name in System.import().
deprecated Package is in maintenance mode; full spec features not implemented.
fix Migrate to SystemJS (https://github.com/systemjs/systemjs) for spec-compliant loader.
gotcha In Node.js, System.import() expects a global path from application root, not a relative path.
fix Use path.resolve() to convert relative paths to absolute before calling System.import().
gotcha Package does not provide a Promise polyfill; Promise must be globally available.
fix Include a Promise polyfill like es6-promise or bluebird before using System.import().
gotcha Browser version relies on System.baseURL (defaults to '/') to fetch modules; modules must be served from that base path.
fix Set System.baseURL to the correct base path before importing modules.
npm install es6-micro-loader
yarn add es6-micro-loader
pnpm add es6-micro-loader

Shows basic usage in Node.js and browser: require the polyfill, then call System.import() with a module path, handling promise resolution.

// In Node.js
var System = require('es6-micro-loader');
System.import('path/to/module')
  .then(function(mod) {
    console.log('Module loaded', mod);
  })
  .catch(function(err) {
    console.error('Loading failed', err);
  });

// In browser after including polyfill
<script src="path/to/system-polyfill.min.js"></script>
<script>
  System.import('named/foo').then(function(foo) {
    foo.init();
  });
</script>