Skip to content

$env/static/private can be imported in client modules #5723

@aloker

Description

@aloker

Describe the bug

If I understood correctly, mechanisms should be in place that prevent $env/static/private to be imported in client modules (like routes). However, this does not seem to be the case. I can import from $env/static/private and the variables get transpiled into the client side javascript modules.

My excuses if this feature is not yet supposed to work.

Reproduction

A simple repo showing the issue:
https://github.com/aloker/sveltekit-private-env

https://github.com/aloker/sveltekit-private-env/blob/main/src/routes/index.svelte

Logs

No response

System Info

System:
    OS: Windows 10 10.0.19043
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz   
    Memory: 8.81 GB / 31.81 GB
  Binaries:
    Node: 16.15.1 - c:\tools\node\node.EXE
    Yarn: 1.22.19 - c:\tools\node\yarn.CMD
    npm: 8.13.2 - c:\tools\node\npm.CMD
  Browsers:
    Edge: Spartan (44.19041.1266.0), Chromium (103.0.1264.71)
    Internet Explorer: 11.0.19041.1566
  npmPackages:
    @sveltejs/adapter-auto: next => 1.0.0-next.64 
    @sveltejs/kit: next => 1.0.0-next.396 
    svelte: ^3.44.0 => 3.49.0 
    vite: ^3.0.0 => 3.0.3

Severity

serious, but I can work around it

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions