Search code examples
node.jsecmascript-6traceur

How can I configure options using the traceur module on nodejs


How do I configure options using the traceur module on nodejs. I'm doing the following but it doesn't seem to work.

require('traceur').require.makeDefault(function(filename) {

    // don't transpile our dependencies, just our app
    return filename.indexOf('node_modules') === -1;

});

traceur.options.annotations = true;

require('./start.js');

traceur.options.annotations = true is not resulting in annotations being enabled in traceur


Solution

  • Pass the options as the second argument to makeDefault:

    require('traceur').require.makeDefault(function(filename) {
        // don't transpile our dependencies, just our app
        return filename.indexOf('node_modules') === -1;
    }, {annotations: true});
    

    See https://github.com/google/traceur-compiler/blob/master/src/node/require.js#L58

    You need to update use this feature.