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

Aperta
#240 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
62/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
node.js, typescript

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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/

Lingua principale
TypeScript
Stelle
34
Fork
5
Merge medio
2g 4h
PR unite (30g)
41

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di focusreactive/payload-plugins

Tutte le issue di focusreactive/payload-plugins

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.