Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sourcemap contains js files #17

Closed
flyon opened this issue May 21, 2015 · 4 comments
Closed

sourcemap contains js files #17

flyon opened this issue May 21, 2015 · 4 comments

Comments

@flyon
Copy link

flyon commented May 21, 2015

Hey, I'm using this together with your jsx-ts-loader plugin.
Also I need sourcemaps, and I used to use the 'sourceRoot' in the sourcemap file before.
I just read here how I can do that with webpack, and it's working, but now I see the content of my sourcefiles are actually the compiled js, not typescript. Any idea what I'm doing wrong or if this is a bug?
Here's my setup:

// webpack.config.js
var webpack = require('webpack');

module.exports = {
    entry: './init.ts',
    output: {
        filename: '../builds/html.bundle.js'
    },
    resolve: {
        extensions: ['', '.ts', '.webpack.js', '.web.js', '.js']
    },
    module: {
        loaders: [
            { test: /\.ts$/, loader: 'ts-loader!ts-jsx-loader' }
        ]
    },
    /*devtool: 'source-map',*/
    plugins: [
        new webpack.SourceMapDevToolPlugin(
            '[file].map', null,
            "../src/modules/html/[resource-path]", "../src/modules/html/[resource-path]")
    ]
};

and the abbriviated sourcemap file:

  "sources": [
    "../src/modules/html/webpack/bootstrap 1c9252c83a8886ca73cb",
    "../src/modules/html/./init.ts",
    "../src/modules/html/./src/UnsortedList.ts"
  ],
  "names": [],
  "mappings": ";AAAA;AACA;;AAEA;[...]ACA",
  "file": "../_builds/dacore.html.bundle.js",
  "sourcesContent": [
    "[..webpacksourcehere..]**/",
    "[..not_a_class_file...]",
    "[..here comes output from the TS compiler! --->] var  __extends = this.__extends || function (d, b) {\r\n    for (var p [.....]**/"
  ],
  "sourceRoot": ""
@jbrantly
Copy link
Member

Make sure you've set sourceMap to true in your tsconfig.json file. If that still doesn't work I'll see if I can duplicate.

On a side note, just before you posted this I reached out to you on twitter. Wondering about your thoughts on feature parity between this and other TS loaders.

@jbrantly
Copy link
Member

I did test this and it works fine as long as you have specified a tsconfig.json file and turned sourcemaps on. By default they are off so TypeScript never generates a sourcemap to hand off to webpack.

I'm going to close since I don't believe there is an issue but if you still have problems feel free to reopen.

@flyon
Copy link
Author

flyon commented May 28, 2015

hey, sorry for the late reply. I had never heard of tsconfig.json yet, it works now. tnx!

@perkinss
Copy link

Will this also work if the ts configuration is inside the webpack configuration instead of a tsconfig.json?

 ...
 module: {
      loaders: [
           // all files with a `.ts` or `.tsx` extension will be handled by `ts-loader`
          { test: /\.tsx?$/, loader: 'ts-loader' }
          ]
    },
    ts: {
        // configures the ts compiler:
        "compilerOptions": {
            "target": "es5",
            "sourceMap": true,
            "jsx": "react",
            "experimentalDecorators": true
         },
         "exclude": [
             "node_modules" // add other exclusions for the ts compiler.
            ]
         },...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants