Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove the default behavior of env replacement on node env #622

Merged
merged 1 commit into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ This convention keeps shared modules private while enabling efficient bundling a
- External (`--external <dep,>`): Specifying extra external dependencies, by default it is the list of `dependencies` and `peerDependencies` from `package.json`. Values are separate by comma.
- Target (`--target <target>`): Set ECMAScript target (default: `'es2015'`).
- Runtime (`--runtime <runtime>`): Set build runtime (default: `'browser'`).
- Environment (`--env <env,>`): Define environment variables. (default: `NODE_ENV`, separate by comma)
- Environment (`--env <env,>`): Define environment variables. (default: `[]`, separate by comma)
- Working Directory (`--cwd <cwd>`): Set current working directory where containing `package.json`.
- Minify (`-m`): Compress output.
- Watch (`-w`): Watch for source file changes.
Expand Down
3 changes: 0 additions & 3 deletions src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ export function getDefinedInlineVariables(
envs: string[],
parsedExportCondition: ParsedExportCondition,
): Record<string, string> {
if (!envs.includes('NODE_ENV')) {
envs.push('NODE_ENV')
}
const envVars = envs.reduce((acc: Record<string, string>, key) => {
const value = process.env[key]
if (typeof value !== 'undefined') {
Expand Down
6 changes: 3 additions & 3 deletions test/integration/dev-prod-convention/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ describe('integration dev-prod-convention', () => {
'index.development.mjs': /= "development"/,
'index.production.js': /= "production"/,
'index.production.mjs': /= "production"/,
// In jest the NODE_ENV is set to test
'index.js': /= "test"/,
'index.mjs': /= "test"/,
// Do not replace NODE_ENV by default
'index.js': /= process.env.NODE_ENV/,
'index.mjs': /= process.env.NODE_ENV/,
})
},
)
Expand Down
Loading