Skip to content

Commit

Permalink
Re-write the module transpiler with support for bindings.
Browse files Browse the repository at this point in the history
This commit removes support for AMD, YUI, and globals formats. These formats can be implemented as plugins. AMD should perhaps be included in core, but we'll see.
  • Loading branch information
eventualbuddha committed Jun 2, 2014
1 parent 861880e commit 9ae2d8c
Show file tree
Hide file tree
Showing 160 changed files with 3,504 additions and 1,885 deletions.
8 changes: 2 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
/node_modules/
tmp/
test/index.html
test/.generated
bin/
dist/
node_modules/
test/results
33 changes: 0 additions & 33 deletions Gruntfile.js

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2013 Square Inc.
Copyright 2014 Square Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
84 changes: 84 additions & 0 deletions bin/compile-modules
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#!/usr/bin/env node

var Path = require('path');
var exe = Path.basename(process.argv[1]);
var getopt = require('posix-getopt');
var parser = new getopt.BasicParser('h(help)v(version)', process.argv);
var option;

function usage(puts) {
puts(exe + ' [--help] [--version] <command> [<args>]');
puts();
puts('Commands');
puts();
puts(' convert Converts modules from `import`/`export` to an ES5 equivalent.');
puts(' help Display help for a given command.');
}

function makeWriteLine(stream) {
return function(line) {
if (!line || line[line.length - 1] !== '\n') {
line = (line || '') + '\n';
}
stream.write(line);
};
}

var puts = makeWriteLine(process.stdout);
var eputs = makeWriteLine(process.stderr);

while ((option = parser.getopt()) !== undefined) {
if (option.error) {
usage();
process.exit(1);
}

switch (option.option) {
case 'h':
usage(puts);
process.exit(0);
break;

case 'v':
puts(exe + ' v' + require(Path.join(__dirname, '../package.json')).version);
process.exit(0);
break;
}
}

var args = process.argv;
var offset = parser.optind();

var commandName = args[offset];
if (commandName === 'help') {
commandName = args[offset + 1];
args = ['--help'].concat(args.slice(offset + 2 /* skip 'help' and command name */));
} else {
args = args.slice(offset + 1);
}

if (typeof commandName !== 'string') {
usage(puts);
process.exit(1);
}

var command;

try {
command = require(Path.join('../lib/cli', commandName));
} catch (ex) {
usage(eputs);
process.exit(1);
}

try {
var exitCode = command.run(args, puts, eputs);
process.exit(exitCode);
} catch (ex) {
if (ex.constructor.name === 'AssertionError') {
eputs('error: ' + exe + ' ' + commandName + ' -- ' + ex.message);
process.exit(1);
} else {
throw ex;
}
}
118 changes: 0 additions & 118 deletions lib/abstract_compiler.js

This file was deleted.

106 changes: 0 additions & 106 deletions lib/amd_compiler.js

This file was deleted.

Loading

0 comments on commit 9ae2d8c

Please sign in to comment.