editor-js / editor-js/document-model

Audit TS module/target config and fix extensionless relative imports across packages

オープン
#167 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
TypeScript
スター
12
フォーク
3
PR マージ指標
30日以内にマージされた PR はありません

説明

## Problem

Several relative imports in `packages/sdk` (and likely elsewhere in the
monorepo) omit the `.js` extension or import a directory instead of its
`index.js` file, e.g. `from '../../entities'` instead of
`from '../../entities/index.js'`.

Since `@editorjs/sdk`'s `package.json` has `"type": "module"`, Node's ESM
resolver is strict about this: a value import through a bare directory
specifier throws `ERR_UNSUPPORTED_DIR_IMPORT`, and a missing extension on a
file specifier throws `ERR_MODULE_NOT_FOUND`. Type-only (`import type`)
specifiers with the same issue don't break at runtime (TS strips them
entirely), but they do break `.d.ts` resolution for consumers using
`moduleResolution: node16`/`nodenext`.

This doesn't surface as a failure anywhere in the repo today, since the only
consumers are Vite (`packages/playground`) and `ts-jest` (test suites) — both
resolve directories/extensions leniently, unlike raw Node ESM. But
`@editorjs/sdk` is published to npm, so any external consumer running it
under plain Node would hit this.

## Known instances

- `packages/sdk/src/entities/InlineTool.ts`
- `packages/sdk/src/entities/BlockTool.ts`
- `packages/sdk/src/entities/BlockTune.ts`
- `packages/sdk/src/entities/EditorjsPlugin.ts`
- `packages/sdk/src/entities/EditorjsAdapterPlugin.ts`
- `packages/sdk/src/entities/BlockToolAdapter.ts`
- `packages/sdk/src/entities/EventBus/events/core/ToolLoadedCoreEvent.ts`
- `packages/sdk/src/entities/EventBus/events/core/SelectionChangedCoreEvent.ts`

Similar patterns likely exist elsewhere in the monorepo, outside `packages/sdk`.

## Proposed scope

- Audit `module`/`moduleResolution`/`target` in each package's tsconfig to
match how it's actually consumed (bundler vs. Node ESM).
- Fix extensionless/directory relative imports repo-wide.
- Consider an ESLint rule (e.g. `import/extensions`) to prevent regressions
going forward.

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

packages/sdk/src/entities と packages/sdk/src/entities/EventBus/events/core 配下の一覧にあるファイルから始め、各パッケージの tsconfig について module、moduleResolution、target の設定を監査します。type-only import を含め、相対 import に明示的な .js ファイルや index.js パスが使われているかを確認し、公開された SDK が Node ESM で解決され、Vite playground や ts-jest の利用側を壊さないことを検証します。

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

評価

技術スタック
node.js, typescript
領域
build-system, tooling
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
静か
明瞭さ
おおむね明確
初心者へのやさしさ
52/100

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

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