kit: `config.kit.env.publicModule` option does not exist

Describe the bug

In the SvelteKit docs for migrating to v2, it says that there is an option called config.kit.env.publicModule. (https://svelte.dev/docs/kit/migrating-to-sveltekit-2#Dynamic-environment-variables-cannot-be-used-during-prerendering) I wasn’t migrating, but this was the option I needed. But checking the configuration options in the docs and in the code, this option does not actually exist. I noticed this when I was using @sveltejs/adapter-cloudflare, where the default value ["<all>"] of routes.exclude causes this error: Uncaught (in promise) TypeError: error loading dynamically imported module: https://5de21f49.begad.pages.dev/_app/env.js I tried using the publicModule option but it did not exist.

Reproduction

Clone https://github.com/Begad666/sveltekit-issue Run bun install Run bun run dev

Logs

error during build:
Could not load svelte.config.js: Unexpected option config.kit.env.publicModule

System Info

System:
    OS: Windows 11 10.0.26100
    CPU: (12) x64 AMD Ryzen 5 3600 6-Core Processor
    Memory: 4.65 GB / 15.92 GB
Binaries:
    Node: 21.5.0 - ~\AppData\Local\Volta\tools\image\node\21.5.0\node.EXE
    Yarn: 4.2.2 - ~\AppData\Local\Volta\tools\image\yarn\4.6.0\bin\yarn.CMD
    npm: 10.2.4 - ~\AppData\Local\Volta\tools\image\node\21.5.0\npm.CMD
    bun: 1.1.45 - ~\AppData\Local\Volta\bin\bun.EXE
Browsers:
    Edge: Chromium (130.0.2849.80)
npmPackages:
    @sveltejs/adapter-auto: ^3.0.0 => 3.3.1
    @sveltejs/adapter-cloudflare: ^4.4.0 => 4.9.0
    @sveltejs/kit: ^2.0.0 => 2.16.1
    @sveltejs/vite-plugin-svelte: ^3.0.0 => 3.1.2
    svelte: ^4.2.7 => 4.2.19
    vite: ^5.0.3 => 5.4.14

Severity

annoyance

Additional Information

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (15 by maintainers)

Commits related to this issue

Most upvoted comments

Do you mind if I create a PR? I checked the codebase and it seems easy to add.

I’m not sure if there’s any reason for us to expose a publicModule option – it seems like the actual issue in this PR is that we need to add _app/env.js (and any future dynamic content) to the cloudflare adapter’s routes.include?

Oh, shoot, yeah, I misunderstood your issue – let me see if this is an oversight on the docs or if it’s API we meant to add but didn’t actually.