deepsweet / isparta-loader

💯 isparta instrumenter loader for webpack
117 stars 22 forks source link

sourcemaps #1

Open iam4x opened 9 years ago

iam4x commented 9 years ago

Anyway to keep sourcemaps at the right line?

kossnocorp commented 9 years ago

Seems like isparta has source maps support. Any change to get it?

dmitry commented 9 years ago

What is the problem here actually?

kossnocorp commented 9 years ago

@dmitry source maps don't passed:

localhost_4001

Before I integrated isparta-loader, source maps did worked as expected.

iam4x commented 9 years ago

Exactly what @kossnocorp said.

You can checkout my boilerplate (https://github.com/iam4x/isomorphic-flux-boilerplate) as repro case.

jhicken commented 9 years ago

The problem occurs when your using a globing pattern instead of a single file.

    files: [
      { pattern: './app/**/__tests__/**/*.js*', watched: true, included: true, served: true }
    ],

    preprocessors: {
      './app/**/__tests__/**/*.js*': ['webpack', 'sourcemap']
    }

When I switch it to a single file that has this... everything works.

var context = require.context('../app', true, /__tests__\/.*\.jsx?$/);
context.keys().forEach(context);

I would really prefer to have my includes inside files in my karma config. It seems bad that I would have to break karma convention so that this plugin will work properly.

deepsweet commented 9 years ago

actually single file approach is preferred, as it's described in README now.

fredantell commented 9 years ago

@jhicken @deepsweet I have a single file setup as suggested and my sourcemaps still don't seem to work. I can use Chrome Dev Tools to pretty print things which makes it mostly readable, but the __cov_hash lines are interspersed everywhere among my actual source. Does someone have an example repo where they have it working? If you're interested I'm happy to post some of my config files to help debug.

joshlasdin commented 9 years ago

+1

anatoliyarkhipov commented 9 years ago

+1. @jhicken Can you please give us the correct config, which works for you?

jhicken commented 9 years ago

@fredantell @anatoliyarkhipov @deepsweet Hey guys sorry. I had this setup in July. I have recently tried it again and I am not able to get the source maps to load properly anymore. In fact I hit some extra issues.

I am not able to get source maps at all without using devtool: 'eval' in my webpack settings. And using the eval method just makes me sad.

Secondly... This might be connected to the first problem. My break points are ignored. If I run tests with karma all my break points are ignored.

I haven't dug in to figure out whats going on yet.

fredantell commented 9 years ago

My solution to this problem was to use a gulp task to split out isparta. One gulp task runs just my tests with no mention of isparta in any config. The other gulp task runs just the code coverage and pops open a browser to view it. Since I don't really need both at the same time, it works well enough. If you're stuck that may be as good a work around as any.

On Mon, Oct 12, 2015 at 3:56 PM, Jeff Hicken notifications@github.com wrote:

@fredantell https://github.com/fredantell @anatoliyarkhipov https://github.com/anatoliyarkhipov @deepsweet https://github.com/deepsweet Hey guys sorry. I had this setup in July. I have recently tried it again and I am not able to get the source maps to load properly anymore. In fact I hit some extra issues.

I am not able to get source maps at all without using devtool: 'eval' in my webpack settings. And using the eval method just makes me sad.

Secondly... This might be connected to the first problem. My break points are ignored. If I run tests with karma all my break points are ignored.

I haven't dug in to figure out whats going on yet.

— Reply to this email directly or view it on GitHub https://github.com/deepsweet/isparta-loader/issues/1#issuecomment-147518559 .

joshlasdin commented 8 years ago

Does anyone have a well-documented workaround for this?

kiki-le-singe commented 8 years ago

You could use an option in your package.json's scripts:

{
  ...
  "scripts": {
    "test": "node ./node_modules/karma/bin/karma start",
    "test:dev": "npm run test -- --coverage"
  },
  ...
}

and dynamically add coverage support:

if (config.coverage_enabled) {
  karmaConfig.reporters.push('coverage');
  karmaConfig.webpack.module.preLoaders = [{
    test    : /\.(js|jsx)$/,
    include : new RegExp(config.get('dir_client')),
    loader  : 'isparta'
  }];
}

This way allows to keep sourcemaps when we are debugging. I use it and it works well.

See my sources React Redux Starter Kit from davezuko:

mwinche commented 8 years ago

PR to fix this: https://github.com/deepsweet/isparta-loader/pull/16

@deepsweet Do you have any issues with this?

gurghet commented 8 years ago

+1