The build-frontend goal fails in class com.vaadin.flow.server.frontend.ImportExtractor when some of the used JS code contains a module import with .from in the name. The reason is because the maven plugin code cannot distinguish between the real from token and any "from" char sequence in an imported module name, e.g. for import 'core-js/modules/es6.array.from';
The maven stacktrace looks like this:
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.vaadin:vaadin-maven-plugin:23.5.0:build-frontend (default) on project centerdevice-web-client: Could not execute build-frontend goal
...
Caused by: org.apache.maven.plugin.MojoFailureException: Could not execute build-frontend goal
at com.vaadin.flow.plugin.maven.BuildFrontendMojo.execute (BuildFrontendMojo.java:109)
...
Caused by: com.vaadin.flow.server.ExecutionFailedException: Error occured during goal execution: begin 1, end 0, length 1Please run Maven with the -e switch (or Gradle with the --stacktrace switch), to learn the full stack trace.
at com.vaadin.flow.plugin.base.BuildFrontendUtil.runNodeUpdater (BuildFrontendUtil.java:341)
at com.vaadin.flow.plugin.maven.BuildFrontendMojo.execute (BuildFrontendMojo.java:107)
...
Caused by: java.lang.StringIndexOutOfBoundsException: begin 1, end 0, length 1
at java.lang.String.checkBoundsBeginEnd (String.java:4602)
at java.lang.String.substring (String.java:2705)
at com.vaadin.flow.server.frontend.ImportExtractor.strip (ImportExtractor.java:94)
at com.vaadin.flow.server.frontend.ImportExtractor.getImportedPaths (ImportExtractor.java:71)
at com.vaadin.flow.server.frontend.AbstractUpdateImports.visitImportsRecursively (AbstractUpdateImports.java:602)
at com.vaadin.flow.server.frontend.AbstractUpdateImports.handleImports (AbstractUpdateImports.java:650)
at com.vaadin.flow.server.frontend.AbstractUpdateImports.getUniqueEs6ImportPaths (AbstractUpdateImports.java:375)
at com.vaadin.flow.server.frontend.AbstractUpdateImports.getModuleLines (AbstractUpdateImports.java:413)
at com.vaadin.flow.server.frontend.AbstractUpdateImports.collectModules (AbstractUpdateImports.java:324)
at com.vaadin.flow.server.frontend.AbstractUpdateImports.run (AbstractUpdateImports.java:128)
at com.vaadin.flow.server.frontend.TaskUpdateImports.execute (TaskUpdateImports.java:389)
at com.vaadin.flow.server.frontend.NodeTasks.execute (NodeTasks.java:334)
at com.vaadin.flow.plugin.base.BuildFrontendUtil.runNodeUpdater (BuildFrontendUtil.java:335)
at com.vaadin.flow.plugin.maven.BuildFrontendMojo.execute (BuildFrontendMojo.java:107)
...
Expected behavior
The expected behavior is that the build-frontend succeeds.
Minimal reproducible example
Add any JS file to the project that contains the following import:
Description of the bug
The
build-frontend
goal fails in classcom.vaadin.flow.server.frontend.ImportExtractor
when some of the used JS code contains a module import with.from
in the name. The reason is because the maven plugin code cannot distinguish between the realfrom
token and any"from"
char sequence in an imported module name, e.g. forimport 'core-js/modules/es6.array.from';
The maven stacktrace looks like this:
Expected behavior
The expected behavior is that the build-frontend succeeds.
Minimal reproducible example
Add any JS file to the project that contains the following import:
Versions