Unexpected token error in REPL but not locally
Describe the bug
svelte-multiselect stopped working in the REPL in v5.0.0. The previous v4.0.6 release is working fine.
The error message v5 raises is: Unexpected token (Note that you need plugins to import files that are not JavaScript)
Sadly the REPL gives no stack traces. I've been looking through the changes I introduced between these 2 releases but nothing jumps out. v5 works fine when used locally too. I was also looking through the REPL compiler's JS output but couldn't spot any issues. Any debugging advice would be great.
Reproduction
v:4.0.6 (working): https://svelte.dev/repl/4279890dae0942caa860e74f2e7a8a6f?version=3.48.0 v5.0.0 (broken): https://svelte.dev/repl/ea202bd627134d898802a11cfaf8ff0e?version=3.48.0
Logs
No response
System Info
REPL
Severity
annoyance
Error originally reported in https://github.com/janosh/svelte-multiselect/issues/80.
I think this is because of this change.
https://github.com/janosh/svelte-multiselect/pull/75/files#diff-7d86c55b55f23806b2be4051d790e7c775fd5fa4e1ad3fc2da59eb51ce25c0e9R3
(Important point is thattype has been removed)
I took diff between 4.0.6 and 5.0.0. (Left side is 4.0.6, the right side is 5.0.0)
And due to import './';, REPL fetches data from https://unpkg.com/browse/[email protected]/ but it returns HTML and REPL throw parse error because it expects JavaScript.
Transferring this to the sites repo, as this is apparently an issue in how the REPL resolves imports, not in Svelte itself.
@baseballyama I thought that strange remnant from the type import might be the issue too at first but later v5 releases of svelte-multiselect don't have that any more. The generated package/MultiSelect.svelte looks like this now but the REPL import still fails.
<script>import { createEventDispatcher } from 'svelte';
import { get_label, get_value } from './';
import CircleSpinner from './CircleSpinner.svelte';
// ...
Same here:
https://svelte.dev/repl/0a87b0b710ab473fb7368dc260160ae6?version=3.50.1
It works fine outside of the REPL.
Just noticed that version 7.0.2 of svelte-multiselect now successfully runs in the Svelte REPL.
@gyurielf Apparently the fix was to remove a circular import between src/lib/{index.ts<->MultiSelect.svelte}. See https://github.com/janosh/svelte-multiselect/issues/121#issuecomment-1272396986.
@Conduitry Maybe this also helps point at how to make the REPL more robust?