vaadin / flow

Vaadin Flow is a Java framework binding Vaadin web components to Java. This is part of Vaadin 10+.
Apache License 2.0
603 stars 165 forks source link

lit-html/is-server.js cannot be found caused by missing version for lit #15007

Closed joergdev closed 10 months ago

joergdev commented 1 year ago

Describe the bug

Getting this error:

Webpack build failed with errors: ERROR in ../node_modules/.pnpm/lit@2.4.0/node_modules/lit/index.js Module not found: Error: Can't resolve 'lit-html/is-server.js' in '....\node_modules.pnpm\lit@2.4.0\node_modules\lit' @ ../node_modules/.pnpm/lit@2.4.0/node_modules/lit/index.js 1:87-122 1:87-122 @ ../node_modules/@vaadin/flow-frontend/@f0rce/lit-ace/lit-ace.js @ ../target/frontend/generated-flow-imports.js

Caused by:

There is no version provided (in package.json) for "lit" so the newest version (lit 2.4.0) is used. In lit 2.4.0 index.js the file lit-html/is-server.js should be loaded but doesnt exists because lit-html is provided with version 1.4.1 (in package.json) but is-server.js exists only from version 2.4.0.

Expected-behavior

Versions should work together, lit should be explicit provided with version 2.3.0 (as it is in newest vaadin version).

Reproduction

Allways

System Info

Windows 10, Vaadin 14.8.20 (also with 14.9.1), Google Chrome 107.0.5304.88

vaadin-bot commented 1 year ago

Thanks for using Vaadin! We appreciate your help and we’ll take care of this as soon as possible.

joergdev commented 1 year ago

Workaround: Replacing all files in lit folder with files from version < 2.4.0 worked for me.

TatuLund commented 1 year ago

../node_modules/@vaadin/flow-frontend/@f0rce/lit-ace/lit-ace.js

Based on this you are using https://vaadin.com/directory/component/ace

Are you using version 2.3.1 (for Vaadin 14) or 3.4.2 (for Vaadin 23)?

joergdev commented 1 year ago

../node_modules/@vaadin/flow-frontend/@f0rce/lit-ace/lit-ace.js

Based on this you are using https://vaadin.com/directory/component/ace

Are you using version 2.3.1 (for Vaadin 14) or 3.4.2 (for Vaadin 23)?

=> 2.3.1

Chris-SP365 commented 1 year ago

Happened to me as well. An update to 14.9.2 did not work due to problems with License.ts, so I did a Vaadin Dance.

After that, this error appeared. Could work around by overriding settings in package.json.

mcollovati commented 1 year ago

I tried to reproduce the issue with Vaadin 14.8.20 and 14.9.1 in a local project (with the ace add-on as a dependency) but I never get errors. Lit version in node_modules is 2.6.1, and in package.json I can see lit-element: 2.5.1 and lit-html: 1.4.1.

Could you please provide an example project that reproduces the problem?

Chris-SP365 commented 1 year ago

Seems to happen for me only in pnpm environments:

I also cleaned .pnpm-store directory and it also happens.

mcollovati commented 1 year ago

Thanks @INPUTsys-Chris, I confirm I can reproduce the issue but only using PNPM

mcollovati commented 1 year ago

Related issue on Ace Editor for Vaadin add-on: https://github.com/F0rce/ace/issues/39

fschoning commented 11 months ago

I am getting this same error with a project using Vaadin 23.2.25. I do not know what changed in my build to cause this error to materialise, but I recently downgraded from Vaadin Pro subscription to no subscription.

The following node versions are pulled in: "lit": "2.6.1", "lit-element": "^2.2.1", "lit-html": "^1.1.2",

As the original poster commented, is-server.js is not in lit-html v1.1.2.

As this Vite build is all a bit of a black box for me, how can I trace where the lit-html v1.1.2 is being pulled in?

Is there some kind of workaround for this error?

[ERROR] [vite]: Rollup failed to resolve import "lit-html/is-server.js" from "node_modules/lit/index.js". [ERROR] This is most likely unintended because it can break your application at runtime. [ERROR] If you do want to externalize this module explicitly add it to [ERROR] build.rollupOptions.external [ERROR] error during build: [ERROR] Error: [vite]: Rollup failed to resolve import "lit-html/is-server.js" from "node_modules/lit/index.js". [ERROR] This is most likely unintended because it can break your application at runtime. [ERROR] If you do want to externalize this module explicitly add it to [ERROR] build.rollupOptions.external [ERROR] at onRollupWarning (file:///G:/proj/example/app/node_modules/.pnpm/vite@3.2.7/node_modules/vite/dist/node/chunks/dep-2faf2534.js:45909:19) [ERROR] at onwarn (file:///G:/proj/example/app/node_modules/.pnpm/vite@3.2.7/node_modules/vite/dist/node/chunks/dep-2faf2534.js:45680:13) [ERROR] at Object.onwarn (file:///G:/proj/example/app/node_modules/.pnpm/rollup@2.79.1/node_modules/rollup/dist/es/shared/rollup.js:23263:13) [ERROR] at ModuleLoader.handleResolveId (file:///G:/proj/example/app/node_modules/.pnpm/rollup@2.79.1/node_modules/rollup/dist/es/shared/rollup.js:22158:26) [ERROR] at file:///G:/proj/example/app/node_modules/.pnpm/rollup@2.79.1/node_modules/rollup/dist/es/shared/rollup.js:22119:26

mcollovati commented 11 months ago

Did you already try a mvn vaadin:clean-frontend?

fschoning commented 11 months ago

Yes. No success.

On Thu, Oct 5, 2023, 11:58 Marco Collovati @.***> wrote:

Did you already try a mvn vaadin:clean-frontend?

— Reply to this email directly, view it on GitHub https://github.com/vaadin/flow/issues/15007#issuecomment-1748523810, or unsubscribe https://github.com/notifications/unsubscribe-auth/AVCVNIDK45NLWKP4ILTN6BLX52AF5AVCNFSM6AAAAAARXZSUT6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONBYGUZDGOBRGA . You are receiving this because you commented.Message ID: @.***>

mcollovati commented 11 months ago

@fschoning do you use add-ons in your projects? If so, can you provide a list?

mcollovati commented 11 months ago

@fschoning just to confirm, the Vaadin version you are using 23.3.25, not the 23.2.25 reported in your comment?

fschoning commented 11 months ago

Yes, apologies it is 23.3.25.

Yes I use a lot of add ons - see below. However none of these have changed versions since before the problem occurred with the exception of the Quill Editor. I will try and remove it and rebuild.

Switching back to vaadin versions as far back as 23.3.19 does not fix the problem.

Is there some way to trace where the node module dependency is pulled in?

    <dependency>
        <groupId>com.coachautomator</groupId>
        <artifactId>vaadincomponents</artifactId>
        <version>1.0-SNAPSHOT</version>
    </dependency>

    <dependency>
        <groupId>in.virit</groupId>
        <artifactId>viritin</artifactId>
        <version>${viritin.version}</version>
    </dependency>

    <dependency>
        <groupId>org.vaadin.olli</groupId>
        <artifactId>file-download-wrapper</artifactId>
        <version>6.0.0</version> <!-- for vaadin 23 -->
        <!--version>7.0.0</version> for vaadin 24 -->
    </dependency>

    <dependency>
        <groupId>org.vaadin.stefan</groupId>
        <artifactId>lazy-download-button</artifactId>
        <version>1.0.0</version>
    </dependency>

    <dependency>
        <groupId>pl.unforgiven</groupId>
        <artifactId>superfields</artifactId>
        <version>0.17.0</version>
    </dependency>

This is a modified version of the add on to support quill delta format files that I created.

com.schoning quill-editor 1.0.2
   <dependency>
        <groupId>org.parttio</groupId>
        <artifactId>line-awesome</artifactId>
        <version>1.1.0</version>
    </dependency>

    <dependency>
        <groupId>org.vaddon</groupId>
        <artifactId>mediaquery</artifactId>
        <version>5.0.3</version>
    </dependency>

    <dependency>
        <groupId>org.vaadin.olli</groupId>
        <artifactId>clipboardhelper</artifactId>
        <version>1.2.0</version>
    </dependency>

    <dependency>
        <groupId>org.vaadin.stefan</groupId>
        <artifactId>fullcalendar2</artifactId>
        <!--version>2.3.2</version-->
        <!--version>3.1.0</version-->
        <version>4.1.6</version>
    </dependency>

    <dependency>
        <groupId>com.github.appreciated</groupId>
        <artifactId>vaadin-css-grid</artifactId>
        <version>2.0.0</version>
    </dependency>

    <dependency>
        <groupId>ch.carnet.kasparscherrer</groupId>
        <artifactId>scrolllayout</artifactId>
        <version>2.0.2</version>
    </dependency>

    <dependency>
        <groupId>com.flowingcode.addons</groupId>
        <artifactId>font-awesome-iron-iconset</artifactId>
        <version>2.2.0</version>
    </dependency>

    <dependency>
        <groupId>com.vaadin.componentfactory</groupId>
        <artifactId>togglebutton</artifactId>
        <version>1.0.1</version>
    </dependency>

    <dependency>
        <groupId>org.vaadin.addons.componentfactory</groupId>
        <artifactId>vcf-gridlayout</artifactId>
        <version>1.0.1</version>
    </dependency>

    <dependency>
        <groupId>dev.mett.vaadin</groupId>
        <artifactId>tooltip</artifactId>
        <version>2.3.0</version>
    </dependency>

    <dependency>
        <groupId>com.github.appreciated</groupId>
        <artifactId>vaadin-css-grid</artifactId>
        <version>2.0.0</version>
    </dependency>

Kind regards, Franz Schöning

On Thu, Oct 5, 2023 at 1:03 PM Marco Collovati @.***> wrote:

@fschoning https://github.com/fschoning just to confirm, the Vaadin version you are using 23.3.25, not 23.2.25 as in your comment?

— Reply to this email directly, view it on GitHub https://github.com/vaadin/flow/issues/15007#issuecomment-1748664785, or unsubscribe https://github.com/notifications/unsubscribe-auth/AVCVNICWUIP2GQNUZGY7SKLX52HZFAVCNFSM6AAAAAARXZSUT6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONBYGY3DINZYGU . You are receiving this because you were mentioned.Message ID: @.***>

mcollovati commented 11 months ago

I think at least dev.mett.vaadin:tooltip should be upgraded to 3.1.0

mcollovati commented 11 months ago

Also, com.github.appreciated:vaadin-css-grid seems to target to Vaadin 14, so it could be one of the causes

fschoning commented 11 months ago

Hi Marco,

Thanks for checking. I isolated the error to the quill editor component that I forked from the add on directory. If I mock the editor then the build succeeds.

The code for the editor is at https://github.com/fschoning/quill-editor

Is there something I am doing wrong in this fork?

Kind regards, Franz Schöning

On Thu, Oct 5, 2023 at 2:08 PM Marco Collovati @.***> wrote:

Also, com.github.appreciated:vaadin-css-grid seems to target to Vaadin 14, so it could be one of the causes

— Reply to this email directly, view it on GitHub https://github.com/vaadin/flow/issues/15007#issuecomment-1748754068, or unsubscribe https://github.com/notifications/unsubscribe-auth/AVCVNIE4XDBYPF3PFTBSWULX52PKFAVCNFSM6AAAAAARXZSUT6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONBYG42TIMBWHA . You are receiving this because you were mentioned.Message ID: @.***>

mcollovati commented 11 months ago

You should probably update the @NpmPackage annotations for lit-element and lit-html in QuillEditorComponent, as it has been done in this fork https://github.com/Klaudeta/quill-editor/compare/master...ulrich-grossmann:quill-editor:master

fschoning commented 11 months ago

Brilliant :-) You nailed it Marco. Build is fine now.

Thank you!

On Thu, Oct 5, 2023 at 4:04 PM Marco Collovati @.***> wrote:

You should probably update the @NpmPackage annotations for lit-element and lit-html in QuillEditorComponent, as it has been done in this fork Klaudeta/quill-editor@ master...ulrich-grossmann:quill-editor:master https://github.com/Klaudeta/quill-editor/compare/master...ulrich-grossmann:quill-editor:master

— Reply to this email directly, view it on GitHub https://github.com/vaadin/flow/issues/15007#issuecomment-1748968328, or unsubscribe https://github.com/notifications/unsubscribe-auth/AVCVNIBWDB6GVQYSGU3JB3DX5245HAVCNFSM6AAAAAARXZSUT6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONBYHE3DQMZSHA . You are receiving this because you were mentioned.Message ID: @.***>

mcollovati commented 11 months ago

I wonder if we can close this ticket, since the issue is on the add-on. @mshabarov what do you think? Do you see any action we can take on the Flow side?

Chris-SP365 commented 11 months ago

we moved on from pnpm to npm, so it's definitely not a problem for us anymore

mshabarov commented 10 months ago

Closed, as nothing to fix on the Flow side.