git commit message with reserved word cannot build in GitLab CI #6102
Labels
blocked by upstream
bug
Something isn't working
$env
Bugs related to the `$env` family of modules
p3-edge-case
SvelteKit cannot be used in an uncommon way
Milestone
Describe the bug
OK here's a weirdo one. I build my project using
yarn build
(vite build
) in GitLab CI, then rsync the compiled bundle/code to my server that's running a simple node server (i.e. I'm using adapter-node), and then GitLab CI then restarts the service on the remote.I am actually writing this because I've updated Kit to the very latest today, and I had to re-work how I was using environment variables (I shifted from import.meta.env to $env/static/public and $env/static/private).
My commit message was then something like "refactor to remove import.meta.env" -- but GitLab puts certain environment variables in the build environment, such as CI_COMMIT_TITLE. Kit then tries to pull them all in to the static build, but as it contains the word "import," it is rejected, and my build soft fails.
I think that this is happening in kit/src/core/env.js (that's where I found references to this being a reserved word).
Looking up at utils.js/get_env, it doesn't seem there's a way to ignore/exclude certain variables from the build. (This would work for me as all GitLab's variables start with
CI_
and I could filter those out.)After I did another commit message without a reserved word, all was fine with the build.
Using
Reproduction
https://stackblitz.com/edit/sveltejs-kit-template-default-gvupwf?file=src/routes/+page.svelte
Once in the stackblitz, stop the development server and issue:
CI_COMMIT_TITLE="do not use import.meta.env" npm run build
And the error happens.
Logs
System Info
Severity
annoyance
Additional Information
I think the proper thing would be to write in a way to exclude certain variables or a certain RegEx of variables as "do not build these into env/static"
I think this would happen maybe in get_env:
...with perhaps an additional entries.filter??
The text was updated successfully, but these errors were encountered: