Vite/Rollup build error after upgrading to 24.1.8

After upgrading to 24.1.8, we get an error on production build:

> Vite process exited with non-zero exit code.
  Stderr: 'vite v4.3.9 building for production...
  ✓ 95 modules transformed.
  ✓ built in 527ms
  'import' and 'export' may only appear at the top level
  file: /Users/oliver/Desktop/temp/my-project/webapp/frontend/generated/flow/chunks/chunk-1346eb852bbd0b39ff83320d261244ab73bf455d2e46d5135c021e3040087eb5.js:8:0
   6: const $css_0 = typeof $cssFromFile_0  === 'string' ? unsafeCSS($cssFromFile_0) : $cssFromFile_0;
   7: function addCssBlock(block) {
   8: import $cssFromFile_0 from 'Frontend/generated/jar-resources/styles/badge.css?inline';
   9: import $cssFromFile_1 from 'Frontend/styles/manifest-editor.scss?inline';
  10: import '@vaadin/app-layout/theme/lumo/vaadin-drawer-toggle.js';
  error during build:
  RollupError: 'import' and 'export' may only appear at the top level
      at error (file:///Users/oliver/Desktop/temp/my-project/webapp/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:2287:30)
      at Module.error (file:///Users/oliver/Desktop/temp/my-project/webapp/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:13726:16)
      at Module.tryParse (file:///Users/oliver/Desktop/temp/my-project/webapp/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:14457:25)
      at Module.setSource (file:///Users/oliver/Desktop/temp/my-project/webapp/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:14058:39)
      at ModuleLoader.addModuleSource (file:///Users/oliver/Desktop/temp/my-project/webapp/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:24623:20)

Tried cleaning the frontend.

The chunk starts with:

 const tpl = document.createElement('template');
 tpl.innerHTML = block;
addCssBlock(`<style include="lumo-badge">${$css_0}</style>`);
const $css_0 = typeof $cssFromFile_0  === 'string' ? unsafeCSS($cssFromFile_0) : $cssFromFile_0;
function addCssBlock(block) {
import $cssFromFile_0 from 'Frontend/generated/jar-resources/styles/badge.css?inline';
import $cssFromFile_1 from 'Frontend/styles/manifest-editor.scss?inline';

Clearly, this is invalid JS. sounds like the culprit

Going to try the prerelease


@quirky-zebra Tried with 24.2.0.alpha10. Same error

I know, it should be faulty because the PR is in both releases :sweat_smile:

I mean the PR could be the cause of the issue, it it wasn’t the case with 24.1.7


Wait, how do you know its part of 24.1.8? The vaadin bot says it will be part of 24.2.0

I linked the wrong PR of the 24.1.8 Release Notes :confused:

Sorry, I am confused. Are you saying that the PR you linked is irrelevant?

Here is the cherry pick



I just linked the original PR because those are linked in the release Notes and not the cherry picks :see_no_evil:

Cherry pick PR was included in 24.1.8

Thank you

Okay, I’ll try overriding the class on the classpath with the old code and let you know