Skip to content

[Bug]: PROCESS.ENV.ASSET_PREFIX is replaced with "auto"  #774

@giancarlosisasi

Description

@giancarlosisasi

Version

System:
    OS: macOS 15.0.1
    CPU: (8) arm64 Apple M1
    Memory: 79.30 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Browsers:
    Brave Browser: 132.1.74.50
    Chrome: 133.0.6943.99
    Safari: 18.0.1

Details

In my library, we sanitize and export a set of env variables that can be used in our web apps:

export const squared = (n: number): number => n * n;

export const envVars = {
  ASSET_PREFIX: process.env.ASSET_PREFIX,
}

But when compiling it with rslib, the process.env.ASSET_PREFIX is replaces with the "auto" value 🤔

Code after compilation:

const squared = (n)=>n * n;
const envVars = {
    ASSET_PREFIX: "auto"
};
export { envVars, squared };

I have not configured anything about that in my rslib.config.ts file so I would expect to have this without a value and instead keep the original code like:

// compiled code
const squared = (n)=>n * n;
const envVars = {
    ASSET_PREFIX: process.env.ASSET_PREFIX_, // <-- this should keep as the original code
};
export { envVars, squared };

Reproduce link

https://github.com/giancarlosisasi/rslib-bug-env-var

Reproduce Steps

  1. git clone https://github.com/giancarlosisasi/rslib-bug-env-var
  2. pnpm install && pnpm build
  3. Check the file dist/index.js, there you can see the "auto" value in the envVars.ASSET_PREFIX even when that variable was not configured in the rslib.config.ts

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions