Skip to content
This repository was archived by the owner on Apr 6, 2023. It is now read-only.

Conversation

@danielroe
Copy link
Member

πŸ”— Linked issue

resolves nuxt/nuxt#14057

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

This adds warnings if user is overriding the correct NODE_ENV for build/dev/analyze. (Other commands like preview, typecheck or prepare I felt did not particularly matter, but happy to expand the warnings.)

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@danielroe danielroe added bug Something isn't working cli 🍰 p2-nice-to-have Priority 2: nothing is broken but it's worth addressing labels Jun 11, 2022
@danielroe danielroe requested a review from pi0 June 11, 2022 13:28
@danielroe danielroe self-assigned this Jun 11, 2022
@netlify
Copy link

netlify bot commented Jun 11, 2022

βœ… Deploy Preview for nuxt3-docs canceled.

Name Link
πŸ”¨ Latest commit b3e0d66
πŸ” Latest deploy log https://app.netlify.com/sites/nuxt3-docs/deploys/62a65936fdc292000827de05

@pi0
Copy link
Member

pi0 commented Jun 12, 2022

Thanks for the PR but if we are not recommending custom NODE_ENV, there is no reason to allow overriding it I think. However, it is also worth tracking down what happens with custom env specially for non development builds. It can be simply one or two bugs.

@danielroe
Copy link
Member Author

The cause of nuxt/nuxt#14057 is really a Vite bug (or perhaps it's unfair to say that it's a bug - we could say that Vite does not support building in development mode). Here's how it happens:

  1. options.dev is set to true if NODE_ENV is overridden
  2. vitejs/plugin-vue injects HMR code because it's not production: https://github.com/vitejs/vite/blob/main/packages/plugin-vue/src/main.ts#L131-L139
  3. vite replaces import.meta.hot with false because we're building: https://github.dev/vitejs/vite/blob/main/packages/vite/src/node/plugins/define.ts#L32-L45

I would be very happy with not allowing NODE_ENV to be overridden, but think if we do then we should definitely warn. What was the reason you originally added it (586709a)?

@pi0
Copy link
Member

pi0 commented Jun 12, 2022

Thanks for explaining! I think we can then change the strategy to override to what we expect but also warn if user already set a NODE_ENV we are overriding and saying hay, we just ignored your env ?

@danielroe danielroe changed the title fix(nuxi): add warnings when NODE_ENV is overridden by user fix(nuxi): override NODE_ENV for analyze, build & dev commands Jun 12, 2022
@pi0 pi0 changed the title fix(nuxi): override NODE_ENV for analyze, build & dev commands fix(nuxi): always override NODE_ENV Jun 12, 2022
@pi0 pi0 merged commit a9c061c into main Jun 12, 2022
@pi0 pi0 deleted the fix/warn-mode branch June 12, 2022 21:26
@pi0 pi0 mentioned this pull request Jun 12, 2022
@danielroe danielroe mentioned this pull request Jun 17, 2022
7 tasks
@danielroe danielroe added the 3.x label Jan 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

3.x bug Something isn't working cli 🍰 p2-nice-to-have Priority 2: nothing is broken but it's worth addressing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NODE_ENV overwriting results in weird errors

4 participants