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
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions src/karma-webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {

for (var i = 0; i < outputPath.length; i++) {
if (
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];

}
}
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;

}

const escapeRegExp = function(str) {
// See details here https://stackoverflow.com/questions/3446170/escape-string-for-use-in-javascript-regex
return str.replace(/[-[\]/{}()*+?.\\^$|]/g, '\\$&');
Expand Down Expand Up @@ -170,8 +182,11 @@ function Plugin(
if (this.entries.has(entry)) {
const entryPath = this.entries.get(entry);
const outputPath = stats.assetsByChunkName[entry];

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 = getOutputPath(outputPath);
if (outputPath !== null)
this.outputs.set(entryPath, outputPath);
}
}

Expand Down