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

fix(plugin-react): jsxDev is not a function when is set NODE_ENV in env files #10861

Merged
merged 4 commits into from Nov 15, 2022

Conversation

Dunqing
Copy link
Contributor

@Dunqing Dunqing commented Nov 10, 2022

Description

fix: #10854

We need to execute loadEnv, because process.env.VITE_USER_NODE_ENV is only defined in it.

Additional context


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the Commit Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@patak-dev
Copy link
Member

@Dunqing would it be possible to modify the react playground to test this so we avoid a regression later?

@Dunqing
Copy link
Contributor Author

Dunqing commented Nov 11, 2022

@Dunqing would it be possible to modify the react playground to test this so we avoid a regression later?

Sure!

patak-dev
patak-dev previously approved these changes Nov 11, 2022
IanVS
IanVS previously approved these changes Nov 14, 2022
Copy link
Contributor

@IanVS IanVS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Dunqing! This does indeed fix my issue. I made one small suggestion to hopefully help future travelers, but this is great.

@@ -118,8 +119,16 @@ export default function viteReact(opts: Options = {}): PluginOption[] {
const viteBabel: Plugin = {
name: 'vite:react-babel',
enforce: 'pre',
config(_, { mode }) {
config(userConfig, { mode }) {
// Copied from https://github.com/vitejs/vite/blob/4e9bdd4fb3654a9d43917e1cb682d3d2bad25115/packages/vite/src/node/config.ts#L488-L490
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment range could be expanded, since we're now copying more of that logic.

Maybe something like: https://github.com/vitejs/vite/blob/4e9bdd4fb3654a9d43917e1cb682d3d2bad25115/packages/vite/src/node/config.ts#L477-L494

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your review!

@Dunqing Dunqing dismissed stale reviews from IanVS and patak-dev via ccfbf69 November 15, 2022 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[plugin-react] Alpha crashes when setting NODE_ENV in .env file
3 participants