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

fix(nuxi): always override NODE_ENV - #5417

Merged
pi0 merged 6 commits into
mainfrom
fix/warn-mode
Jun 12, 2022
Merged

fix(nuxi): always override NODE_ENV#5417
pi0 merged 6 commits into
mainfrom
fix/warn-mode

Conversation

@danielroe

Copy link
Copy Markdown
Member

🔗 Linked issue

resolvesnuxt/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.

@danielroedanielroe 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 pi0June 11, 2022 13:28
@danielroedanielroe self-assigned this Jun 11, 2022
@netlify

netlifyBot commented Jun 11, 2022

Copy link
Copy Markdown

Deploy Preview for nuxt3-docs canceled.

NameLink
🔨 Latest commitb3e0d66
🔍 Latest deploy loghttps://app.netlify.com/sites/nuxt3-docs/deploys/62a65936fdc292000827de05

Comment threadpackages/nuxi/src/commands/build.ts Outdated
Comment threadpackages/nuxi/src/commands/analyze.ts Outdated
@pi0

pi0 commented Jun 12, 2022

Copy link
Copy Markdown
Member

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
Copy Markdown
MemberAuthor

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

pi0 commented Jun 12, 2022

Copy link
Copy Markdown
Member

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 ?

@danielroedanielroe changed the title fix(nuxi): add warnings when NODE_ENV is overridden by userfix(nuxi): override NODE_ENV for analyze, build & dev commandsJun 12, 2022
Comment threadpackages/nuxi/src/commands/analyze.ts Outdated
Comment threadpackages/nuxi/src/utils/env.ts Outdated
pi0
pi0 approved these changes Jun 12, 2022
@pi0pi0 changed the title fix(nuxi): override NODE_ENV for analyze, build & dev commandsfix(nuxi): always override NODE_ENVJun 12, 2022
@pi0
pi0 merged commit a9c061c into mainJun 12, 2022
@pi0
pi0 deleted the fix/warn-mode branch June 12, 2022 21:26
@pi0pi0 mentioned this pull request Jun 12, 2022
@danielroedanielroe mentioned this pull request Jun 17, 2022
7 tasks
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

3.xbugSomething isn't workingcli🍰 p2-nice-to-havePriority 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

3 participants

@danielroe@pi0@DamianGlowala