-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Parcel build setting NODE_ENV=production always #1476
Comments
This was already fixed by #1323 but wasn't released yet. Previously env were not replaced for node, now in 1.8.1 it is replaced with "NODE_ENV=production" for node too. I'm closing this. But please release 1.8.2 with this fix. |
I don't think this is parcel's fault. That was not a change in 1.8.1, that code has been there since parcel 1.0.0. And it does not set the environment variable external to the node process, so I'm not sure how it would affect anything outside of parcel. |
The faulty commit is actually #1166. It moves env replacement to pretransform and removes the check if target=browser, that was there before. As consequence of both this and replacing NODE_ENV, it is rewritten to "production". This was released on 1.8.1 (or 1.8.0?). The fix is already merged on master: #1323, but wasn't released yet. |
In 1.9.2, this problem still persists. When put in script |
Are you building for Node or for the Browser? On 21 Jun 2018 03:35, Satana Charuwichitratana <[email protected]> wrote:In 1.9.2, this problem still persists. When put in script NODE_ENV=staging parcel build the environment is set to production.
—You are receiving this because you modified the open/close state.Reply to this email directly, view it on GitHub, or mute the thread.
|
yes, i'm building for browser. I use |
For the Browser, parcel always set NODE_ENV to production. This is not a bug, this is a "wontfix" / feature.I'm not sure if I disagree with the decision, it does make usage easier. But at the same time, it is unexpected. A perhaps it should be set to production only if it is not set already? On 21 Jun 2018 04:00, Satana Charuwichitratana <[email protected]> wrote:yes, i'm building for browser.
—You are receiving this because you modified the open/close state.Reply to this email directly, view it on GitHub, or mute the thread.
|
IMHO, If it's not already set, then set to Just in case someone else having similar issue, I recently use |
Just want to give some example of how this could affect production even when the NODE_ENV only set during parcel run build. The problem could happen when some web app rely on NODE_ENV during build-time to change target database or api endpoint that the web app will be working on. For example, a web app using Anyway, I still prefer parcel over other tools and continue using it. Just hope this explanation helps to reconsider decision on the "wontfix" feature. |
I'm on the same boat than @micksatana ... configuring |
FYI, I just noticed. According to these lines, the issue is fixed in Lines 179 to 183 in 2aa7215
So in case anyone still in 1.9.2, just upgrade and you don't need this workaround.
|
🐛 bug report
I use parcel to build my node apis, this includes both the production and staging environment. For production I do:
And for staging my Dockerfile is:
Which is well within best practices. The
NODE_ENV
variable is later used in the code to decide in which database to connect.Today I upgraded to parcel 1.8.1, and deployed to the staging environment for testing. This same branch also does some heavy migrations on the database, changing schema of some core tables, and dropping a few others. This code wasn't ready for production.
But then comes this change on 1.8.1:
parcel/src/cli.js
Lines 172 to 176 in dc10531
WTF? Seriously? I can't
parcel build
for staging?Fast forwarding: The staging environment connected to the production database and ran all that bad test migrations which destroyed data.
Let's revert it, shall we?
The text was updated successfully, but these errors were encountered: