Main and component entries use removed `assert { type: 'json' }` syntax, and `/zod` export is uncompiled TypeScript with syntax errors

未关闭
#15 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
58/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃

调研方向

Start by reproducing both failures with the two node --input-type=module commands against a fresh install. Read scripts/generate-schemas.js (which emits the old assert { type: 'json' } import, unlike index.json.js) and scripts/generate-zod-schemas.js (which interpolates unescaped quotes/newlines into the 19 schema.zod.ts files), then check the exports map in package.json for ./zod. Done means both documented entry points import cleanly, generated files use with { type: 'json' }, and /zod ships compiled .js/.d.ts.

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

描述

Importing @patternfly/patternfly-component-schemas (or @patternfly/patternfly-component-schemas/components/*) fails on Node.js 22 and later with SyntaxError: Unexpected identifier 'assert', and @patternfly/patternfly-component-schemas/zod fails in both Node.js and TypeScript/bundlers.

npm install @patternfly/[email protected]
node --input-type=module -e "import { Button } from '@patternfly/patternfly-component-schemas'; console.log(Button.componentName);"
node --input-type=module -e "import { ButtonSchema } from '@patternfly/patternfly-component-schemas/zod'; console.log(ButtonSchema);"

Actual output (main entry):

file:///.../node_modules/@patternfly/patternfly-component-schemas/components/KeyboardHandler/index.js:2
import schema from './schema.json' assert { type: 'json' };
                                   ^^^^^^

SyntaxError: Unexpected identifier 'assert'

Actual output (/zod entry):

Error [ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING]: Stripping types is currently unsupported for files under node_modules, for "file:///.../node_modules/@patternfly/patternfly-component-schemas/zod/index.ts"

Bundling or type-checking @patternfly/patternfly-component-schemas/zod with esbuild, tsx, or tsc also fails to parse 19 generated components/*/schema.zod.ts files (for example .default('['BUTTON', 'A']') in components/KeyboardHandler/schema.zod.ts:30, unescaped multiline strings in components/TreeViewListItemBase/schema.zod.ts:12 and components/PopperOptions/schema.zod.ts:21, and \' inside z.custom<...>() in components/WizardContextProps/schema.zod.ts:28).

Expected output:

Both documented entry points import cleanly (Button.componentName logs "Button" and ButtonSchema loads as a Zod schema), matching @patternfly/patternfly-component-schemas/json.

scripts/generate-schemas.js emits import schema from './schema.json' assert { type: 'json' }; in all 479 components/*/index.js files instead of with { type: 'json' } (which index.json.js already uses), while package.json points "./zod" at raw ./zod/index.ts without compiled .js/.d.ts output and scripts/generate-zod-schemas.js interpolates unescaped quotes and newlines into generated TypeScript source.

Versions: @patternfly/[email protected] (npm latest) and main (b8509c3), Node.js v26.13.0.

Found with a differential-testing tool; the report was drafted with AI assistance and reviewed and edited by me.

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

主要语言
TypeScript
星标
1
派生
3
PR 合并指标
30 天内没有已合并 PR

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

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

patternfly/patternfly-component-schemas 的其他 Issue

查看 patternfly/patternfly-component-schemas 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

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