Skip to content

Commit

Permalink
Make traceur runtime thlorenz#1 entry file.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmm committed Feb 5, 2015
1 parent 3f68ced commit 33ec7d0
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,15 @@ exports = module.exports = function es6ify(b, opts) {

if (opts.basedir === undefined) opts.basedir = b._options.basedir;
if (opts.includeRuntime === undefined) opts.includeRuntime = true;
if (opts.includeRuntime) b.add(runtime);
if (opts.includeRuntime) {
// Process records that have previously entered the pipeline.
b._recorded.forEach(function (rec) {
reorderEntry(rec);
});
// Push a pipeline step to process records hereafter entering the pipeline.
b.pipeline.get('record').push(reorderEntries());
b.add(runtime);
}

transform = makeTransform();

Expand Down Expand Up @@ -105,6 +113,29 @@ exports = module.exports = function es6ify(b, opts) {
// makeTransform
}

// Reorder a pipeline record.
function reorderEntry(rec) {
if (rec.entry) rec.order++;
if (rec.id === runtime) rec.order = 1;
return rec;
}
// reorderEntry

// Create a stream to insert in the browserify pipeline to reorder entry files
// so traceur runtime is number one.
function reorderEntries() {
var stream = through(write);
stream.label = 'es6ify-reorder-entries';

return stream;

function write(rec) {
reorderEntry(rec);
this.queue(rec);
}
}
// reorderEntries

/**
* The traceur runtime exposed here so it can be included in the bundle via:
*
Expand Down

0 comments on commit 33ec7d0

Please sign in to comment.