patternfly / patternfly/patternfly-react

Bug - Package Publishing - Published Libraries should follow NPM dual module package standards

Offen
#11,686 4 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Breaking change :boom: Stale
Vorherrschende Sprache
TypeScript
Sterne
862
Forks
392
Ø Merge
4 T. 8 Std.
Gemergte PRs (30 T.)
9

Beschreibung

PatternFly libraries should follow NPM standards for publishing dual module (CommonJS/ESModule) packages.

PatternFly packages have

  "main": "dist/js/index.js",
  "module": "dist/esm/index.js",
  "types": "dist/esm/index.d.ts",

This is a really early format when es modules were being initially developed and not supported by modern tooling.

NPM documentation links to this as the right way to handle dual module packages.

{
  "type": "module",
  "exports": {
    "import": "./index.mjs",
    "require": "./index.cjs"
  }
}

Modern tooling like vite builds libraries with a combination of both for compatibility.

{
  "name": "my-lib",
  "type": "module",
  "main": "./dist/my-lib.umd.cjs",
  "types": "./dist/my-lib.d.ts",
  "module": "./dist/my-lib.js",
  "exports": {
    ".": {
      "import": "./dist/my-lib.js",
      "require": "./dist/my-lib.umd.cjs"
    }
  }
}

This is currently blocking us from using vitest to test because it gets really confused. It tries to import the code as ESM but then is unhappy that the package is not marked as type "module". If we manually add type 'module', it then runs into some code that uses a 'require', which is not valid in the scope of a module.

PatternFly packages should support both ESM and CommonJS using NPM standards for better compatibility.

This affects all PF packages not just react-core.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Überprüfe die im Issue gezeigten Paketmetadatenfelder in allen PatternFly-Paketen und reproduziere anschließend das aktuelle Problem bei der Modulauflösung mit vitest. Prüfe zuerst die Referenzen zu NPM package-examples und Vite library-mode; erledigt ist die Aufgabe, wenn jedes betroffene Paket sowohl ESM als auch CommonJS über standardmäßige Paketmetadaten unterstützt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
nodejs, typescript
Bereich
build-system, developer-experience, release
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
42/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.