-
Notifications
You must be signed in to change notification settings - Fork 971
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
Make functions build path selection smarter: build path changes based on imports #2625
Comments
@bsmith418 sorry I don't quite understand what's going on here.
These pages may be useful to you: |
It is disrespectful to close the issue without asking clarifying questions. I took time out of my day to detail a problem, only to have what I was saying misunderstood and condescendingly dismissed. "Developer Relations" indeed. That aside, here is another go at explaining what is happening. Expected behavior: Actual behavior: Case study: A developer make a simple index.js. She builds firebase deploys, and it uploads her function to Firebase Functions. No problem. She decides to include a model.ts from her app's source code. Accordingly, she imports /exampleApp/src/app/example.model.ts into /exampleApp/functions/src/index.js. She builds and firebase deploy's. No errors, so everything seems to be fine. However, when she checks on her Function, she finds that the old version is still running. There were no errors, so she now has to sort through all of these possible problems:
The obscure truth is that an import into index.js might change the build directory, and the new build directory will have to be accounted for in package.json. This change in build directory happens under the hood, without notification or documentation. And thus, firebase deploy was uploading her old version in the old build directory, and not the new index.js in the new, esoterically generated build directory, and all of the above more-probable-seeming hypotheses were false. In summary, most developers expect ng build followed by firebase deploy to have predictable behavior. The actual behavior is far from predictable: it depends on your imports in index.js. The likely solution to all of this is to throw a warning in firebase tools when index.js includes an import from an ancestor or sibling of the /functions/ directory. |
@bsmith418 I apologize if you felt disrespected, that wasn't my intention. The reason I closed the issue so quickly was because it did not follow the issue template and from my initial reading it was out of scope for this issue tracker, as it seems like a complication with building Angular apps. Without detailed reproduction steps, I often can't do anything. That said I still think this is not an issue with the Firebase CLI, it sounds like more of something to do with how the Does that make sense? |
@samtstern No worries. I would imagine there is some degree of coordination between the Firebase and Angular teams? Changing the build process indeed seems cleaner. The problem scope / failure point is in Firebase, but the elegant solution is in Angular. It seems solvable on either end, and devs only care about consistent or transparent behavior. |
@bsmith418 hmmm I see where you're coming from but I don't really agree that Firebase has failed here. The Have you reported this issue to the Angular team? |
@bsmith418 so funny enough this exact issue happened to me last night while working on a personal project. My project doesn't use Angular, but it does use TypeScript and I had some code in So first of all thank you, since I immediately recognized the issue as the same one you had and didn't have to do any head scratching. Second of all I think this is something we could fix through |
Ok so apparently this is a well-worn issue (ex: microsoft/TypeScript#16683) and the official answer is: There are some discussions here about how to do a "clean build" of a TypeScript project: You could always do a simple Unfortunately my conclusion is that this is a TS quirk that is definitely painful but there's nothing Firebase can do here. When we see If you can think of a better answer please let me know and I will re-open this! But for now I'm going to close it as something we can't feasibly improve. I hope one day TS adds a simple |
If you import from your Angular project into index.js:
import {ExampleModel} from '../../src/app/example.model';
The build directory changes from
"lib/index.js"
to
"lib/functions/src/index.js"
Then when you try to "firebase deploy", firebase-tools will either break or deploy your old build at lib/index.js. If the latter happens, you'll have no errors and a great deal of confusion trying to figure out why your functions aren't updating.
The text was updated successfully, but these errors were encountered: