sveltejs / svelte

Cybernetically enhanced web apps
https://svelte.dev
MIT License
78.21k stars 4.09k forks source link

SVELTE 5 - No matching export in in filea for import b #9925

Closed niemyjski closed 9 months ago

niemyjski commented 9 months ago

Describe the bug

Once I upgraded to svelte 5 preview I became unable to compile and run my website due to compile errors. They all seem to stem from the same issue and it's blocking adoptions.

X [ERROR] No matching export in "node_modules/svelte/src/internal/index.js" for import "listen"

    node_modules/svelte-legos/dist/utilities/screenOrientation/index.js:3:9:
      3 │ import { listen } from "svelte/internal";
        ╵          ~~~~~~

7:06:06 AM [vite] error while updating dependencies:
Error: Build failed with 25 errors:
node_modules/svelte-legos/dist/actions/alertAction/Alert.js:1:18: ERROR: No matching export in "node_modules/svelte/src/internal/index.js" for import "append"
node_modules/svelte-legos/dist/actions/clickOutsideAction/index.js:1:9: ERROR: No matching export in "node_modules/svelte/src/internal/index.js" for import "listen"
node_modules/svelte-legos/dist/actions/clickToCopyAction/Clipboard.js:1:9: ERROR: No matching export in "node_modules/svelte/src/internal/index.js" for import "append"
node_modules/svelte-legos/dist/actions/infiniteScrollAction/index.js:1:9: ERROR: No matching export in "node_modules/svelte/src/internal/index.js" for import "listen"
node_modules/svelte-legos/dist/actions/loadingAction/Loader.js:1:9: ERROR: No matching export in "node_modules/svelte/src/internal/index.js" for import "append"
...
    at failureErrorWithLog (D:\ClientApp\node_modules\esbuild\lib\main.js:1650:15)
    at D:\ClientApp\node_modules\esbuild\lib\main.js:1058:25
    at D:\ClientApp\node_modules\esbuild\lib\main.js:1526:9
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

https://github.com/TanStack/table/issues/5213
https://github.com/ankurrsinghal/svelte-legos/issues/115

### Reproduction

clone and build https://github.com/exceptionless/Exceptionless/tree/feature/svelte-5-runes/src/Exceptionless.Web/ClientApp

### Logs

```shell
VITE v5.0.9  ready in 866 ms

  ➜  Local:   http://localhost:5173/next
  ➜  Network: use --host to expose
  ➜  press h + enter to show help
X [ERROR] No matching export in "node_modules/svelte/src/internal/index.js" for import "SvelteComponent"

    node_modules/@tanstack/svelte-table/build/lib/index.mjs:13:9:
      13 │ import { SvelteComponent, init, safe_not_equal, text, claim_text, insert_hydration, set_data, noop, detach, create_ssr_component, escape, validate_component, create_component, claim_com...
         ╵          ~~~~~~~~~~~~~~~

X [ERROR] No matching export in "node_modules/svelte/src/internal/index.js" for import "init"

    node_modules/@tanstack/svelte-table/build/lib/index.mjs:13:26:
      13 │ import { SvelteComponent, init, safe_not_equal, text, claim_text, insert_hydration, set_data, noop, detach, create_ssr_component, escape, validate_component, create_component, claim_com...
         ╵                           ~~~~

X [ERROR] No matching export in "node_modules/svelte/src/internal/index.js" for import "safe_not_equal"

    node_modules/@tanstack/svelte-table/build/lib/index.mjs:13:32:
      13 │ import { SvelteComponent, init, safe_not_equal, text, claim_text, insert_hydration, set_data, noop, detach, create_ssr_component, escape, validate_component, create_component, claim_com...
         ╵                                 ~~~~~~~~~~~~~~

X [ERROR] No matching export in "node_modules/svelte/src/internal/index.js" for import "claim_text"

    node_modules/@tanstack/svelte-table/build/lib/index.mjs:13:54:
      13 │ import { SvelteComponent, init, safe_not_equal, text, claim_text, insert_hydration, set_data, noop, detach, create_ssr_component, escape, validate_component, create_component, claim_com...
         ╵                                                       ~~~~~~~~~~

X [ERROR] No matching export in "node_modules/svelte/src/internal/index.js" for import "insert_hydration"

    node_modules/@tanstack/svelte-table/build/lib/index.mjs:13:66:
      13 │ import { SvelteComponent, init, safe_not_equal, text, claim_text, insert_hydration, set_data, noop, detach, create_ssr_component, escape, validate_component, create_component, claim_com...
         ╵                                                                   ~~~~~~~~~~~~~~~~

X [ERROR] No matching export in "node_modules/svelte/src/internal/index.js" for import "set_data"

    node_modules/@tanstack/svelte-table/build/lib/index.mjs:13:84:
      13 │ import { SvelteComponent, init, safe_not_equal, text, claim_text, insert_hydration, set_data, noop, detach, create_ssr_component, escape, validate_component, create_component, claim_com...
         ╵                                                                                     ~~~~~~~~

X [ERROR] No matching export in "node_modules/svelte/src/internal/index.js" for import "noop"

    node_modules/@tanstack/svelte-table/build/lib/index.mjs:13:94:
      13 │ ...t { SvelteComponent, init, safe_not_equal, text, claim_text, insert_hydration, set_data, noop, detach, create_ssr_component, escape, validate_component, create_component, claim_compo...
         ╵                                                                                             ~~~~

X [ERROR] No matching export in "node_modules/svelte/src/internal/index.js" for import "detach"

    node_modules/@tanstack/svelte-table/build/lib/index.mjs:13:100:
      13 │ ...lteComponent, init, safe_not_equal, text, claim_text, insert_hydration, set_data, noop, detach, create_ssr_component, escape, validate_component, create_component, claim_component, m...
         ╵                                                                                            ~~~~~~

X [ERROR] No matching export in "node_modules/svelte/src/internal/index.js" for import "create_ssr_component"

    node_modules/@tanstack/svelte-table/build/lib/index.mjs:13:108:
      13 │ ...nit, safe_not_equal, text, claim_text, insert_hydration, set_data, noop, detach, create_ssr_component, escape, validate_component, create_component, claim_component, mount_component,...
         ╵                                                                                     ~~~~~~~~~~~~~~~~~~~~

X [ERROR] No matching export in "node_modules/svelte/src/internal/index.js" for import "escape"

    node_modules/@tanstack/svelte-table/build/lib/index.mjs:13:130:
      13 │ ...qual, text, claim_text, insert_hydration, set_data, noop, detach, create_ssr_component, escape, validate_component, create_component, claim_component, mount_component, transition_in,...
         ╵                                                                                            ~~~~~~

X [ERROR] No matching export in "node_modules/svelte/src/internal/index.js" for import "create_component"

    node_modules/@tanstack/svelte-table/build/lib/index.mjs:13:158:
      13 │ ...dration, set_data, noop, detach, create_ssr_component, escape, validate_component, create_component, claim_component, mount_component, transition_in, transition_out, destroy_componen...
         ╵                                                                                       ~~~~~~~~~~~~~~~~

X [ERROR] No matching export in "node_modules/svelte/src/internal/index.js" for import "claim_component"

    node_modules/@tanstack/svelte-table/build/lib/index.mjs:13:176:
      13 │ ..., noop, detach, create_ssr_component, escape, validate_component, create_component, claim_component, mount_component, transition_in, transition_out, destroy_component } from 'svelte/...
         ╵                                                                                        ~~~~~~~~~~~~~~~

X [ERROR] No matching export in "node_modules/svelte/src/internal/index.js" for import "mount_component"

    node_modules/@tanstack/svelte-table/build/lib/index.mjs:13:193:
      13 │ ... detach, create_ssr_component, escape, validate_component, create_component, claim_component, mount_component, transition_in, transition_out, destroy_component } from 'svelte/internal';
         ╵                                                                                                  ~~~~~~~~~~~~~~~

X [ERROR] No matching export in "node_modules/svelte/src/internal/index.js" for import "transition_in"

    node_modules/@tanstack/svelte-table/build/lib/index.mjs:13:210:
      13 │ ... detach, create_ssr_component, escape, validate_component, create_component, claim_component, mount_component, transition_in, transition_out, destroy_component } from 'svelte/internal';
         ╵                                                                                                                   ~~~~~~~~~~~~~

X [ERROR] No matching export in "node_modules/svelte/src/internal/index.js" for import "transition_out"

    node_modules/@tanstack/svelte-table/build/lib/index.mjs:13:225:
      13 │ ... detach, create_ssr_component, escape, validate_component, create_component, claim_component, mount_component, transition_in, transition_out, destroy_component } from 'svelte/internal';
         ╵                                                                                                                                  ~~~~~~~~~~~~~~

X [ERROR] No matching export in "node_modules/svelte/src/internal/index.js" for import "destroy_component"

    node_modules/@tanstack/svelte-table/build/lib/index.mjs:13:241:
      13 │ ... detach, create_ssr_component, escape, validate_component, create_component, claim_component, mount_component, transition_in, transition_out, destroy_component } from 'svelte/internal';
         ╵                                                                                                                                                  ~~~~~~~~~~~~~~~~~

7:32:47 AM [vite] error while updating dependencies:
Error: Build failed with 16 errors:
node_modules/@tanstack/svelte-table/build/lib/index.mjs:13:9: ERROR: No matching export in "node_modules/svelte/src/internal/index.js" for import "SvelteComponent"
node_modules/@tanstack/svelte-table/build/lib/index.mjs:13:26: ERROR: No matching export in "node_modules/svelte/src/internal/index.js" for import "init"
node_modules/@tanstack/svelte-table/build/lib/index.mjs:13:32: ERROR: No matching export in "node_modules/svelte/src/internal/index.js" for import "safe_not_equal"
node_modules/@tanstack/svelte-table/build/lib/index.mjs:13:54: ERROR: No matching export in "node_modules/svelte/src/internal/index.js" for import "claim_text"
node_modules/@tanstack/svelte-table/build/lib/index.mjs:13:66: ERROR: No matching export in "node_modules/svelte/src/internal/index.js" for import "insert_hydration"
...
    at failureErrorWithLog (D:\ClientApp\node_modules\esbuild\lib\main.js:1650:15)
    at D:\ClientApp\node_modules\esbuild\lib\main.js:1058:25
    at D:\ClientApp\node_modules\esbuild\lib\main.js:1526:9
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

### System Info

```shell
System:
    OS: Windows 11 10.0.22631
    CPU: (24) x64 AMD Ryzen 9 5900X 12-Core Processor
    Memory: 5.95 GB / 31.91 GB
  Binaries:
    Node: 21.4.0 - C:\Program Files\nodejs\node.EXE
    npm: 10.1.0 - ~\AppData\Roaming\npm\npm.CMD
    pnpm: 8.11.0 - ~\AppData\Roaming\npm\pnpm.CMD
  Browsers:
    Edge: Chromium (120.0.2210.61)
    Internet Explorer: 11.0.22621.1

Severity

blocking all usage of svelte

trueadm commented 9 months ago

Svelte 5 doesn't export a listen function from its internals anymore (it was something Svelte 4 internals exposed). This looks like an issue with svelte-legos as it's depending on an internal API that no longer exists.

niemyjski commented 9 months ago

@trueadm that might be the case but when you say svelte 5 has 100% backwards compatibility. It sure doesn't look like it, internal api or not, it was exported to a public api surface. A shim should be there with some warnings logs

dummdidumm commented 9 months ago

100% backwards compatible if you're using public API. Internal APIs are subject to change in every release. We can't shim the old runtime, it has completely changed how it works.

niemyjski commented 9 months ago

Seems like you could have at least left them in place and had empty functions / polyfills that throw what an alternative might be... Fact is they still were exported and public, people are using them these are two popular svelte libraries. who knows how many libraries are using them. Perhaps having a linter that errors would go a long way from having people use these.

I totally get it from your perspective. I'm a framework / library developer myself.

dummdidumm commented 9 months ago

The error already tells you that there is something wrong, I don't think having an empty function that errors would make this any easier. We could maybe look into shimming a few selected high-usage internals, depending on what is commonly used across frameworks, but that's about it - and even that makes me nervous because people could think "oh ok I'm going to keep using those internal methods" and that just postpones the time of breakage a bit.

niemyjski commented 9 months ago

Agreed, can we also call this out on the 5.0 breaking changes and alert text saying don't use imports from this package? I'm also kind of curious why these developers would have thought it ok to take on internal package references, are these behaviors not exposed via public apis?

dominikg commented 9 months ago

appearantly a lot of people do. https://github.com/search?q=svelte%2Finternal&type=code but i'm not sure how to get more explicit than naming it svelte/internal.

Maybe we can look into import maps with # refs so that svelte5 internals are truly opaque?

We do communicate that svelte5 is a complete rewrite, so there's no mistake or implication that anything internal will stay the same. Adding it to the list of breaking changes would be redundant.

niemyjski commented 9 months ago

redundant yes, but communication is always a good thing :)

niemyjski commented 9 months ago

I'd also ask why so many people are using the internal api, what is the public api possibly missing?