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

define should not modify string #13362

Closed
7 tasks done
eightHundreds opened this issue May 29, 2023 · 2 comments
Closed
7 tasks done

define should not modify string #13362

eightHundreds opened this issue May 29, 2023 · 2 comments
Labels
duplicate This issue or pull request already exists pending triage

Comments

@eightHundreds
Copy link

Describe the bug

The define configuration modifies the content of the string in the code

Reproduction

https://github.com/eightHundreds/vite-define-bug-demo

Steps to reproduce

// src/index.ts
const a = {
    'content/vite.config.ts': {
        type: 'Txt',
        data: "'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)",
    },
};
console.log(a)
// vite.config.ts
import { defineConfig } from 'vite'

export default defineConfig({
    define: {
        'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
    },
})

Expected result: change nothing
Actual result:
image

System Info

System:
    OS: Linux 5.4 Ubuntu 20.04.6 LTS (Focal Fossa)
    CPU: (2) x64 Intel(R) Xeon(R) Platinum 8272CL CPU @ 2.60GHz
    Memory: 1.89 GB / 3.84 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 19.9.0 - ~/nvm/current/bin/node
    Yarn: 1.22.19 - /usr/bin/yarn
    npm: 9.6.3 - ~/nvm/current/bin/npm
  npmPackages:
    vite: ^4.3.9 => 4.3.9

Used Package Manager

pnpm

Logs

No response

Validations

@eightHundreds
Copy link
Author

I tried esbuild, it works fine

@sapphi-red
Copy link
Member

Duplicate of #3304

@sapphi-red sapphi-red marked this as a duplicate of #3304 May 29, 2023
@sapphi-red sapphi-red closed this as not planned Won't fix, can't repro, duplicate, stale May 29, 2023
@sapphi-red sapphi-red added the duplicate This issue or pull request already exists label May 29, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Jun 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
duplicate This issue or pull request already exists pending triage
Projects
None yet
Development

No branches or pull requests

2 participants