-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
2.5.X new project with message “React is running in production mode, but dead code elimination has not been applied” #11775
Comments
Can confirm, it started to pop up in my apps as well. I don't recall seeing it in 2.5.0 and from 2.5.1 changelog the only possible culprit is #11758. I have another more pressing bug in my app, but I'll take a look once I deal with it. |
Possible related StackOverflow question. I also have this problem, and it slows down the app considerably. |
Hi @brianlukoff, is the issue that you had with terser also happening in https://atmospherejs.com/ostrio/flow-router-extra? Because I believe we will have to re-enable terser evaluate to solve this issue here. The code from flow-router using |
Hi @leobastiani can you run meteor update to confirm if the new minifier-js fixes this problem for you? |
@filipenevola Even if flow-router-extra works OK, I think we should be very hesitant to use a version of terser that we know changes the meaning of code! (If we know that terser corrupts flow-router, then what other code might it be mangling and what other subtle bugs might be introduced by its use?) |
Hi @brianlukoff I believe the problem is not in terser but in the way the flow-router code was implemented. We need this feature (evaluate) to correctly build React apps, for example. Did you try to isolate the problematic code in flow-router? I believe if you modernize this code in flow-router this problem is not going to happen anymore. We could also revert the bump that was made in terser a few months ago but sooner or later this problem would return. |
After running dockerfile="FROM ubuntu:20.04
ENV DEBIAN_FRONTEND noninteractive
ENV LANG=\"C.UTF-8\"
ENV TZ=Etc/Universal
RUN ln -snf /usr/share/zoneinfo/\$TZ /etc/localtime && echo \$TZ > /etc/timezone
RUN apt-get update && \
apt-get install -y sudo tzdata
RUN useradd -ms /bin/bash ubuntu && \
usermod -aG sudo ubuntu
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
USER ubuntu
WORKDIR /home/ubuntu
RUN sudo apt-get install wget curl git -y
RUN sudo mkdir -p /usr/local/n && \
sudo chown -R \$(whoami) /usr/local/n && \
sudo mkdir -p /usr/local/bin /usr/local/lib /usr/local/include /usr/local/share && \
sudo chown -R \$(whoami) /usr/local/bin /usr/local/lib /usr/local/include /usr/local/share
RUN wget -q -O n https://raw.githubusercontent.com/tj/n/master/bin/n && \
bash n install 14.18.1
RUN npm install -g meteor
ENV PATH=\"/home/ubuntu/.meteor:\${PATH}\"
WORKDIR /home/ubuntu
"
echo "$dockerfile" | docker build -t meteor-ubuntu:2.5.1 -
docker run -it \
--rm \
-p 3000:3000 \
--entrypoint /bin/bash \
meteor-ubuntu:2.5.1 -c "meteor --version && \
meteor create --typescript myapp && \
cd myapp && \
meteor update && \
meteor --version && \
NODE_ENV=production meteor --production" |
@filipenevola The screenshot in #11756 is the affected code (minified) with the link to the original code. But my concern is larger than flow-router; it's that terser is changing the meaning of any code. I agree we could certainly rewrite that code in flow-router, but there is so much code that we all depend on in various libraries -- how can we be confident that terser is not also changing the meaning of other code that is not part of flow-router? Certainly we could maintain our own versions of the minifier packages to solve the problem with flow-router, but I think it's dangerous for Meteor to be automatically applying a code transformation that might change the meaning of some code that a project is relying on. (We happened to discover this bug quickly because it generated an error upon changing routes, but terser could be creating much more subtle bugs that would be harder to catch.) I would come down on the side of reverting the update to terser until they address the issue, since other folks need |
Terser has a good enough popularity IMO. I believe if we improve flow-router code this issue is going to disappear. The code is using Meteor applies a lot of code transformations along the way, including Terser and Reify, as we have a compiler, bundler, and minifier we need to perform these operations. There is no way to avoid them. I believe an issue in the new flow-router repo would be the best way moving forward. |
I certainly understand that. I think updating that code in flow-router is certainly the way to go (or the newer fork may have already done so -- I haven't checked yet). But I still think it is dangerous to apply a transformation to every Meteor codebase (some may have similar legacy patterns in other older libraries) that we know has the potential to change the code's behavior and introduce bugs. Of course I am not opposed to these transformations in general -- as you said, they are critical to do -- but it's important that we can be confident that they will not change the semantics of the code! Of course this is your call with respect to the Meteor project as a whole. But even if I switch to the newer version of flow-router I would likely still decide to maintain a local fork of minifier-js that avoids the problematic |
@filipenevola @brianlukoff I have fully refactored |
Thanks @dr-dimitru -- I'll take a look at switching to |
@dr-dimitru yes, tests are not important for this matter. @brianlukoff I don't think you should be afraid of this option in Terser. This is the first problem like this in a long time using it. We could isolate this in a test case inside flow router to make sure this doesn't happen in future versions. Could you double check if @dr-dimitru fork doesn't manifest this problem? It would be really helpful. |
@filipenevola @dr-dimitru I have confirmed that |
We are deprecating |
Hi, Just to add my thoughts on this (having independently discovered and reported the issue in the Meteor forums.) As @brianlukoff says, I do have serious concerns that the minifier incorrectly interpretes the code. Even if the code uses out-dated paradigms, it is not actually illegal/incorrect code. My code and that of many libraries I use still has variables declared with Can we not hunt down the bug in minifier that is causing it to mis-interprete code (instead of changing a behaviour flag)? |
To see this error in the console you must have the React Devtools Extension
https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi?hl=en
Copy and paste this script on your terminal, you also need to have docker installed
Open http://localhost:3000 and see that “React is running in production mode, but dead code elimination has not been applied”
I also posted it here
https://forums.meteor.com/t/meteor-2-5-1-new-project-with-message-react-is-running-in-production-mode-but-dead-code-elimination-has-not-been-applied/57031/3
The text was updated successfully, but these errors were encountered: