comments, seo, analytics, and presets publish ESM that fails to load in Node.js (follow-up to #149)

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

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

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

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
62/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
node.js, typescript

調査の方向性

Start with the tsup.config.ts of comments, seo and analytics to see the bundle: false setting that leaves relative specifiers extensionless, and compare against how #149 fixed translator (same repo, published config is the reference). For presets, read src/plugin.ts (the ../package.json import) and the relative imports in src/components/blocksDrawer/PresetItem/index.tsx and src/components/presetActions/BlockLabelWithPresets/index.tsx. Then run the repro.mjs snippet after building each package; done means all four print OK and tsc passes under node16/nodenext.

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

説明

Four published ESM packages in this repo (@focus-reactive/payload-plugin-comments, -seo, -analytics, and -presets) cannot be loaded by Node's ESM resolver because their published dist files contain extensionless relative specifiers or a JSON import without type: "json" (the same class of issue #149 fixed for translator).

// repro.mjs
for (const pkg of [
  "@focus-reactive/payload-plugin-comments",
  "@focus-reactive/payload-plugin-seo",
  "@focus-reactive/payload-plugin-analytics",
  "@focus-reactive/payload-plugin-presets",
]) {
  try {
    await import(pkg);
    console.log(pkg, "OK");
  } catch (err) {
    console.log(`${pkg}: ${err.code}: ${err.message.split("\n")[0]}`);
  }
}

Run with:

npm install --legacy-peer-deps \
  @focus-reactive/[email protected] \
  @focus-reactive/[email protected] \
  @focus-reactive/[email protected] \
  @focus-reactive/[email protected]
node repro.mjs

Actual output:

@focus-reactive/payload-plugin-comments: ERR_MODULE_NOT_FOUND: Cannot find module '.../node_modules/@focus-reactive/payload-plugin-comments/dist/plugin' imported from .../node_modules/@focus-reactive/payload-plugin-comments/dist/index.js
@focus-reactive/payload-plugin-seo: ERR_MODULE_NOT_FOUND: Cannot find module '.../node_modules/@focus-reactive/payload-plugin-seo/dist/plugin' imported from .../node_modules/@focus-reactive/payload-plugin-seo/dist/index.js
@focus-reactive/payload-plugin-analytics: ERR_MODULE_NOT_FOUND: Cannot find module '.../node_modules/@focus-reactive/payload-plugin-analytics/dist/plugin' imported from .../node_modules/@focus-reactive/payload-plugin-analytics/dist/index.js
@focus-reactive/payload-plugin-presets: ERR_IMPORT_ATTRIBUTE_MISSING: Module "file:///.../node_modules/@focus-reactive/payload-plugin-presets/package.json" needs an import attribute of "type: json"

Expected: all four packages resolve and load in Node.js (and type-check cleanly under moduleResolution: "node16" / "nodenext"), matching ab, html-preview, json-form-builder, netlify-deploy, scheduling, translator, and visual-editing.

#149 noted presets as unbundled swc and assumed the tsup-built plugins bundled relative imports away, but comments, seo, and analytics set bundle: false in tsup.config.ts (leaving all 249, 369, and 757 relative JS imports and their .d.ts imports extensionless), while presets has import packageJson from "../package.json" in src/plugin.ts plus extensionless relative imports in src/components/blocksDrawer/PresetItem/index.tsx and src/components/presetActions/BlockLabelWithPresets/index.tsx.

Tested on @focus-reactive/[email protected], @focus-reactive/[email protected], @focus-reactive/[email protected], and @focus-reactive/[email protected] (npm latest), and built from main (b0644fd54) with Node.js v26.13.0.

Credit: https://ucsbplse.github.io/

主要言語
TypeScript
スター
34
フォーク
5
平均マージ
2日 4時間
マージ済み PR(30日)
41

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

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

focusreactive/payload-plugins のほかの issue

focusreactive/payload-plugins の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

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

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