milesj/docusaurus-plugin-typedoc-api

Polyrepo mode fails when `readmes` or `changelogs` are enabled

B4nan opened this issue · 0 comments

B4nan commented

When in polyrepo context, enabling readmes or changelogs make this webpack config include the whole project root, which makes docusaurus unhappy with the following:

SyntaxError: /Users/adamek/htdocs/apify/apify-client-js/docs/index.md: Identifier 'React' has already been declared. (32:396)
  30 | };
  31 |
> 32 | import _extends from"/Users/adamek/htdocs/apify/apify-client-js/website/node_modules/@babel/runtime/helpers/esm/extends.js";import _objectWithoutPropertiesLoose from"/Users/adamek/htdocs/apify/apify-client-js/website/node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js";var _excluded=["components"];/* @jsxRuntime classic */ /* @jsx mdx */ /* @jsxFrag React.Fragment */import React from'react';import{mdx}from'@mdx-js/react';
     |                                                                                                                                                                                                                                                                                                                                                                                                             ^
  33 | export var frontMatter = {};
  34 | export var contentTitle = undefined;
  35 | export var toc = [];
    at parser.next (<anonymous>)
    at normalizeFile.next (<anonymous>)
    at run.next (<anonymous>)
    at transform.next (<anonymous>)
client (webpack 5.75.0) compiled with 1 error

Changing that include to the following helps on my end:

const include = packageConfigs.flatMap(cfg => [
    path__default.default.join(options.projectRoot, cfg.packagePath, options.readmeName),
    path__default.default.join(options.projectRoot, cfg.packagePath, options.changelogName),
]);

Will send a PR.