Skip to content
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

Nx option to have separate project.json files not supported #1520

Open
lan10rd opened this issue Jan 11, 2022 · 20 comments
Open

Nx option to have separate project.json files not supported #1520

lan10rd opened this issue Jan 11, 2022 · 20 comments
Labels
bug Something isn't working

Comments

@lan10rd
Copy link

lan10rd commented Jan 11, 2022

🐞 Bug report

Tried on ubuntu, windows, and mac os with node 14.17.0, using the latest nx create workspace. No matter what extra cli or config changes i make i constantly face a problem where it can't find angular.json (this is a apps/core nrwl nx monorepo, i dont even think its possible to use the angular.json variant anymore but idk, all the new nrwl workspaces have a workspace.json and each project has its own project.json).

root@docker-ubuntu-s-4vcpu-8gb-nyc3-01:~/workspace# npx scully --project x
✔ Folder "./scully" used for custom plugins
scully: using project config from "apps/x"
x Could not find project "x" in 'angular.json'.
⚠ Deprication Notice:
======================================================================
From now on, the plugin that is being used to render a route is
able to be changed by the user. You can do this by adding or
enabling the plugin in the scully.json file. For your convenience,
we loaded the Puppeteer plugin for you.

     To disable this warning enable the plugin of your choiche.
     for Puppteer please add:
         import '@scullyio/scully-plugin-puppeteer';
      to your scully.docs-app-ng.config.ts file.

      When you get this waring while not using scully-plugin-puppeteer
      you need to set the defaultRouteRenderer to the name of your plugin.
      The defaultRouteRenderer is now set to 'routeRenderer'.
   ======================================================================

x Angular distribution files not found, run "ng build" first

Description

🔬 Minimal Reproduction

💻Your Environment

Angular Version:





Scully Version:





🔥 Exception or Error




@lan10rd lan10rd added the bug Something isn't working label Jan 11, 2022
@SanderElias
Copy link
Contributor

@lan10rd I looked into your repo, and the root cause is the new NX option to have separated project.json files. We don't support this right now. I will change the title, so we can track the progress on this

@SanderElias SanderElias changed the title x Could not find project "x" in 'angular.json'. Nx option to have separate project.json files not supported Jan 12, 2022
@lan10rd
Copy link
Author

lan10rd commented Jan 12, 2022

thanks @SanderElias , i pulled the repo and just searched for the above warning/error language, if i can help let me know I am just a little unsure of how to build/try to fix it. i would think it's not necessary to check angular/project/workspace.json for anything if you already specified/found the scully.config.ts, but not sure if a cli option or a config fix is best. it looks like this is the new format for nx workspaces, i had a few thoughts in gitter but yeah just let me know im not sure how recent the nx team made this change!

@Jefiozie
Copy link
Collaborator

I'm not sure if this is the same behavior or issues as this one. But in the comments is a fix for that scenario. Could you check it @lan10rd

@lan10rd
Copy link
Author

lan10rd commented Jan 12, 2022

@Jefiozie target: 'targets' in config does certainly get passed that i think thats all that was needed! its not getting my routes cause they are all lazy loaded but it think there is support for that for sure, thanks!

@lan10rd
Copy link
Author

lan10rd commented Jan 12, 2022

let me fix that with some extra options or something and ill close this issue!

@SanderElias
Copy link
Contributor

Lazy routes are well supported in Scully.
However, if you have parts of it in buildable libraries. The Guess-parser is not able to detect them. (Makes sense, as it only scans your app. if part of your routes come in from libraries, there is no way it will know about those)
The only solution we can provide right now is adding them to the extra-routes array manually.
It might be possible to create a util that traverses all of the libs and uses Guess-parser to extract the routes from them.
But that leaves the exercise on how to link those into the route tree that comes out of the main app.

@brendanalexdr
Copy link

Am hitting this bug too.

@FanYeeChok
Copy link

been waiting for this bugs to be fix few months ago.

in order to scully workaround on NX izit we add the 'angular.json' manually?

@stianmorsund
Copy link

Until this is officially fixed/supported, you can get it to work by adding target: 'targets' inside the Scully-config as mentioned here: #1429

@SanderElias
Copy link
Contributor

Also, this is related to #1491

@BenLune
Copy link

BenLune commented Aug 31, 2022

Hi,
I add everything manually and it works. I think we are more and more people splitting their projects configs.
Thank you

@BlindDespair
Copy link
Contributor

Since NX 16, target: 'targets' no longer works as angular.json is deleted completely. Any idea what to do now?

@stianmorsund
Copy link

BlindDespair

There is an open PR that will fix that (#1654), but unfortunately it is not merged or resolved yet

@BlindDespair
Copy link
Contributor

@stianmorsund thanks, I checked that PR yesterday, but honestly I don't think it is a correct fix. It relies on you having your projects in apps directory which is not the case in my monorepo. I wrote this in gitter and will write it here: I believe that scully should drop the idea of reading the project configs to get a couple of fields and should instead ask the users of scully to provide those in scully.config.ts. That way this issue will never surface again and any kind of setup will be able to use it.

@stianmorsund
Copy link

@stianmorsund thanks, I checked that PR yesterday, but honestly I don't think it is a correct fix. It relies on you having your projects in apps directory which is not the case in my monorepo. I wrote this in gitter and will write it here: I believe that scully should drop the idea of reading the project configs to get a couple of fields and should instead ask the users of scully to provide those in scully.config.ts. That way this issue will never surface again and any kind of setup will be able to use it.

Sure, that would be more resilient. Right now it is not possible to use scully without angular.json though

@FanYeeChok
Copy link

FanYeeChok commented Jun 27, 2023

Currently im using NX v14.1.9 with Angular v13.3.12. Here my config file

scully.web-showroom.config.ts

import {ScullyConfig, setPluginConfig} from '@scullyio/scully';
import '@scullyio/scully-plugin-puppeteer';
/** this loads the default render plugin, remove when switching to something else. */
import { baseHrefRewrite } from '@scullyio/scully-plugin-base-href-rewrite';
import { getHttp404Plugin } from '@gammastream/scully-plugin-http404';

const Http404Plugin = getHttp404Plugin();
setPluginConfig(baseHrefRewrite, { href: '/abc' });

export const config: ScullyConfig = {
  projectRoot: "./apps/web-showroom/src",
  projectName: "web-showroom",
  distFolder: './dist/apps/web-showroom',
  spsModulePath: 'YOUR OWN MODULE PATH HERE',
  outDir: './dist/static',
  defaultPostRenderers: [Http404Plugin,'seoHrefOptimise', baseHrefRewrite],
  target: 'targets',
  handle404: 'index',
  routes: {
  }
};

npx scully --scanRoutes --cf=scully.web-showroom.config.ts

its able to generate the static file. Hope can help

@SanderElias
Copy link
Contributor

SanderElias commented Jun 27, 2023 via email

@FanYeeChok
Copy link

FanYeeChok commented Jun 28, 2023

I notice after upgrade to nx 15.8 ng15.2.9 scully will hitting this error due to removed workspace.json. If I just add in back the workspace.json will be working fine, even nx no longer need that file. if u have better solution, let us know.

must use the following command

npx scully --scanRoutes --cf=scully.web-showroom.config.ts

+ npx scully --scanRoutes --cf=scully.web-showroom.config.ts
  ✔ Folder "./scully" used for custom plugins
  ⚠ Using deprecated plugin type:"render"  use "postProcessByHtml" instead
  x Could not find project "web-showroom" in 'angular.json'.
  ✔ new Angular build files imported
  ✔ copied index.html to 404.html
  ✔ Starting servers for project "web-showroom"
  ✔ Started Scully static server on "http://localhost:1668/"
  ✔ Started Angular distribution server on "http://localhost:1864/" 
  ✔ Scully Development Server is up and running
  ✔ Puppeteer is being launched
DeprecationWarning: 'isTypeAssertion' has been deprecated since v4.0.0. Use `isTypeAssertionExpression` instead.
  ✔ Successfully scanned Angular app for routes
  ✔ Successfully added routes created from routePlugins
  x  The scullySystem plugin "storeRoutes has thrown the below error,
              while trying to render route "unknown"
              Scully will exit
  x TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined

@Splaktar
Copy link
Contributor

@SanderElias any eta on this?

The Nx Cloud caching does not work with Scully as of Nx v16. In this configuration, the cache is never invalidated, so every build gets old cached results, even when changes are made. We are not aware of a workaround at this time.

@MGREMY
Copy link

MGREMY commented Jan 14, 2024

Any update for this ? Without angular.json file ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

10 participants