Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

[api-extractor] ExtractorConfig fails when bundled into ESM output

オープン
#5,864 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
72/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
静か
技術スタック
nodejs, typescript

調査の方向性

Start at the ExtractorConfig._defaultConfig initialization and inspect how schemas/api-extractor-defaults.json is loaded. Reproduce the failure by bundling @microsoft/api-extractor into a single-file ESM output with a listed bundler, then verify that the default schema loads from the bundled output without a runtime filesystem path dependency.

索引モデルが issue の本文から書いたものです。

説明

When @microsoft/api-extractor is bundled into a single-file ESM output (e.g. with esbuild, rollup, rolldown, or webpack), the following error is thrown at runtime:

Error: File does not exist: /path/to/bundle-output/schemas/api-extractor-defaults.json

Root cause

ExtractorConfig loads its default config at module initialization time using a __dirname-relative path:

ExtractorConfig._defaultConfig = JsonFile.load(path.join(__dirname, '../schemas/api-extractor-defaults.json'));

__dirname is a CJS-only global — it doesn't exist in ESM. To handle this when bundling CJS code into ESM output, bundlers inject a replacement. For example, rolldown's recommended workaround is to globally define __dirname as import.meta.dirname via transform.define. This replacement resolves to the bundle's output directory rather than the original api-extractor package directory, so the schema file is never found.

Suggested fix

Replace the filesystem read with a static JSON import, which bundlers inline at build time:

import defaultConfig from '../schemas/api-extractor-defaults.json' with { type: 'json' };
ExtractorConfig._defaultConfig = defaultConfig;

This eliminates the runtime filesystem dependency entirely and works correctly whether the package is used directly or bundled.

主要言語
TypeScript
スター
6.5k
フォーク
708
平均マージ
4日 7時間
マージ済み PR(30日)
61

環境構築

このプロジェクトの環境構築ファイルはまだ確認していません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

microsoft/rushstack のほかの issue

microsoft/rushstack の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。