Skip to content
This repository has been archived by the owner on Mar 29, 2018. It is now read-only.

[RFC] Re-write the module transpiler with support for bindings. #126

Merged
merged 30 commits into from
Jun 25, 2014
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
9ae2d8c
Re-write the module transpiler with support for bindings.
eventualbuddha Jun 2, 2014
38df346
Remove `enumerable: false` since it is the default.
eventualbuddha Jun 2, 2014
8c12737
Fix the usage message for bad options.
eventualbuddha Jun 2, 2014
909f8c5
Ensure that all imports and exports are read before rewriting.
eventualbuddha Jun 4, 2014
c4622a3
Add some error messages when finding formatters or resolvers goes wrong.
eventualbuddha Jun 4, 2014
d24ab31
Fix a spacing issue with the error message.
eventualbuddha Jun 4, 2014
58ff715
Fix requiring a resolver class.
eventualbuddha Jun 4, 2014
9031e8c
Update to ast-util v0.1.2 to fix a reference identifier issue.
eventualbuddha Jun 4, 2014
0ca016d
Add support for `module foo from 'foo'`.
eventualbuddha Jun 4, 2014
d423fc0
Fix a typo.
eventualbuddha Jun 4, 2014
74e602f
Ensure that importing with `module from` works with chained exports.
eventualbuddha Jun 5, 2014
040c1b3
Ensure the error message is printed for test exceptions.
eventualbuddha Jun 5, 2014
8755c02
Handle default exports with `module from` imports.
eventualbuddha Jun 5, 2014
265ad7b
Make memoized attributes writable forever.
eventualbuddha Jun 5, 2014
2d5ba89
Set the name of modules in a container to a unique value.
eventualbuddha Jun 5, 2014
a20bf8d
Make `this` inside a concatenated module the global object.
eventualbuddha Jun 5, 2014
8c1c863
Print the error message only once.
eventualbuddha Jun 5, 2014
82e5218
Export the built-in formatters and remove the useless `makeContainer`.
eventualbuddha Jun 10, 2014
6d1c26c
Stop using removed export.
eventualbuddha Jun 10, 2014
59f88b1
Throw an error when imports do not have matching exports.
eventualbuddha Jun 10, 2014
0a5275e
Remove support for `module foo from "foo"`.
eventualbuddha Jun 10, 2014
16cb321
Consolidate and change strategy with the export formatters.
eventualbuddha Jun 12, 2014
282a7b4
Add a test with cycles that immediately uses an import from it.
eventualbuddha Jun 12, 2014
7df865c
Ensure that import bindings cannot be assigned.
eventualbuddha Jun 13, 2014
afc72f7
Allow missing type and message params.
eventualbuddha Jun 14, 2014
4df54f4
Create an assertion error so the runner will know not to modify it.
eventualbuddha Jun 14, 2014
b1ea9da
Fix up some error message generation.
eventualbuddha Jun 14, 2014
99dfc45
Throw a SyntaxError when we encounter duplicate declarations.
eventualbuddha Jun 14, 2014
64a3821
Ensure update expressions (e.g. `n++`) are not allowed for imports.
eventualbuddha Jun 24, 2014
174e501
Update the CHANGELOG, TRANSITION, and README files.
eventualbuddha Jun 25, 2014
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(eputs);
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