Giter Club home page Giter Club logo

traceur-source-maps's Introduction

Traceur source maps

NPM version Build status Coveralls status Support us

When using Traceur as a command-line utility to transpile Node.js source code, it provides --source-maps option to create source map files. But when using at runtime by requiring traceur module to live-transpile files, Traceur lacks the ability to reports correct stack trace.

Here comes this module to solve that problem: it provides source map for Node.js files when using Traceur on the fly.

Installation

This module can be installed easily with npm:

$ npm install traceur-source-maps

Usage

Below is a small example to describe how to use this module.

bootstrap.js:

var traceur = require('traceur');

require('traceur-source-maps').install(traceur);

traceur.require.makeDefault(function (filePath) {
  return !~filePath.indexOf('node_modules');
});
// There is no need to pass `{ sourceMaps: true }` as options,
// source mapping is always enabled after install

require('./main');

main.js:

import { hey } from './greet';

hey();

greet.js:

export function hey() {
  hi();
}

export function hi() {
  throw new Error('Call me maybe!');
}

Run bootstrap.js using Node.js, notice the stack trace reports correct line number where the error occurred (line 6 of greet.js).

$ node bootstrap.js

/some/dir/greet.js:6
  throw new Error('Call me maybe!');

        ^
Error: Call me maybe!
    at hi (/some/dir/greet.js:6:9)
    at hey (/some/dir/greet.js:2:3)
    at Object.<anonymous> (/some/dir/main.js:3:1)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (/some/dir/node_modules/traceur-source-maps/node_modules/traceur/src/node/require.js:65:21)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/some/dir/bootstrap.js:12:1)

Compatibility

  • This module conflicts with all source code which uses source-map-support module (or maybe some modules with similar features) to provide source mapping.

  • This module has been tested to run properly with Traceur version 0.0.61 (latest version at the time of writing). It could be broken in the future if Traceur introduces non backward-compatible changes. In that circumstance, feel free to create new issue or create a pull request.

Contributing

Before create a pull request, make sure that you:

To execute all tests, simply run:

$ npm test

Contributors

License

This module is released under MIT license.

Analytics

traceur-source-maps's People

Contributors

beneidel avatar

Watchers

John Montoya avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.