Skip to content

Commit

Permalink
remove the default behavior of env replacement on node env (#622)
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi authored Dec 31, 2024
1 parent 4229609 commit d6fcc5d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
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

0 comments on commit d6fcc5d

Please sign in to comment.