Skip to content

Commit

Permalink
fix issue when webpack entrypoint config has a non string value for file
Browse files Browse the repository at this point in the history
  • Loading branch information
Haehnchen committed Aug 12, 2023
1 parent 962cdcb commit d365cf9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,21 +126,19 @@ public void visitElement(@NotNull PsiElement element) {
String name = ((JSReferenceExpression) methodExpression).getReferenceName();
if ("addStyleEntry".equals(name) || "addEntry".equals(name)) {
JSExpression[] arguments = ((JSCallExpression) element).getArguments();
if (arguments.length >= 1) {
if (arguments[0] instanceof JSLiteralExpression) {
String parameter1 = ((JSLiteralExpression) arguments[0]).getStringValue();
String parameter2 = null;

if (StringUtils.isNotBlank(parameter1)) {
if (arguments.length >= 2) {
String parameter2Value = ((JSLiteralExpression) arguments[1]).getStringValue();
if (StringUtils.isNotBlank(parameter2Value)) {
parameter2 = parameter2Value;
}
if (arguments.length >= 1 && arguments[0] instanceof JSLiteralExpression jsLiteralExpressionArg0) {
String parameter1 = jsLiteralExpressionArg0.getStringValue();
String parameter2 = null;

if (StringUtils.isNotBlank(parameter1)) {
if (arguments.length >= 2 && arguments[1] instanceof JSLiteralExpression jsLiteralExpressionArg2) {
String parameter2Value = jsLiteralExpressionArg2.getStringValue();
if (StringUtils.isNotBlank(parameter2Value)) {
parameter2 = parameter2Value;
}

consumer.accept(new WebpackAsset(virtualFile, parameter1, parameter2, arguments[0]));
}

consumer.accept(new WebpackAsset(virtualFile, parameter1, parameter2, arguments[0]));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void testVisitEntries() {
}
});

assertContainsElements(entries, "foo", "foobar", "entry_foobar_2", "addStyleEntryFoobar");
assertContainsElements(entries, "foo", "foobar", "entry_foobar_2", "addStyleEntryFoobar", "function_foo");
assertContainsElements(targets, "./assets/app.js");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Encore
*/
.addEntry('foobar', './assets/app.js')
.addEntry("foo")
.addEntry("function_foo", function() {})
.addStyleEntry('addStyleEntryFoobar')

.enableVueLoader(() => {}, { runtimeCompilerBuild: false })
Expand Down

0 comments on commit d365cf9

Please sign in to comment.