codymikol / karma-webpack

Karma webpack Middleware
MIT License
829 stars 222 forks source link

Can't specify transformPath #488

Closed jquense closed 1 year ago

jquense commented 3 years ago

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

codymikol commented 3 years ago

Can you post your webpack + karma configurations?

jquense commented 3 years ago

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`;
      },
    },
  });
};
codymikol commented 3 years ago

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.

jquense commented 3 years ago

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

codymikol commented 3 years ago

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