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

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

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

評価

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

調査の方向性

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 はありません

環境構築

はじめの一歩

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

patternfly/patternfly-component-schemas のほかの issue

patternfly/patternfly-component-schemas の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

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

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