Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Identifier "b" has already been declared

オープン
#34 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

@haneetsingh がすでに取り組んでいます。

2025年1月23日 から。

  • #35 @haneetsingh による — オープン

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
25/100
issue の種類
バグ
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
javascript, react, typescript, vite

調査の方向性

レポートは node_modules/use-editable/dist/use-editable.es.js と、競合している MutationObserver コールバックの宣言を指摘しています。まずビルドエラーを再現し、use-editable パッケージがどのようにビルドまたは利用されているかを確認してください。レポートでは、統合箇所の候補として vite.config.js と package.json にも言及しています。完了条件は、この宣言エラーなしでプロジェクトをビルドでき、関連する依存関係または設定の変更が検証されていることです。

索引モデルが issue の本文から書いたものです。

説明

bug
Is there an existing issue for this?
  • I have searched the existing issues
Code of Conduct
  • I agree to follow this project's Code of Conduct
Code Sandbox link

No response

Bug report
### What Does This Error Mean?

The error:


Identifier "b" has already been declared


indicates that the variable `b` has been declared multiple times in the same scope. This violates JavaScript's scoping rules, causing a syntax error during the build process. The issue originates from the `use-editable` package, specifically in the file:


/node_modules/use-editable/dist/use-editable.es.js


The problem is in this line:


"undefined" != typeof MutationObserver && (e.observer = new MutationObserver((function b(b) {


Here, `b` is both the name of the function and its parameter, creating a conflict.

---

### Which Module is Responsible?

The error is caused by the `use-editable` package, which appears to have a bug in its distributed code (`dist/use-editable.es.js`).

---

### How to Fix It


####  **Patch the Package**

If an updated version isn't available or doesn't fix the issue, you can patch the package locally:

1. Install `patch-package`:

   
   npm install patch-package --save-dev
   

2. Locate the problematic file:

   
   node_modules/use-editable/dist/use-editable.es.js
   

3. Edit the file to rename the conflicting identifier. For example, change:

   
   (function b(b) { ... });
   

   to:

   
   (function handleMutation(mutations) { ... });
   

4. Create a patch:

   
   npx patch-package use-editable
   

5. Add `patch-package` to your `postinstall` script in `package.json`:

   
   "scripts": {
     "postinstall": "patch-package"
   }
   

---

#### 3. **Use Vite Plugin to Handle Legacy Code**

If modifying the package isn't an option, use Vite's `optimizeDeps` to handle problematic dependencies. Add this to `vite.config.js`:


export default defineConfig({
  optimizeDeps: {
    include: ['use-editable']
  }
});


---


### Summary

- The error is caused by a bug in the `use-editable` package.
- Update the package, patch it locally, or configure Vite to handle it.

These steps should help resolve the build error effectively.
主要言語
TypeScript
スター
620
フォーク
16
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

FormidableLabs/use-editable のほかの issue

FormidableLabs/use-editable の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。