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

Svelte 5: getContext is undefined. #12710

Closed
HighFunctioningSociopathSH opened this issue Aug 2, 2024 · 1 comment
Closed

Svelte 5: getContext is undefined. #12710

HighFunctioningSociopathSH opened this issue Aug 2, 2024 · 1 comment

Comments

@HighFunctioningSociopathSH

Describe the bug

Since the last update (svelte@5.0.0-next.206), svelte throws an error saying getContext is undefined if getContext was called in a svelte.ts file. works fine in next.205

Reproduction

test.svelte.ts

import { getContext } from "svelte";

export function fetchContext() {
  const test = getContext("something");

  return test;
}

Child.svelte

<script lang="ts">
  import { fetchContext } from "./test.svelte";

  const result = fetchContext();
</script>

Logs

client.js?v=731e5348:299 Uncaught (in promise) 
ReferenceError: getContext is not defined
    at fetchContext (test.svelte.ts:4:16)
    at Child (Child.svelte:4:18)
    at chunk-KRQXFADS.js?v=731e5348:209:58
    at update_reaction (chunk-IUDHG5ZN.js?v=731e5348:1093:23)
    at update_effect (chunk-IUDHG5ZN.js?v=731e5348:1213:21)
    at create_effect (chunk-IUDHG5ZN.js?v=731e5348:274:7)
    at branch (chunk-IUDHG5ZN.js?v=731e5348:398:10)
    at chunk-KRQXFADS.js?v=731e5348:202:17
    at update_reaction (chunk-IUDHG5ZN.js?v=731e5348:1093:23)
    at :5174/update_effect …text is not defined
    at fetchContext (test.svelte.ts:4:16)
    at Child (Child.svelte:4:18)
    at chunk-KRQXFADS.js?v=731e5348:209:58
    at update_reaction (chunk-IUDHG5ZN.js?v=731e5348:1093:23)
    at update_effect (chunk-IUDHG5ZN.js?v=731e5348:1213:21)
    at create_effect (chunk-IUDHG5ZN.js?v=731e5348:274:7)
    at branch (chunk-IUDHG5ZN.js?v=731e5348:398:10)
    at chunk-KRQXFADS.js?v=731e5348:202:17
    at update_reaction (chunk-IUDHG5ZN.js?v=731e5348:1093:23)
    at update_effect (chunk-IUDHG5ZN.js?v=731e5348:1213:21)

System Info

System:
    OS: Windows 11 10.0.22631
    CPU: (16) x64 12th Gen Intel(R) Core(TM) i7-12650H
    Memory: 4.54 GB / 15.63 GB
  Binaries:
    Node: 20.12.2 - C:\Program Files\nodejs\node.EXE
    npm: 10.8.2 - C:\Program Files\nodejs\npm.CMD
    bun: 1.1.3 - ~\.bun\bin\bun.EXE
  Browsers:
    Edge: Chromium (126.0.2592.102)
    Internet Explorer: 11.0.22621.3527

Severity

blocking an upgrade

@brunnerh
Copy link
Member

brunnerh commented Aug 2, 2024

@Conduitry Conduitry closed this as not planned Won't fix, can't repro, duplicate, stale Aug 2, 2024
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

No branches or pull requests

3 participants