Error: _mergeDefaults is not defined (in ^1.0)
関連するプルリクエストがすでにマージされています。
- #328 @Teages による — マージ済み
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 48/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- nuxtjs, typescript
- 領域
- build-system
調査の方向性
リンクされている nuxt-module-builder-issue の再現から始め、prepack playground path と dev:prepare を比較します。import された propDefaults と _mergeDefaults の呼び出し周辺にある生成されたコンポーネントコードを調べます。完了条件は、published-module path で undefined のヘルパーが生成されなくなり、import された 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
- 平均マージ
- 4日 19時間
- マージ済み PR(30日)
- 3
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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 が 136 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 45/100
nuxt/module-builder#749 ·
-
Tsdown/obuild migration再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
nuxt/module-builder#726 · コメント 1 件 · リアクション 1 件 ·
nuxt/module-builder の issue をすべて見る
似ている issue
-
The inspector never shows the instances field, so scaling out is unreachable対応中かも @Mrkewl が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
xevrion/breakscale#96 ·
メンテナーはふだん 4 日以内に返信
-
Object parameters lose their structure when resources is enabled対応中かも @asts-top が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
rossant/awesome-math#199 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
jaegertracing/jaeger-ui#4618 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
mifi/lossless-cut#3125 ·
メンテナーはふだん 1 日以内に返信