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

Magic-string version causes errors with Threlte (svelte lib) #5555

Closed
1 task done
jerzakm opened this issue Dec 8, 2022 · 1 comment · Fixed by #5577
Closed
1 task done

Magic-string version causes errors with Threlte (svelte lib) #5555

jerzakm opened this issue Dec 8, 2022 · 1 comment · Fixed by #5577
Labels
- P2: nice to have Not breaking anything but nice to have (priority) ecosystem: external External library doesn't work

Comments

@jerzakm
Copy link
Contributor

jerzakm commented Dec 8, 2022

What version of astro are you using?

^1.6.13

Are you using an SSR adapter? If so, which one?

no

What package manager are you using?

npm, pnpm

What operating system are you using?

Windows, Linux

Describe the Bug

I was trying to implement a Threlte component. It's a Svelte library for Three.js and it uses it's own pre-processor. (https://threlte.xyz/getting-started#installation)

I am getting this error:

  File:
    C:/Users/Firma/Documents/Github/astro-threlte-issue/src/components/App.svelte
  Stacktrace:
TypeError: Error while preprocessing C:/Users/Firma/Documents/Github/astro-threlte-issue/src/components/App.svelte - markup.update is not a function
    at Object.enter (file:///C:/Users/Firma/Documents/Github/astro-threlte-issue/node_modules/@threlte/preprocess/dist/index.js:121:32)

This is a repo to reproduce the error. Stackblitz example doesn't build either but I don't see full error message (could be just me not knowing where it outputs :P )
https://github.com/jerzakm/astro-threlte-issue

Why it's broken
It is happening because magicstring.update was released in 26.6 and astro uses "magic-string": "^0.25.9"
Rich-Harris/magic-string@7b45b9b

Quick fix
Simply installing magic-string inside the project as dev dependency fixes the issue
npm i -D magic-string

Permanent fix proposal
Update astro's magic-string. I am not familiar with astro internals so I'm not sure if this would cause any major problems. I'm willing to make a PR with it.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-wmsgt4?file=src/pages/index.astro

Participation

  • I am willing to submit a pull request for this issue.
@matthewp
Copy link
Contributor

matthewp commented Dec 8, 2022

@jerzakm a PR would be very welcome here!

@matthewp matthewp added - P2: nice to have Not breaking anything but nice to have (priority) ecosystem: external External library doesn't work labels Dec 8, 2022
@bluwy bluwy linked a pull request Dec 10, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P2: nice to have Not breaking anything but nice to have (priority) ecosystem: external External library doesn't work
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants