-
Notifications
You must be signed in to change notification settings - Fork 34
Description
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.