Exported PropTypes shapes get lost in translation
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 45/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- javascript, react
- Área
- build-system
Línea de trabajo
Reproduce el comando de microbundle informado con la importación compartida de LocaleShape e inspecciona el bundle generado, donde la shape de PropTypes exportada se convierte en null. Compáralo con la compilación funcional que duplica la shape; se considera hecho cuando las shapes importadas siguen siendo válidas y la advertencia de prop-type de React ya no informa expected one of [null,null].
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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
- Lenguaje dominante
- JavaScript
- Estrellas
- 8.1k
- Forks
- 358
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de developit/microbundle
-
CSS
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
developit/microbundle#1002 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
developit/microbundle#789 · 1 comentario ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 55/100
developit/microbundle#1100 · 4 comentarios ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
developit/microbundle#1094 · 1 comentario ·
-
Disable minification by default Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 45/100
developit/microbundle#1093 · 3 comentarios · 1 reacción ·
Todos los issues de developit/microbundle
Issues similares
-
awaiting triage bug Causes friction Hop Gui P1 P2 Transforms
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
-
Improve Title Support Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
georgestephanis/p2026#40 ·
-
Enatega Customer and Rider app: Add-ons price is not visible to customer after order is placed. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Margaret-Petersen/food-delivery-app-clone-react-native#1981 ·