GitXplorerGitXplorer
V

gimme-modules

public
0 stars
0 forks
0 issues

Commits

List of commits on branch master.
Unverified
d3ac2ffb2931300fe8824bdb3ca57cf3a8f28026

Merge pull request #3 from Victorystick/separate-format

VVictorystick committed 9 years ago
Unverified
b15f17d0505e0798cf7823277b368f22d5e97c01

Removed old comment. Remove any top-level 'use strict's found.

VVictorystick committed 9 years ago
Unverified
509888d9e3b0f980310f5fc9d7378ea56f5e01fd

Babylon updated under my feet. :(

VVictorystick committed 9 years ago
Unverified
8ca08f0d1f47048e2614ab3da0a4ed1361afe72e

TravisCI integration

VVictorystick committed 9 years ago
Unverified
1041bd41466a5132f1a51c34849aef719b34e00e

Extracted format detection and added more tests.

VVictorystick committed 9 years ago
Unverified
e843a1db5e4a92af2f4d4af2650d33054e35a7aa

Log what file causes an error.

VVictorystick committed 9 years ago

README

The README file for this repository.

gimme-modules

Are you also fed up with all the module formats hanging around? We've had to work with IIFEs and globals, CommonJS, AMD, UMD, SystemJS etc. Which should you choose for your library to have maximal reach? Why ECMAScript modules, of course! There are excellent transpilers available, like Babel and rollup, which let you target all the other formats.

Just say "Gimme modules!" and we'll deliver them.

Install the package

$ npm install -g gimme-modules

and tell your code to be written in ECMAScript 2015 modules instead!

# !! This example updates the code in-place.
$ gimme-modules --recursive --output src src/index.js

gimme-modules will crawl your code and try to convert the files in your project to ECMAScript modules, and put them in the src/ directory.

To preview gimme-modules's output for a single file, like this one:

exports.a = require( './a.js' );
exports.b = require( './b.js' );

pass it as the only argument.

$ gimme-modules lib/index.js

Outputs:

export { default as a } from './a.js';
export { default as b } from './b.js';

API

Alternatively, you can use the Node API.

var gimme = require( 'gimme-modules' );

// From the given entry point, convert all imported files
// recursively and output to the target directory.
gimme.recursive( 'lib/index.js', 'ecma/' );

// Convert one file and output to the given filename ...
gimme.file( 'src/file.js', 'ecma/file.js' );

// ... or to a Writeable Stream.
gimme.file( 'src/file.js', process.stdout );

// Convert any source string, or ESTree AST.
var result = gimme.source( '...' );
    result = gimme.ast( acorn.parse( '...' ) );

// The results have the following properties:
assert.ok( typeof result.code === 'string' );

Licence

MIT