Take the Spring Boot starter project and replace webpack.config.js with
foo
If you run node_modules/.bin/webpack manually, you will get
ReferenceError: foo is not defined
at Object.<anonymous> (.../webpack.config.js:1:63)
If you run mvn, you get
2020-02-03 12:15:47.107 ERROR 60528 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Exception sending context initialized event to listener instance of class [com.vaadin.flow.spring.VaadinServletContextInitializer$DevModeServletContextListener]
java.lang.RuntimeException: Unable to initialize Vaadin DevModeHandler
at com.vaadin.flow.spring.VaadinServletContextInitializer$DevModeServletContextListener.contextInitialized(VaadinServletContextInitializer.java:349) ~[vaadin-spring-12.2.0.alpha1.jar:na]
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4680) [tomcat-embed-core-9.0.22.jar:9.0.22]
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5143) [tomcat-embed-core-9.0.22.jar:9.0.22]
...
Caused by: java.lang.IllegalStateException: Webpack exited prematurely
at com.vaadin.flow.server.DevModeHandler.<init>(DevModeHandler.java:201) ~[flow-server-2.2.0.alpha10.jar:2.2.0.alpha10]
at com.vaadin.flow.server.DevModeHandler.createInstance(DevModeHandler.java:298) ~[flow-server-2.2.0.alpha10.jar:2.2.0.alpha10]
at com.vaadin.flow.server.DevModeHandler.start(DevModeHandler.java:248) ~[flow-server-2.2.0.alpha10.jar:2.2.0.alpha10]
This does not even contain a reference to webpack.config.js nor to the problem that actually occured in webpack
It does say Webpack exited prematurely, is there any more log before the illegal state?
Also as you replaced the config content with foo up in the logs do you have:
"Flow generated webpack configuration was not mentioned "
"in the configuration file: {}."
"Please verify that './webpack.generated.js' is used "
"in the merge or remove the file to generate a new one."
Same thing here with Vaadin 14.5.1: I only see the exception but there is no indication in the entire stdout as to why the webpack would fail:
Caused by: java.lang.IllegalStateException: Webpack exited prematurely
at com.vaadin.flow.server.DevModeHandler.doStartWebpack(DevModeHandler.java:657)
at com.vaadin.flow.server.DevModeHandler.doStartDevModeServer(DevModeHandler.java:583)
at com.vaadin.flow.server.DevModeHandler.runOnFutureComplete(DevModeHandler.java:530)
at com.vaadin.flow.server.DevModeHandler.lambda$new$0(DevModeHandler.java:146)
at java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:774)
This started to happen after I applied the checker from #8475 . Without the checker the Vaadin would fail in runtime with Uncaught DOMException: CustomElementRegistry.define: 'vaadin-lumo-styles' has already been defined as a custom element: the checker apparently catches the issue early on (which is a good thing), but then Vaadin logs nothing of the issue and fails with this useless exception.
This is a horrible dev UX experience - my project doesn't start anymore, and I have no idea why. I would rather revert the checker and go back to failing at runtime, at least there I'll receive an "informative" error message.
Is this only in v14 dev mode server start?
For v19+ there is the server output when running the server (both plain and spring starter):
[INFO] com.vaadin.flow.server.DevModeHandler : Running webpack to compile frontend resources. This may take a moment, please stand by...
...\skeleton-starter-flow\webpack.config.js:1
foo
^
ReferenceError: foo is not defined
at Object.<anonymous> (...\skeleton-starter-flow\webpack.config.js:1:1)
at Module._compile (node:internal/modules/cjs/loader:1092:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1121:10)
at Module.load (node:internal/modules/cjs/loader:972:32)
at Function.Module._load (node:internal/modules/cjs/loader:813:14)
at Module.require (node:internal/modules/cjs/loader:996:19)
at require (node:internal/modules/cjs/helpers:92:18)
at WEBPACK_OPTIONS (...\skeleton-starter-flow\node_modules\.pnpm\[email protected][email protected]\node_modules\webpack-cli\bin\utils\convert-argv.js:114:13)
at requireConfig (...\skeleton-starter-flow\node_modules\.pnpm\[email protected][email protected]\node_modules\webpack-cli\bin\utils\convert-argv.js:116:6)
at ...\skeleton-starter-flow\node_modules\.pnpm\[email protected][email protected]\node_modules\webpack-cli\bin\utils\convert-argv.js:123:17
@caalador could be - I've only tested Vaadin 14.5.1.
Most helpful comment
Same thing here with Vaadin 14.5.1: I only see the exception but there is no indication in the entire stdout as to why the webpack would fail:
This started to happen after I applied the checker from #8475 . Without the checker the Vaadin would fail in runtime with
Uncaught DOMException: CustomElementRegistry.define: 'vaadin-lumo-styles' has already been defined as a custom element: the checker apparently catches the issue early on (which is a good thing), but then Vaadin logs nothing of the issue and fails with this useless exception.This is a horrible dev UX experience - my project doesn't start anymore, and I have no idea why. I would rather revert the checker and go back to failing at runtime, at least there I'll receive an "informative" error message.