bfanger / svelte-preprocess-react

Seamlessly use React components inside a Svelte app
MIT License
119 stars 6 forks source link

Still having compile errors on Svelte 5 #39

Closed jangxyz closed 2 months ago

jangxyz commented 2 months ago

Even after #34, I am seeing compile errors:

[vite] Internal server error: Failed to resolve import "./" from "src-svelte/App.svelte". Does the file exist?
  Plugin: vite:import-analysis
  File: /.../src-svelte/App.svelte:1:0
  9  |
  10 |  import * as $ from "svelte/internal/client";
  11 |  import { sveltify as React$$sveltify } from "./";
     |                                               ^
  12 |  import React$$ReactDOM from "react-dom/client";
  13 |  import { createPortal as React$$createPortal } from "react-dom";

This is svelte@5.0.0-next.164, with svelte-preprocess-react@2.0.0-beta.3

I know Svelte 5 is not officially released yet, and RC is what we've got. I was curious whether this a known issue, and you are planning to work on it after there is an official release.

Or... perhaps I have missed something? It did work before I upgraded to Svelte 5 (was using 0.17.0).

bfanger commented 2 months ago

The 0.17.0 only works with Svelte 4.

Try the unreleased the svelte5 branch ( 2.0.0-beta.3 ) it works pretty good in my tests.

bfanger commented 2 months ago

Strange, when building the package the preprocessReact.js was modified from:

  const imports = [
    `import { sveltify as ${prefix}sveltify } from "svelte-preprocess-react";`,
  ];

into:

const imports = [
    `import { sveltify as ${prefix}sveltify } from "./";`,
  ];

Fixed in 2.0.0-beta-5

jangxyz commented 2 months ago

Nice! I'm glad it was not something to do with svelte5 internals. Confirmed working in my code too 👍 👍