es6-module-transpiler-globals-formatter
raw JSON → 0.1.1 verified Fri May 01 auth: no javascript abandoned
Extension for the es6-module-transpiler that outputs exported module values as globals. Version 0.1.1 appears to be the only release; no release cadence indicated. Unlike the default BundleFormatter which keeps exports internal, this formatter assigns exported values to a named global object (e.g., window.myGlobal). Useful for exposing an ES6 module bundle as a global variable in legacy environments. Note that the transpiler repo is also archived, making this an abandoned approach.
Common errors
error Cannot find module 'es6-module-transpiler' ↓
cause Missing peer dependency es6-module-transpiler.
fix
npm install es6-module-transpiler --save-dev
error TypeError: GlobalsFormatter is not a constructor ↓
cause Using ES import syntax or destructuring incorrectly; require returns the constructor directly.
fix
Use var GlobalsFormatter = require('es6-module-transpiler-globals-formatter');
Warnings
gotcha This package depends on the now-abandoned es6-module-transpiler, which is no longer maintained. ↓
fix Consider switching to a modern module bundler like Rollup or Webpack.
gotcha Global object assignments use this.exportedValues at runtime, which may cause conflicts with existing globals. ↓
fix Ensure the globalName is unique and not already used in the target environment.
gotcha Only one version (0.1.1) was ever published; no updates since 2014. ↓
fix Do not rely on future maintenance.
Install
npm install es6-module-transpiler-globals-formatter yarn add es6-module-transpiler-globals-formatter pnpm add es6-module-transpiler-globals-formatter Imports
- GlobalFormatter
var GlobalsFormatter = require('es6-module-transpiler-globals-formatter');
Quickstart
var GlobalsFormatter = require('es6-module-transpiler-globals-formatter');
var transpiler = require('es6-module-transpiler');
var Container = transpiler.Container;
var FileResolver = transpiler.FileResolver;
var container = new Container({
resolvers: [new FileResolver(['lib/'])],
formatter: new GlobalsFormatter({globalName: 'myGlobal'})
});
container.getModule('index');
container.write('out/mylib.js');