Error: _mergeDefaults is not defined (in ^1.0)
Una pull request collegata è già stata integrata.
- #328 di @Teages — integrata
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 48/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- nuxtjs, typescript
- Ambito
- build-system
Direzione di ricerca
Inizia con la riproduzione collegata di nuxt-module-builder-issue e confronta il percorso del playground di prepack con dev:prepare. Ispeziona il codice del componente generato intorno ai propDefaults importati e alla chiamata a _mergeDefaults; il lavoro è completato quando il percorso del published-module non produce più un helper undefined e preserva i valori predefiniti delle props importati.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
I updated a module to use 1.0 and kept getting this error when actually using it. Version 0.8 works fine. Managed to replicate the issue, here's the repo (prepack + dev playground). Note I set the playground to link the parent module and use it as if it were a real dep, otherwise I can't replicate. In a real app, using a real published module I can also replicate.
Interestingly, using dev:prepare does not have the same issue.
The issue happens if a component imports an object and uses it as the defaults for a prop, the outputted code looks like this:
<script setup>
import { propDefaults } from "./defaults.js";
defineProps(/* @__PURE__ */ _mergeDefaults({
color: { type: String, required: false },
disabled: { type: Boolean, required: false }
}, {
color: "blue",
...propDefaults
}));
</script>
If I remove propDefaults, because withDefaults is transformed away it works:
defineProps({
color: { type: String, required: false, default: "blue" },
disabled: { type: Boolean, required: false, default: false }
});
With 0.8 it used to just looked like this and worked fine:
<script setup lang="ts">
import { propDefaults } from './defaults.js'
withDefaults(defineProps<{
color?: string
disabled?: boolean
}>(), {
color: 'blue',
...propDefaults,
})
</script>
I know component's can't reference local objects because withDefaults is a compiler macro, but they can reference imports like this. Or at least, this had been working fine for me for a long time and I checked and it works fine on the Vue SFC playground too.
- Lingua principale
- TypeScript
- Stelle
- 277
- Fork
- 36
- Merge medio
- 4g 19h
- PR unite (30g)
- 3
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di nuxt/module-builder
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
nuxt/module-builder#801 ·
-
enhancement
Difficoltà 3/5 1-2 giorni Idoneità per principianti 48/100
nuxt/module-builder#764 ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
nuxt/module-builder#754 ·
-
Conflict between folder structure in readme (src/runtime) and TypeScript config (src/module/runtime)Forse già presa @dword-design l’ha presa 136 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 45/100
nuxt/module-builder#749 ·
-
Tsdown/obuild migrationForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Aperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
nuxt/module-builder#726 · 1 commento · 1 reazione ·
Tutte le issue di nuxt/module-builder
Issue simili
-
Object parameters lose their structure when resources is enabledForse già presa @asts-top l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
I maintainer di solito rispondono entro 2 giorni
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
jaegertracing/jaeger-ui#4618 ·
I maintainer di solito rispondono entro 1 giorno
-
pending close triaging
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
anomalyco/opencode#56765 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
area:plugins enhancement platform:vscode
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
anthropics/claude-code#103166 ·
I maintainer di solito rispondono entro 1 giorno
-
Types: FlashListProps imports ViewabilityConfig from react-native, removed in RN 0.87+Forse già presa @efegokdemir l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
Shopify/flash-list#2540 ·