milesj / docusaurus-plugin-typedoc-api

Docusaurus plugin that provides source code API documentation powered by TypeDoc.
71 stars 25 forks source link

Monorepo with a single package is broken after update to v3.0.1 #107

Closed B4nan closed 12 months ago

B4nan commented 1 year ago

After updating to latest version (3.0.1 with TS 5.2), the generated api-typedoc-default.json file no longer has sources in the children in our case, so this line fails with TypeError: Cannot read properties of undefined (reading 'sources'). Using optional chaining on that array item on its own will make the build pass, but the page is not generated properly (I get 404 when switching to the next version).

When I log the mod object in that place, I get:

[info] JSON written to ./.docusaurus/api-typedoc-default.json
{
  id: 0,
  name: 'apify',
  kind: 1,
  kindString: 'Project',
  flags: {},
  originalName: '',
  children: []
}

But when I open that JSON file, I can see the children are there:

image

It's from this repository: https://github.com/apify/apify-sdk-js (I can PR the broken update if you want, but its just about updating the dependencies in website folder. Also tried to bump typedoc to 0.25.1 (via overrides) but no luck with that either.

jan-molak commented 1 year ago

I'm getting sources generated correctly for Serenity/JS using:

Maybe it's the TypeScript version affecting the result?

Screenshot 2023-10-09 at 19 37 26
milesj commented 12 months ago

@B4nan I think the problem is is that TypeDoc doesn't consider index.ts a module anymore. It doesn't show up in the list:

{
  allSourceFiles: {
    '3rd-party/apify-client-js/src/resource_clients/dataset.ts': true,
    '3rd-party/apify-client-js/src/resource_clients/user.ts': true,
    '3rd-party/apify-client-js/src/resource_clients/schedule.ts': true,
    '3rd-party/apify-client-js/src/resource_clients/webhook_dispatch.ts': true,
    '3rd-party/apify-client-js/src/resource_clients/actor.ts': true,
    '3rd-party/apify-client-js/src/resource_clients/actor_collection.ts': true,
    '3rd-party/apify-client-js/src/apify_api_error.ts': true,
    '3rd-party/apify-client-js/src/apify_client.ts': true,
    '3rd-party/apify-client-js/src/resource_clients/build.ts': true,
    '3rd-party/apify-client-js/src/resource_clients/build_collection.ts': true,
    '3rd-party/apify-client-js/src/resource_clients/dataset_collection.ts': true,
    '3rd-party/apify-client-js/src/interceptors.ts': true,
    '3rd-party/apify-client-js/src/resource_clients/key_value_store.ts': true,
    '3rd-party/apify-client-js/src/resource_clients/key_value_store_collection.ts': true,
    '3rd-party/apify-client-js/src/resource_clients/log.ts': true,
    '3rd-party/apify-client-js/src/resource_clients/request_queue.ts': true,
    '3rd-party/apify-client-js/src/resource_clients/request_queue_collection.ts': true,
    '3rd-party/apify-client-js/src/resource_clients/run.ts': true,
    '3rd-party/apify-client-js/src/resource_clients/run_collection.ts': true,
    '3rd-party/apify-client-js/src/resource_clients/schedule_collection.ts': true,
    '3rd-party/apify-client-js/src/resource_clients/store_collection.ts': true,
    '3rd-party/apify-client-js/src/resource_clients/task.ts': true,
    '3rd-party/apify-client-js/src/resource_clients/task_collection.ts': true,
    '3rd-party/apify-client-js/src/resource_clients/webhook.ts': true,
    '3rd-party/apify-client-js/src/resource_clients/webhook_collection.ts': true,
    '3rd-party/apify-client-js/src/resource_clients/webhook_dispatch_collection.ts': true,
    '3rd-party/apify-client-js/src/utils.ts': true
  },
  isSinglePackage: true,
  isUsingDeepImports: false,
  packagePath: '.'
} { relModSourceFile: '', relEntryPoint: 'src/index.ts' }

Probably because it just re-exports stuff and doesn't defined it's own types?

milesj commented 12 months ago

Confirmed that adding an explicit type to the index fixes it.

I can try and "hack" this in the plugin, but feels weird.

milesj commented 12 months ago

The fix is in v4