Endpoint generation is impossible in Vaadin 24.4.x?

We upgraded our vaadin Hilla Application to the latest Version, where Hilla is absorbed into vaadin again. We used the following guide (How to upgrade Hilla applications | Vaadin)
After following the upgrade guide we used vaadin-maven-plugin to build our Project. However at this point there is a significant issue:
When running prepare-frontend goal no node_modules are updated or downloaded (intended I assume)
When running build-frontend right afterwards node_modules are created (in npm install). After npm install vite tries to build the application. This step fails, because no Hilla Endpoints have been generated.
Now we run the vaadin-plugin-generate step. This step now generates Endpoints and a rerun of build-frontend successfully builds the application.

Is it possible use the vaadin maven plugin in a way that we can build the application, generate endpoints and then use vite to build?

If you run generate before build-frontend it will fail, since no node_modules directory is either created or populated.
If you run build-frontend before generate it fails, because vite cannot resolve Endpoints since they have not been generated before.

This cannot be the intended behavior right? Where am I going wrong here?

Maybe the problem is that build-frontend is supposed to also run the generation goal and our application thinks its a flow-only application after the update…

Cheers,
James

If the upgrade has been done correctly, endpoints should be generated both in development mode and in production mode. And node_modules is also populated in both cases.

Without looking at the pom.xml at least, it’s hard to say where the problem is.

Can you share something more, like interesting fragments of the logs? Try running mvn clean package -Pproduction to see if the production build completes correctly. Running single Vaadin goals directly is not necessarily a complete process. They are meant to be part of the whole.

Thank you for your reply Luciano!

After running mvn clean package -Pproduction I run into the same problem: vaadin:generate is not being executed.

This is the build/production config in our pom.xml that we use:

<build>

        <defaultGoal>spring-boot:run</defaultGoal>
        <finalName>${project.artifactId}</finalName>

        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>com.vaadin</groupId>
                <artifactId>vaadin-maven-plugin</artifactId>
                <version>${vaadin.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>prepare-frontend</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <artifactId>maven-clean-plugin</artifactId>
                <configuration>
                    <filesets>
                        <fileset>
                            <directory>node_modules</directory>
                        </fileset>
                        <fileset>
                            <directory>.</directory>
                            <includes>
                                <include>webpack.generated.js</include>
                                <include>frontend/generated/</include>
                            </includes>
                        </fileset>
                    </filesets>
                </configuration>
            </plugin>

        </plugins>
    </build>
<profiles>
        <profile>
            <!-- Production mode is activated using -Pproduction -->
            <id>production</id>

            <dependencies>
                <!-- Exclude development dependencies from production -->
                <dependency>
                    <groupId>com.vaadin</groupId>
                    <artifactId>vaadin-core</artifactId>
                    <version>${vaadin.version}</version>
                    <exclusions>
                        <exclusion>
                            <groupId>com.vaadin</groupId>
                            <artifactId>vaadin-dev</artifactId>
                        </exclusion>
                    </exclusions>
                </dependency>
                <dependency>
                    <groupId>com.vaadin</groupId>
                    <artifactId>vaadin</artifactId>
                    <version>${vaadin.version}</version>
                    <exclusions>
                        <exclusion>
                            <groupId>com.vaadin</groupId>
                            <artifactId>vaadin-dev</artifactId>
                        </exclusion>
                    </exclusions>
                </dependency>
            </dependencies>

            <build>
                <plugins>
                    <plugin>
                        <groupId>com.vaadin</groupId>
                        <artifactId>vaadin-maven-plugin</artifactId>
                        <version>${vaadin.version}</version>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>build-frontend</goal>
                                </goals>
                                <phase>compile</phase>
                            </execution>
                        </executions>
                        <configuration>
                            <!-- To always force an optimized production bundle build set this configuration to 'true' -->
                            <forceProductionBuild>true</forceProductionBuild>
                            <!-- To have reproducible build by running 'npm ci' -->
                            <!-- False: Funktioniert aktuell noch nicht erwartungsgemäß -->
                            <ciBuild>false</ciBuild>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

The symptoms suggest to me that the plugin assumes that Hilla is not in use for some reason, perhaps our auto-detection is unable to detect the Hilla usage you have to enable the endpoint generator tasks. To workaround, creating at least one non-blank Hilla view file in the frontend/views directory could help.

Could you, please, try creating a non-empty .ts file inside [src/main]frontend/views/? For example:

frontend/views/_workaround.ts:

// Make sure that Vaadin detects a Hilla view file
export default function HillaView() {
  return "";
}

That was the missing piece! Thank you!

We had all of our .ts files in a seperate folder and not within src/main/frontend/views. After moving our .ts files into the new directory mvn clean package -P production now properly builds the frontend including all Endpoints.

1 Like