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

fix issue when webpack entrypoint config has a non string value for file #2206

Merged
merged 1 commit into from
Aug 12, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -122,25 +122,23 @@ private static void visitWebpackConfiguration(@NotNull Project project, @NotNull
public void visitElement(@NotNull PsiElement element) {
if (element instanceof JSCallExpression) {
PsiElement methodExpression = element.getFirstChild();
if (methodExpression instanceof JSReferenceExpression) {
String name = ((JSReferenceExpression) methodExpression).getReferenceName();
if (methodExpression instanceof JSReferenceExpression jsReferenceExpression) {
String name = jsReferenceExpression.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 jsLiteralExpressionArg1) {
String parameter1 = jsLiteralExpressionArg1.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