karma-webpack icon indicating copy to clipboard operation
karma-webpack copied to clipboard

Can't specify transformPath

Open jquense opened this issue 5 years ago • 5 comments

  • webpack Version: 5
  • karma-webpack Version: 5

Expected Behavior

providing transformPath per the README works

Actual Behavior

The option is also passed to webpack which throws because it validates the config and transformPath is not a valid webpack option

How Do We Reproduce?

provide transformPath in config.webpack and try and do a test run

jquense avatar Feb 09 '21 14:02 jquense

Can you post your webpack + karma configurations?

codymikol avatar Feb 09 '21 16:02 codymikol

any config with the option set would have this issue, here's a minimal one!

module.exports = (config) => {
  config.set({
    frameworks: ['webpack'],
    files: ['test/entry.ts'],
    preprocessors: {
      'test/entry.ts': ['webpack'],
    },
    webpack: {
      transformPath: (filepath) => {
        // force *.js files by default
        const info = path.parse(filepath);
        return `${path.join(info.dir, info.name)}.js`;
      },
    },
  });
};

jquense avatar Feb 09 '21 18:02 jquense

Thanks for creating an issue,

I can confirm that transformPath does not work as expected. This was a feature that existed prior to me working on this project and interestingly I just created an integration test mimicking your setup but without the transformPath option and everything works as expected. Could you give this a shot without the transformPath option?

It seems that in any case this is not a valid configuration field for webpack and that it will always cause failures. If simply removing that option fixes your setup, I will remove the transformPath docs entirely.

codymikol avatar Feb 13 '21 23:02 codymikol

Yeah it works fine without it, since the default works find for TS. I'm not sure if anyone would need to specify it

jquense avatar Feb 14 '21 02:02 jquense

Just made a PR to update the docs, thanks for pointing this out

codymikol avatar Feb 14 '21 05:02 codymikol