Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Exported PropTypes shapes get lost in translation

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

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

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
javascript, react
領域
build-system

調査の方向性

共有された LocaleShape の import を使用して報告された microbundle コマンドを再現し、エクスポートされた PropTypes shape が null になる生成済み bundle を調査します。shape を複製する正常な build と比較します。import された shape が有効なままになり、React の prop-type 警告で expected one of [null,null] が報告されなくなれば完了です。

索引モデルが issue の本文から書いたものです。

説明

question :grey_question:

Hi there,
Thank you for the great work you've done with microbundle. For the record, here is how I'm using the lib:
microbundle --jsx React.createElement --no-compress --format modern,cjs

I'm using react in version 17 and microbundle in version 0.12.0-next.9

I've got a PropType shape that is used in several definitions:

import PropTypes from "prop-types";

 const LocaleShape = PropTypes.shape({
    // two-char language code ("en", "fr", "de")
    tag: PropTypes.string.isRequired,
    // human readable language description
    language: PropTypes.oneOf([PropTypes.object, PropTypes.string]).isRequired,
    //latin, cyrillic, etc.
    script: PropTypes.string,
    // two-char region code ("US", "CA", "GB", "CH")
    region: PropTypes.string,
    // text direction / orientation: right to left, left to right
    orientation: PropTypes.oneOf(["rtl", "ltr"]),
    // optional emoji string for displaying a flag 🇨🇬 🇲🇼 🇹🇩
    flag: PropTypes.string,
    // String that can be used to search for a locale
    keywords: PropTypes.string,
    // locale identifier of the fallback locale
    fallback: PropTypes.string,
    // optional identifier. If not specified, locale identifier will result in the concatenation
    // of tag and region, with a dash separator: "en-GB", "fr-CA", "nl-BE"
    id: PropTypes.string,
});
export default LocaleShape;

This shape is imported in different files:

LocaleChooser.propTypes = {
  value: PropTypes.oneOfType([LocaleShape, PropTypes.arrayOf(LocaleShape)]),
  locales: PropTypes.arrayOf(LocaleShape),
}

When the bundle is built, it looks like the exported PropType shape is turned into null, as explain the warnings I receive in console:

Warning: Failed prop type: Invalid prop `locales[0].language` of value `[object Object]` supplied to `LocaleChooser`, expected one of [null,null].

This warning is suppressed once I remove the imports and duplicate the LocaleShape in every file that requires it. Am I missing a parameter in the command?

Thanks for your help

主要言語
JavaScript
スター
8.1k
フォーク
358
PR マージ指標
30日以内にマージされた PR はありません

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

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

developit/microbundle のほかの issue

developit/microbundle の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

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

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