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

[v4.x] fix(karma-webpack): handle multiple outputs correctly #361

Merged
merged 4 commits into from
Nov 20, 2018

Conversation

alabbas-ali
Copy link
Contributor

@alabbas-ali alabbas-ali commented Sep 21, 2018

This PR contains a:

  • bugfix
  • new feature
  • code refactor
  • test update
  • typo fix
  • metadata update

Motivation / Use-Case

uplift fix multiple output files to 4.x branch

21 09 2018 23:54:23.585:ERROR [karma]: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type object

@michael-ciniawsky michael-ciniawsky changed the title uplift multiple output files fix to the 4.x branch [v4.x] fix(karma-webpack): handle multiple outputs correctly Sep 22, 2018
@michael-ciniawsky michael-ciniawsky added this to the 4.0.0 milestone Sep 22, 2018
@bdirito
Copy link

bdirito commented Oct 10, 2018

miniCssExtractPlugin breaks karma-webpack. Since i dont require styles one way or the other for my unit tests I just remove it from the webpack entry of karma.config as a workarround.

MiniCssExtractPlugin = require 'mini-css-extract-plugin'
webpackConfig = require './webpack.config'

removeMiniCssExtract = (conf) ->
    for rule in conf.module.rules
        if rule.use
            rule.use = rule.use.filter( (u) -> u != MiniCssExtractPlugin.loader)
    return conf

# ...
 webpack: removeMiniCssExtract(webpackConfig)

@mario-d-s
Copy link

@bdirito tried it but it didn't work... Karma-webpack is still receiving multiple entry points. What syntax is that code by the way?

Besides the mini CSS extract plugin, enabling source maps also results in multiple entry points being passed (.js and .js.map), but maybe I'm doing something wrong here...

@alabbas-ali
Copy link
Contributor Author

I can't see the need to have such work workarround. if merging this branch will solve the problem. I test it also with MiniCssExtractPlugin and it is working fine.

@bdirito
Copy link

bdirito commented Oct 11, 2018

@mario-d-s MiniCssExtractPlugin is only one example of a webpack plugin that produces this issue. Various other plugins can and will also trigger this issue so it will not work in cases where you are using those. Depending on what those plugins do it may or may not be possible to remove them in the same manner, I can only do this because css is irrelevant for my unit testing. The syntax is coffeescript.

@alabbas-ali I would prefer to have a fix merged in to webpack-karma but in the absence of that happening (why is review taking so long for an 'urgent regression'?) I wanted something that didnt require building before use. Ideally this issue would be fixed and any such workarounds can be removed.

@thijstriemstra
Copy link

(why is review taking so long for an 'urgent regression'?)

I'd also like to know. Can this please be merged and released?

@@ -18,6 +18,18 @@ let isBlocked = false;

const normalize = (file) => file.replace(/\\/g, '/');

var getOutputPath = (outputPath) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make this just a function instead? Or use const

Suggested change
var getOutputPath = (outputPath) => {
function getOutputPath(outputPath) {
Suggested change
var getOutputPath = (outputPath) => {
const getOutputPath = (outputPath) => {

return outputPath[i]
}
}
return null
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semi-colon

Suggested change
return null
return null;


this.outputs.set(entryPath, outputPath);

if (Array.isArray(outputPath))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add braces around these statements please

outputPath[i].indexOf(".js") !== -1 &&
outputPath[i].indexOf(".js.map") === -1
) {
return outputPath[i]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return outputPath[i]
return outputPath[i];

@bensampaio
Copy link

Any updates on this? Would be really great to have this merged so that I can go forward with upgrading to Webpack 4.

@plusgut
Copy link

plusgut commented Nov 7, 2018

@michael-ciniawsky any updates?

@thijstriemstra
Copy link

Why is this not merged...

@43081j
Copy link

43081j commented Nov 8, 2018

I'm seeing a lot of issues in both 3.x and 4.x around sourcemaps and such too.

3.x has a fix in place for multiple outputs but it introduces more issues than it resolves. It means things like sourcemaps are lost/broken as their outputs are thrown away.

This may resolve the issue. If it does, it needs to be added to 3.x too if thats still being maintained.

@neemski
Copy link

neemski commented Nov 15, 2018

@rynclark @michael-ciniawsky any updates on this? As many have pointed out, we are blocked from upgrading to Webpack 4 until this is merged/released

@edmorley
Copy link

Please can we review/merge this?

At this point just switching wholesale to Jest is seeming very appealing.
The Karma ecosystem seems to be in decline.

@alexander-akait
Copy link
Collaborator

We need contributor for this loader, there is no one here right now, so if you can and have time for this ping me in gitter (https://gitter.im/webpack/webpack)

@matthieu-foucault
Copy link
Collaborator

matthieu-foucault commented Nov 20, 2018

I just got collaborator access. Bear with me as I am trying to get this merged. Currently, I cannot do that as the TravisCI build is pending (and will stay that way). It seems that this check has been ignored since #344 (at least) and that admin rights have been used to merge PRs.

If an admin sees this, can you please disable the required check?

@alexander-akait
Copy link
Collaborator

alexander-akait commented Nov 20, 2018

@matthieu-foucault temporary disable, need fix

@matthieu-foucault
Copy link
Collaborator

Well, I still can't merge this. Looks like only an admin can merge to master.

@ryanclark
Copy link
Collaborator

Yeah, that's why I didn't merge - we need @michael-ciniawsky as far as I'm aware

@matthieu-foucault
Copy link
Collaborator

@evilebottnawi seems to be able to change these things. Can you add @rynclark (my help isn't needed if Ryan is available) to the list of contributors allowed to push to master?

@ryanclark
Copy link
Collaborator

Thanks @matthieu-foucault. I'm also not able to publish to npm, though. // @evilebottnawi

@alexander-akait

This comment has been minimized.

@alexander-akait

This comment has been minimized.

@alexander-akait

This comment has been minimized.

@ryanclark ryanclark merged commit 41edac8 into codymikol:master Nov 20, 2018
@alabbas-ali alabbas-ali deleted the v4-multiple-output-files branch November 23, 2018 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet