Skip to content

$traceurRuntime used before its inclusion when using generators #1141

@amitport

Description

@amitport

tested a simple generator on nodejs (compiling using --modules=commonjs)

require('traceur/bin/traceur-runtime');

function* range(begin, end) {
    for (var i = begin; i <= end; ++i) {
        yield i;
    }
} 

the generated code was:

"use strict";
var $__0 = $traceurRuntime.initGeneratorFunction(range);
require('traceur/bin/traceur-runtime');
function range(begin, end) {
  var i;
  return $traceurRuntime.createGeneratorInstance(function($ctx) {
    while (true)
...

this throws ReferenceError: $traceurRuntime is not defined

(can bypass this by including the runtime in a pre-required file, but it is annoying when testing a single file)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions