patternfly / patternfly/patternfly-react

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

未关闭
#11,686 4 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

Breaking change :boom: Stale
主要语言
TypeScript
星标
862
派生
392
平均合并
4 天 8 小时
30 天内合并 PR
9

描述

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.

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

检查所有 PatternFly 包中 issue 所示的包元数据字段,然后使用 vitest 重现当前的模块解析问题。首先查看 NPM package-examples 和 Vite library-mode 参考资料;完成标准是每个受影响的包都通过标准包元数据支持 ESM 和 CommonJS。

由索引模型根据 Issue 内容生成。

评估

技术栈
nodejs, typescript
领域
build-system, developer-experience, release
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
42/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。