flow
flow copied to clipboard
Vite: errors when importing ES modules with default exports from bundles
Description of the bug
In a Vaadin application that uses Vite and @vaadin/map
component, the following error is thrown:
SyntaxError: unexpected token 'default'
for the following code:
const { default } = (await import('ol/renderer/canvas/Layer.js'));
export { default as default };
The application does not open.
The error is gone after deleting node_modules/@vaadin/bundles
directory.
Expected behavior
The application should open without errors.
Minimal reproducible example
- Create an application using Vaadin 23.2.0.beta1
- Add
<vaadin-map>
component to the main view
Versions
- Vaadin / Flow version: 23.2.0.beta1
- Java version:
- OS version:
- Browser version (if applicable):
- Application Server (if applicable):
- IDE (if applicable):
Here is the problematic code from a https://start.vaadin.com generated project.
import { init as VaadinBundleInit, get as VaadinBundleGet } from '/VAADIN/@fs/Users/artur/workspace/vaadin/start/node_modules/@vaadin/bundles/vaadin.js?v=e3242472';
await VaadinBundleInit('default');
const { default } = (await VaadinBundleGet('./node_modules/ol/renderer/canvas/Layer.js'))();
export { default as default };
The regression is introduced in this commit https://github.com/vaadin/flow/commit/2d2363beb007870566f4f3bec4e2557ac8c09f05