/ts-transform-jsx-source

Adds source file, line number and column number to JSX elements

Primary LanguageTypeScriptMIT LicenseMIT

ts-transform-jsx-source

Adds source file, line number and column number to JSX elements.

Example

In

<sometag>foo</sometag>

Out

<sometag
  __source={{
    fileName: '/Users/me/proj/src/thisFile.tsx',
    lineNumber: 20,
    columnNumber: 11,
  }}
>
  foo
</sometag>

Installation

yarn add -D ts-transform-jsx-source

Usage

Webpack

import tsTranformJsxSource from 'ts-transform-jsx-source';

// ...
{
  loader: "awesome-typescript-loader",
  options: {
    getCustomTransformers: () => ({ before: [tsTranformJsxSource] })
  }
}
// ...

Fusebox

import tsTranformJsxSource from 'ts-transform-jsx-source';

const fuse = FuseBox.init({
  homeDir: 'src/',
  target: 'browser@es6',
  output: 'dist/$name.js',
  transformers: {
    before: [tsTranformJsxSource],
  },
});