Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatible with Vite #90

Closed
Artur- opened this issue Apr 20, 2022 · 4 comments · Fixed by vaadin/flow#13625
Closed

Incompatible with Vite #90

Artur- opened this issue Apr 20, 2022 · 4 comments · Fixed by vaadin/flow#13625

Comments

@Artur-
Copy link
Member

Artur- commented Apr 20, 2022

If you use Vaadin 23 and Vite, then window.Vaadin.developmentModeCallback["vaadin-license-checker"] is never defined

In function uncommentAndRun(callback, args) { the value of callback.toString() is

with webpack

function maybeCheckLicenses() {
  /** vaadin-dev-mode:start
...
  vaadin-dev-mode:end **/
}

with Vite

'function maybeCheckLicenses() {\n}'

window.Vaadin.developmentModeCallback["vaadin-usage-statistics"] works fine with both vite and webpack

@rolfsmeds
Copy link

Any thoughts on this, @vursen ?

@web-padawan
Copy link
Member

We might need to add "type": "module" to package.json - maybe that would help (but I'm not really sure).

@Artur-
Copy link
Member Author

Artur- commented Apr 26, 2022

It seems like this works if you are using the component bundle because there the commented code is intact. If you use e.g. 23.0.5 where the bundle is not used because of some version mismatches, you see this problem

@vursen
Copy link

vursen commented Apr 26, 2022

When the component bundle is not used, the license checker ends up optimized by Vite's deps optimizer (esbuild) which happens to eliminate code comments along the way.

The usage statistics module is included in Vaadin Router which is explicitly excluded from that optimization, which explains why the stats module is not affected.

One way to fix the issue would be to add @vaadin/vaadin-license-checker and @vaadin/vaadin-usage-statistics to optimizeDeps.exclude in vite.generated.ts.

Artur- pushed a commit to vaadin/flow that referenced this issue Apr 26, 2022
…13625)

Excludes @vaadin/vaadin-license-checker and @vaadin/vaadin-usage-statistics from the Vite deps optimization to prevent the special part of their source code serialized into a code comment from eliminating in dev mode:

Fixes vaadin/license-checker#90.
vaadin-bot pushed a commit to vaadin/flow that referenced this issue Apr 26, 2022
…13625)

Excludes @vaadin/vaadin-license-checker and @vaadin/vaadin-usage-statistics from the Vite deps optimization to prevent the special part of their source code serialized into a code comment from eliminating in dev mode:

Fixes vaadin/license-checker#90.
Artur- pushed a commit to vaadin/flow that referenced this issue Apr 26, 2022
…13625) (#13626)

Excludes @vaadin/vaadin-license-checker and @vaadin/vaadin-usage-statistics from the Vite deps optimization to prevent the special part of their source code serialized into a code comment from eliminating in dev mode:

Fixes vaadin/license-checker#90.

Co-authored-by: Sergey Vinogradov <mr.vursen@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants