sveltejs / sveltejs/kit

Set environment variable when running `svelte-kit package`

Open
#3,215 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

pkg:svelte-package
Dominant language
JavaScript
Stars
20.8k
Forks
2.3k
Avg merge
1d 16h
Merged PRs (30d)
156

Description

Describe the problem

When writing a preprocessor, I've found it desirable to do different things (e.g warning vs error, optimize vs deoptimize etc.) based on the mode (e.g prod, dev etc.) that is running. Svelte-kit sets NODE_ENV to "development" and "production" for the dev and build modes respectively. It would be helpful if Svelte-kit does the same for svelte-kit package to allow different tools to behave accordingly.

Describe the proposed solution

Before starting packaging simply set the process NODE_ENV to "packaging".

Alternatives considered

Require that consumers of your preprocessor/build-tool MUST set the env variable to get correct behavior during packaging:

NODE_ENV=packaging npx svelte-kit package

This is less convenient especially given that Svelte-kit "knows" that it's running in packaging mode.

Importance

nice to have

Additional Information

NODE_ENV is currently undefined during packaging.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Locate the entry point for the svelte-kit package command and trace where packaging begins. Set NODE_ENV to packaging before that work starts, then verify that the environment variable is available during packaging without changing the existing dev or build behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
build-system
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.