How to use the @microsoft/api-extractor.ExtractorConfig.loadFile function in @microsoft/api-extractor

To help you get started, we’ve selected a few @microsoft/api-extractor examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SkygearIO / skygear-SDK-JS / scripts / dts.js View on Github external
const lines = fs
    .readFileSync(dtsPath, { encoding: "utf8" })
    .split("\n")
    // Remove lines that reference @skygear/core
    // because we are going to inline its index.d.ts
    .filter(line => !/@skygear\/core/.test(line));
  const content =
    fs.readFileSync(coreDtsPath, { encoding: "utf8" }) + lines.join("\n");
  fs.writeFileSync(dtsPath, content);
}
fs.unlinkSync(coreDtsPath);

// Generate api.json
for (const p of publishedPackages) {
  const entrypoint = path.join(projectRoot, `packages/${p}/index.d.ts`);
  const configObject = ExtractorConfig.loadFile(
    path.join(projectRoot, "api-extractor.json")
  );
  configObject.mainEntryPointFilePath = entrypoint;
  configObject.projectFolder = path.join(projectRoot, `packages/${p}`);
  configObject.docModel.enabled = true;
  configObject.docModel.apiJsonFilePath = path.join(
    projectRoot,
    `temp/${p}.api.json`
  );

  const extractorConfig = ExtractorConfig.prepare({
    configObject,
    packageJsonFullPath: path.join(projectRoot, `packages/${p}/package.json`),
  });

  const extractorResult = Extractor.invoke(extractorConfig, {
github SkygearIO / skygear-SDK-JS / scripts / dts.js View on Github external
const projectRoot = path.join(__dirname, "..");

const publishedPackages = [
  "skygear-web",
  "skygear-node-client",
  "skygear-react-native",
];
const packages = ["skygear-core", ...publishedPackages];

const coreDtsPath = path.join(projectRoot, `packages/skygear-core/index.d.ts`);

// Generate index.d.ts
for (const p of packages) {
  const entrypoint = path.join(projectRoot, `packages/${p}/src/index.d.ts`);
  const configObject = ExtractorConfig.loadFile(
    path.join(projectRoot, "api-extractor.json")
  );
  configObject.mainEntryPointFilePath = entrypoint;
  configObject.projectFolder = path.join(projectRoot, `packages/${p}`);
  configObject.dtsRollup.enabled = true;
  configObject.dtsRollup.untrimmedFilePath = path.join(
    projectRoot,
    `packages/${p}/index.d.ts`
  );
  configObject.docModel.apiJsonFilePath = path.join(
    projectRoot,
    `temp/${p}.api.json`
  );

  const extractorConfig = ExtractorConfig.prepare({
    configObject,