Skip to content

Regression: project is not working anymore from 6.0.8 -> 6.1.0 (in lerna monorepos) #11685

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

Closed
ctaepper opened this issue Jul 27, 2018 · 30 comments · Fixed by #12325
Closed

Regression: project is not working anymore from 6.0.8 -> 6.1.0 (in lerna monorepos) #11685

ctaepper opened this issue Jul 27, 2018 · 30 comments · Fixed by #12325

Comments

@ctaepper
Copy link

ctaepper commented Jul 27, 2018

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

Command (mark with an x)

- [x] all

Repro steps

Our angular/cli project ist located as one package of a larger lerna monorepo. We also make use of yarn workspaces, so all (or most) dependencies are hoisted within one single root node_modules folder. The resulting structure is something like

- node_modules <-- angular dependencies installed here
  - @angular
    - cli
    - core
    - ...
- packages
  - angular-app
    - package.json <-- angular dependencies defined here
    - src
    - ....
- package.json <-- no angular dependencies defined here

this line now (as of 6.1.0) prevents the project from working (at all) because relativePotential.startsWith('..') === true because in our structure relativePotential = ../../node_modules/@angular/core/package.json

everything was working fine with 6.0.8

The log given by the failure

You seem to not be depending on "@angular/core" and/or "rxjs". This is an error.

Desired functionality

I can work on my angular project with latest versions of everything

@hunhavoc
Copy link

hunhavoc commented Jul 27, 2018

Same setup - same issue here. Working on a workaround, I'll let you know if it works.

@ctaepper
Copy link
Author

I have been playing around with combining lerna packages with angular worspace, so I would pull the angular.json and all related dependencies into the root package. Then the lerna packages would be semantically the same as the angular workspace libraries/applications. This would also "fix" this bug, as the angular project root would be equal to the lerna root. I am confident this will work (and will be cool)

However this is not something we can easily achieve in existing projects and I still see this as regression bug.

@ctaepper ctaepper changed the title Regression: project is not working anymore from 6.0.8 -> 6.1.0 Regression: project is not working anymore from 6.0.8 -> 6.1.0 (in lerna monorepos) Jul 27, 2018
@jSchez
Copy link

jSchez commented Jul 27, 2018

Same here. We have tried both Lerna and Rush.js, same result.

@ctaepper
Copy link
Author

@hansl I am happy to create a PR for this issue. However, this is not really a bug in the code, more like a decision on how you check for dependencies. Is there anything I can do to speed this up?

@ctaepper
Copy link
Author

maybe there is the need for a setting in angular.json to make clear what is considered to "be within the project"

@cormacrelf
Copy link

cormacrelf commented Aug 1, 2018

See this issue with linked PRs #3864

@ctaepper
Copy link
Author

ctaepper commented Aug 2, 2018

still broken in 6.1.2

@ctaepper
Copy link
Author

6.1.3 🤷‍♂️

@alexeagle
Copy link
Contributor

Added to the top of our backlog

@iangregsondev
Copy link

In the meantime, not ideal, but a quick fix on the lerna.json file to NOT hoist certain dependencies..

    "bootstrap": {
      "nohoist": [
        "@angular/*",
        "@angular-devkit/build-angular",
        "rxjs",
        "@ngtools/*"
      ]
    }

@iangregsondev
Copy link

Actually, even this fix above is a nightmare as anything that is used by the UI needs to be set as a NOHOIST ...... So its a lot of packages. Anybody find an alternative fix ?

@iangregsondev
Copy link

I am using 6.1.5 (installed today).

@jSchez
Copy link

jSchez commented Aug 27, 2018

@appsolutegeek try to add your dependencies in the root package.json. Then you will be able to hoist the dependencies within your packages.

@ngbot ngbot bot added this to the Backlog milestone Aug 27, 2018
@gombosg
Copy link

gombosg commented Aug 29, 2018

I'm having the same issue, with only using Yarn workspaces. The nohoist option in package.json is indeed a fair temporary fix (thanks @appsolutegeek!) - hopefully this' will be fixed in the future.

@iangregsondev
Copy link

@gombosg no problem, hopefully, we can update the cli soon, so I can remove the NO HOIST packages.

@ctaepper
Copy link
Author

ctaepper commented Sep 3, 2018

sadly, the nohoist option is only available for private packages

also sadly

Added to the top of our backlog

does not seem to mean "this is the very next issue that gets fixed"

@ctaepper
Copy link
Author

ctaepper commented Sep 7, 2018

6.2.0, 7.0.0 😔

@fabianbru
Copy link

Is there any update when the issue will be fixed?

@ctaepper
Copy link
Author

@hansl 👍

@ctaepper
Copy link
Author

ctaepper commented Oct 2, 2018

wait a minute, why did this not land in 6.2.4 ???

@ptitjes
Copy link

ptitjes commented Oct 6, 2018

@ctaepper It seems that it went in 7.0.0-rc. Updating only @angular/cli worked for me.

@ptitjes
Copy link

ptitjes commented Oct 11, 2018

@alexeagle, @hansl, could we also have the fix on 6.2.x please? Moving to 7.0.0-rc* creates other problems with dependencies that are not ready for 7.0...

@johanchouquet
Copy link

Hi there, anyone tested monorepo approach with Firebase Cloud Functions ?

The idea: multiple apps for multiple Firebase targets, hosted via Firebase hosting. Each target would be a subdomain. I manage to do that.

But I'm struggling with Firebase Cloud Functions setup to be OK in the monorepo. It just doesn't work for now. Do you have best practices to share ?

@jorroll
Copy link

jorroll commented Jul 16, 2019

@johanchouquet I have an angular monorepo with multiple firebase projects in it, including a firebase functions project. I can confirm it works fine.

@johanchouquet
Copy link

johanchouquet commented Jul 16, 2019

@thefliik , I'm so glad to hear that it can work.

Then, i have this structure. I created 3 apps with the CLI. So my project structure is:

| projects
  | admin
  | app
  | website
package.json
| node_modules
| functions
  | package.json
  | node_modules
.firebaserc
firebase.json

Everything is standard there. When I do firebase deploy --only functions, it fails when executing the tsc task.
I've this stacktrace:

node_modules/@google-cloud/common/node_modules/gaxios/build/src/index.d.ts(14,66): error TS1005: '>' expected.
node_modules/@google-cloud/common/node_modules/gaxios/build/src/index.d.ts(14,103): error TS1109: Expression expected.
node_modules/firebase-functions/lib/function-builder.d.ts(58,93): error TS1005: ';' expected.
node_modules/firebase-functions/lib/function-builder.d.ts(58,94): error TS1003: Identifier expected.
node_modules/firebase-functions/lib/function-builder.d.ts(58,114): error TS1005: ';' expected.
node_modules/firebase-functions/lib/function-builder.d.ts(63,88): error TS1005: ';' expected.
node_modules/firebase-functions/lib/function-builder.d.ts(63,89): error TS1003: Identifier expected.
node_modules/firebase-functions/lib/function-builder.d.ts(63,109): error TS1005: ';' expected.
node_modules/firebase-functions/lib/function-builder.d.ts(63,110): error TS1131: Property or signature expected.
node_modules/firebase-functions/lib/function-builder.d.ts(63,127): error TS1005: ';' expected.
node_modules/firebase-functions/lib/function-builder.d.ts(63,184): error TS1109: Expression expected.
node_modules/firebase-functions/lib/function-builder.d.ts(63,229): error TS1005: '(' expected.
node_modules/firebase-functions/lib/function-builder.d.ts(64,5): error TS1128: Declaration or statement expected.
node_modules/firebase-functions/lib/function-builder.d.ts(65,5): error TS1128: Declaration or statement expected.
node_modules/firebase-functions/lib/function-builder.d.ts(99,5): error TS1128: Declaration or statement expected.
node_modules/firebase-functions/lib/function-builder.d.ts(117,5): error TS1128: Declaration or statement expected.
node_modules/firebase-functions/lib/function-builder.d.ts(124,5): error TS1128: Declaration or statement expected.
node_modules/firebase-functions/lib/function-builder.d.ts(131,5): error TS1128: Declaration or statement expected.
node_modules/firebase-functions/lib/function-builder.d.ts(138,146): error TS1005: '(' expected.
node_modules/firebase-functions/lib/function-builder.d.ts(140,5): error TS1128: Declaration or statement expected.
node_modules/firebase-functions/lib/function-builder.d.ts(153,5): error TS1128: Declaration or statement expected.
node_modules/firebase-functions/lib/function-builder.d.ts(162,5): error TS1128: Declaration or statement expected.
node_modules/firebase-functions/lib/function-builder.d.ts(168,1): error TS1128: Declaration or statement expected.
node_modules/firebase-functions/lib/function-configuration.d.ts(4,64): error TS1005: ']' expected.
node_modules/firebase-functions/lib/function-configuration.d.ts(4,66): error TS1134: Variable declaration expected.
node_modules/firebase-functions/lib/function-configuration.d.ts(4,153): error TS1005: ';' expected.
node_modules/firebase-functions/lib/function-configuration.d.ts(16,61): error TS1005: ']' expected.
node_modules/firebase-functions/lib/function-configuration.d.ts(16,63): error TS1134: Variable declaration expected.
node_modules/firebase-functions/lib/function-configuration.d.ts(16,93): error TS1005: ';' expected.

I'm not sure if i don't something wrong or anything. I'm using the latest dependencies in the functions/package.json, as follow:

"dependencies": {
    "firebase-admin": "~8.2.0",
    "firebase-functions": "^3.1.0"
  }

So, did you configure something to make Firebase Cloud Functions work fine in the monorepo ?

@jorroll
Copy link

jorroll commented Jul 16, 2019

@johanchouquet it's been a while since I set it up, so I can't remember if I encountered any issues in the beginning.

My folder structure is like so

> apps
  > app_one_name
    > app
    > e2e
    package.json
  > functions
    > src
    > tasks
    package.json
    tsconfig.json
    // ...
  > // ...
> libs
  > lib_one
  > lib_two
  > // ...
.firebaserc
angular.json
firebase.json
package.json
tsconfig.json
// ...

It's set up using yarn with yarn workspaces. The workspace's package.json includes:

{
  "workspaces": {
    "packages": [
      "apps/*",
      "libs/*"
    ]
  }
}

The only other thing of note is that the firebase.json file needs to specify the location of the functions source directory:

{
  "functions": {
    "source": "apps/functions"
  }
}

This all being said, your error message looks like it's coming from a syntax error in a typings file. Have you examined the file causing the error? Looks like it could be caused by an incorrect typescript version. Or perhaps the typings for dependencies are clashing in some way.

🤔 💭 It's times like these I wish github had some sort of direct messaging system, to avoid cluttering issues.

@johanchouquet
Copy link

johanchouquet commented Jul 16, 2019

Thanks @thefliik.

🤔 💭 It's times like these I wish github had some sort of direct messaging system, to avoid cluttering issues.

So true ^^!

This all being said, your error message looks like it's coming from a syntax error in a typings file. Have you examined the file causing the error? Looks like it could be caused by an incorrect typescript version. Or perhaps the typings for dependencies are clashing in some way.

I'm looking into this right now.

I've created my workspace using Angular Console. So I didn't expect that there would be issues in typescript versions or else. Maybe this is not related, but just saying. BTW, AngularConsole is really amazing.

I'll look into yarn workspaces. Seems to be simpler to deal with Cloud Functions.

@jorroll
Copy link

jorroll commented Jul 16, 2019

@johanchouquet sometimes typescript version errors can be hidden by vscode. VSCode, so long as it is kept updated, seems to always use the latest typescript version for intellisense. If your project has an older version of typescript installed, this means that vscode may not show you errors if you accidentally use a typescript feature that is newer than the typescript version your project is using (or if you depend on a library which, in turn, depends on a newer typescript version than you are using).

For example, a firebase functions project of mine was using typescript ~3.2. But I accidentally pulled in a library which made use of the new readonly Array<T> and as const syntax introduced in typescript 3.4. The error showed up as a strange syntax error at compile time. VSCode understood the syntax (because it was using typescript 3.5 to power intellisense), but the version of typescript using during compilation did not. The version of typescript used during compilation didn't even know how to define the error really. It said something like "variable declaration expected" or "unexpected [".

@johanchouquet
Copy link

@thefliik , indeed, my tsc version was 3.1.6 in VS Code terminal ! I managed to change it to the same version used in my projects (v3.4.5). But nothing changed: i still have those errors... Very strange behavior.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.