Registry / devops / 6-to-library

6-to-library

JSON →
library0.3.4jsnpmunverified

A deprecated formatter plugin for 6to5 (predecessor to Babel) that transforms ES6 modules into CommonJS, AMD, or global scripts for library distribution. Version 0.3.4 was the last release. It was made obsolete by 6to5 v2.7.0+, which added native module export support. Key differentiator: allowed library authors to write in ES6 and target multiple module systems seamlessly by specifying '6-to-library' as the modules option in 6to5.

npm install 6-to-library
INSTALL
IMPORT
SIG · 6-TO-LIBRARY
6
6-to-library
devopsjavascriptv0.3.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

6-to-library formatter
// In 6to5 config: modules: '6-to-library'
This package is a plugin for 6to5, not a standalone import. It is used by passing its name as the modules option.
Default export in library code
export default function myFunc() {}
The formatter expects a default export to generate a simple UMD module. Named exports remain accessible via .default and .exportName.
Resulting CommonJS require
var lib = require('your-library');
var lib = require('your-library').default;
If library only has a default export, the generated CommonJS wrapper exports the default directly, so no .default needed.

Demonstrates how to use 6-to-library formatter to transpile an ES6 module with a default export into a distributable UMD file.

// Install 6to5 and 6-to-library npm install --save 6to5 6-to-library // Write your library in ES6 (e.g., es6/up-first-letter.js) // es6/up-first-letter.js: export default function (string) { return string.charAt(0).toLocaleUpperCase() + string.substr(1); } // Transpile using 6to5 CLI 6to5 --modules 6-to-library --out-file index.js es6/up-first-letter.js // Then publish index.js as your library entry point // Users can consume it with: var upFirstLetter = require('up-first-letter'); upFirstLetter('hello'); // 'Hello'
Debug
Known issues
deprecatedThis package is deprecated. 6to5 (now Babel) added built-in UMD export support in version 2.7.0, making this formatter unnecessary.
fix
Upgrade to a newer version of Babel (formerly 6to5) and use its built-in module formatting (e.g., modules: 'umd' or 'commonjs').
affects: >=0.0.0
gotchaIf library has only a default export, the generated CommonJS wrapper does NOT use .default; require() returns the default directly. Named exports require accessing .exportName.
fix
Ensure your library exports a single default if you want seamless CommonJS usage; otherwise, users must access named exports via .default and .exportName.
affects: >=0.0.0
gotchaGlobal object names are derived from file basenames (camel-cased). This may cause conflicts if multiple files have similar names.
fix
Use unique file names or manually specify global names in 6to5 configuration if available.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Cannot find module '6-to-library'
The 6-to-library package is not installed, or 6to5 cannot locate it.
fix
Run 'npm install --save 6-to-library' and ensure node_modules includes it.
require('...').default is undefined
Library only has a default export; the generated CommonJS wrapper exports the default directly, so .default is not needed.
fix
Change 'var lib = require('...').default' to 'var lib = require('...')'.
Upgrade
Version history
0.3.4latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
58 hits · last 30 days
node
50
OpenAI (training)
1
Resources
6-to-library — npm install 6-to-library · libregistry