ng-doc: [Bug] Strange behavior on ng-doc 16.3.2

Is this a regression?

Yes

Description

I’m upgrading to 16.3.2 from Angular 15. It’s gone well so far, but I’m noticing a strange issue when building using webpack.

If I build first using webpack, the ng-doc folder isn’t generated properly. It’s missing all of the pages under guides. Example:

./.ng-doc/app/ng-doc.routing.ts:3:22-70 - Error: Module not found: Error: Can't resolve '.ng-doc/app/guides/installation/module' in '/Users/rbower/code/qc/qui/qui-components/packages/angular-docs/.ng-doc/app'

./.ng-doc/app/ng-doc.routing.ts:6:22-57 - Error: Module not found: Error: Can't resolve '.ng-doc/app/guides/module' in '/Users/rbower/code/qc/qui/qui-components/packages/angular-docs/.ng-doc/app'

It works when I use the esbuild builder. However, I need to use the webpack builder because tailwind + scss isn’t currently supported, and my docs site uses tailwind for demos.

What’s weird is that when I build using esbuild and then switch over to webpack and build, it works just fine, even if I clear the .ng-doc folder between builds.

Please provide the exception or error you saw

./.ng-doc/app/ng-doc.routing.ts:3:22-70 - Error: Module not found: Error: Can't resolve '.ng-doc/app/guides/installation/module' in '/Users/rbower/code/qc/qui/qui-components/packages/angular-docs/.ng-doc/app'

./.ng-doc/app/ng-doc.routing.ts:6:22-57 - Error: Module not found: Error: Can't resolve '.ng-doc/app/guides/module' in '/Users/rbower/code/qc/qui/qui-components/packages/angular-docs/.ng-doc/app'


### OS

Unix (Linux, macOS, etc.)

### Browser

Chrome

### Node version

18.16.0

### Anything else?

_No response_

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 24 (12 by maintainers)

Commits related to this issue

Most upvoted comments

@R-Bower it’s not reproducible in my new branch, so maybe I’ve already fixed it 🙃 I want to test a new feature and changes that I’ve done and release them tomorrow, so let’s wait a bit 😃

Anytime, happy to help!

So far I’ve tested the following:

  • Start dev mode without .ng-doc folder.
  • Start dev mode with .ng-doc folder from previous build.
  • Start dev mode with .ng-doc folder, but the folder is empty.
  • Build without .ng-doc folder.

Everything seems to be working as expected. Hot reloading is also working.

Awesome! Then I will merge the changes, and release them together with the next version. But I think let this feature be turned off by default for now, if there are no other problems with it in the future, then I will turn it on. Thanks a lot for the feedback! 👍

So far I’ve tested the following:

  • Start dev mode without .ng-doc folder.
  • Start dev mode with .ng-doc folder from previous build.
  • Start dev mode with .ng-doc folder, but the folder is empty.
  • Build without .ng-doc folder.

Everything seems to be working as expected. Hot reloading is also working.

I can get caching to work in dev mode by following these steps:

  1. Set cache: false in ng-doc.config.ts
  2. Build
  3. Set cache: true in ng-doc.config.ts
  4. Serve in dev mode.

It’s quite fast. Looking forward to when this is fixed 😃

It was working initially, but fails if I remove the .ng-doc folder contents and attempt a fresh build. I can’t get it to work after that.

Got it, thank you 👍 I’ll continue checking 🤔

There are only two hard things in Computer Science: cache invalidation and naming things.

The reason that the project was built correctly after switching the builder is that NgDoc resets the cache after changing the configuration, so I decided to disable the cache function by default, I have not yet been able to reproduce a similar problem on other projects, apparently, its stability depends on the environment. It seems that the only way to solve it is to get a project in which it is reproduced so that it would be possible to debug its behavior and understand what’s going on.

I’m also gonna refactor the builder, reduce the delay between the NgDoc and Angular builders, and maybe slightly increase the build speed, so maybe this problem will go away by itself, anyway will see!

Cool, thanks for the quick response!

@R-Bower ok great I think we’ve found the problem, I specifically made it so that the cache could be completely disabled by returning to the process as it was before the cache in case something like this happens, because the cache is quite a big feature and most likely will not work correctly on all projects from the start. I’ll try to reproduce this locally and fix it, thank you for the feedback!