Build frontend cannot resolve import "tslib" (Verson 3.1.0 on Vaadin 25.0.7)

I’ve upgraded a Flow application from Vaadin 24 to 25 and the dependency of vcf-month-picker-flow from 2.0.0 to 3.1.0.

Building the front-end then gave me the following error message:


> Vite process exited with non-zero exit code.
  Stderr: 'vite v7.3.1 building client environment for production...
  transforming...
   566 modules transformed.
  vite v7.3.1 building client environment for production...
  transforming...
   79 modules transformed.
  rendering chunks...
  computing gzip size...
  ../../../build/resources/main/META-INF/VAADIN/webapp/sw.js  19.40 k‚ gzip: 6.50 kB
  built in 3.90s
  Build failed in 7.76s
  error during build:
  [vite]: Rollup failed to resolve import "tslib" from "C:/.../node_modules/@vaadin-component-factory/vcf-month-picker/dist/src/component/vcf-month-picker.js".
  This is most likely unintended because it can break your application at runtime.
  If you do want to externalize this module explicitly add it to
  `build.rollupOptions.external`
      at viteLog (file:///C:/.../node_modules/vite/dist/node/chunks/config.js:33635:57)
      at file:///C:/.../node_modules/vite/dist/node/chunks/config.js:33669:73
      at Object.onwarn (file:///C:/.../node_modules/.vite-temp/vite.config.ts.timestamp-1773396245191-8a269c9f18f21.mjs:1495:11)
      at onwarn (file:///C:/.../node_modules/@vitejs/plugin-react/dist/index.js:75:78)
      at file:///C:/.../node_modules/vite/dist/node/chunks/config.js:33669:28
      at onRollupLog (file:///C:/.../node_modules/vite/dist/node/chunks/config.js:33664:63)
      at onLog (file:///C:/.../node_modules/vite/dist/node/chunks/config.js:33467:4)
      at file:///C:/.../node_modules/rollup/dist/es/shared/node-entry.js:20981:32
      at Object.logger [as onLog] (file:///C:/.../node_modules/rollup/dist/es/shared/node-entry.js:22968:9)
      at ModuleLoader.handleInvalidResolvedId (file:///C:/.../node_modules/rollup/dist/es/shared/node-entry.js:21712:26)
      at file:///C:/.../node_modules/rollup/dist/es/shared/node-entry.js:21670:26
  '

As a work-around I’m annotating my Java class (where org.vaadin.addons.componentfactory.monthpicker.MonthPicker is imported):
@NpmPackage(value = "tslib", version = "2.8.1")

This automatically adds the “tslib” library as dependency into package.json and the build succeeds.

Is annotating the Java class the intended approach in Vaadin 25 or is there a better solution?

Hello, the workaround is valid but the proper way will be for the web-component to handle the dependency. I’ve created an issue to track the problem Build error in Vaadin 25.0.7: Rollup failed to resolve import "tslib" · Issue #14 · vaadin-component-factory/vcf-month-picker-flow · GitHub