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

feat: Svelte renderer #12

Merged
merged 4 commits into from
May 5, 2024
Merged

feat: Svelte renderer #12

merged 4 commits into from
May 5, 2024

Conversation

mattcroat
Copy link
Contributor

@mattcroat mattcroat commented Apr 18, 2024

Here's my Svelte renderer contribution. πŸ™

The only thing I need help with is solving a cryptic error when trying to run npm build about importing files that aren't JavaScript β€” which probably has to do with importing .svelte files, but I don't know how to pass it a plugin to compile the Svelte components with Rollup.

Everything else works! πŸ˜„

svelte-renderer.mp4

@mattcroat
Copy link
Contributor Author

@antfu can you please have a look when you have time? πŸ˜„

@timscodebase
Copy link

I support this addition. Svelte is becoming a major player.

@antfu
Copy link
Member

antfu commented May 5, 2024

I will ship .svelte file directly to npm. Hope that would work.

@antfu antfu merged commit 587e5bb into shikijs:main May 5, 2024
8 checks passed
@mattcroat mattcroat deleted the svelte-renderer branch May 6, 2024 07:58
@mattcroat
Copy link
Contributor Author

mattcroat commented May 6, 2024

@antfu The imports inside the Svelte component can't be resolved after the build, and require the file extension to be included at the end:

-import { codeToKeyedTokens, createMagicMoveMachine } from '../core'
-import type { MagicMoveRenderOptions, MagicMoveDifferOptions } from '../types'
+import { codeToKeyedTokens, createMagicMoveMachine } from '../core.mjs'
+import type { MagicMoveRenderOptions, MagicMoveDifferOptions } from '../types.d.ts'

This fixes the problem but I'm not sure if that's the best solution because it only works for the build β€” TypeScript also complains about the ShikiMagicMove import:

<script lang="ts">
  import { ShikiMagicMove } from 'shiki-magic-move/svelte'
</script>
Module '"shiki-magic-move/svelte"' has no
exported member 'ShikiMagicMove'.ts(2305)

What do you propose?

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 this pull request may close these issues.

3 participants