Error: _mergeDefaults is not defined (in ^1.0)
已经有一个关联 PR 被合并了。
- #328 来自 @Teages —— 已合并
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 48/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- nuxtjs, typescript
- 领域
- build-system
调研方向
从链接的 nuxt-module-builder-issue 复现开始,并将 prepack playground path 与 dev:prepare 进行比较。检查生成的组件代码中围绕导入的 propDefaults 和 _mergeDefaults 调用的部分;完成标准是 published-module path 不再产生 undefined helper,同时保留导入的 prop defaults。
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- TypeScript
- 星标
- 277
- 派生
- 36
- 平均合并
- 2 小时 46 分钟
- 30 天内合并 PR
- 2
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
nuxt/module-builder 的其他 Issue
-
难度 3/5 1-2 天 新手友好度 68/100
nuxt/module-builder#801 ·
-
enhancement
难度 3/5 1-2 天 新手友好度 48/100
nuxt/module-builder#764 ·
-
难度 3/5 1-2 天 新手友好度 45/100
nuxt/module-builder#754 ·
-
Conflict between folder structure in readme (src/runtime) and TypeScript config (src/module/runtime)可能已有人在做 @dword-design 于 138 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 45/100
nuxt/module-builder#749 ·
-
Tsdown/obuild migration可能重新可做 关联的 PR 已关闭且未合并。 未关闭
难度 5/5 一周以上 新手友好度 25/100
nuxt/module-builder#726 · 1 条评论 · 1 个 reaction ·
查看 nuxt/module-builder 的全部 Issue
相似的 Issue
-
enhancement
难度 2/5 1-3 小时 新手友好度 68/100
equinor/prisma-decision-web#919 ·
维护者通常 1 天内回复
-
[DC] OneLogin sync imports a partial user list when an API request fails可能已有人在做 @RaphaelFakhri 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 84/100
bitwarden/directory-connector#1276 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
home-assistant/installer#324 ·
维护者通常 1 天内回复
-
Mondriaan
难度 2/5 1-3 小时 新手友好度 65/100
knaw-huc/textannoviz#733 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复