Relative imports in files inside folders resolve from src/ instead of the importing file
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 65/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- javascript, typescript
- 領域
- frontend
調査の方向性
Start in src/output/moduleCompiler.ts, in processModule, where local specifiers are rewritten with source.replace(/^./+/, 'src/') and only the './' prefix is checked for ImportDeclaration, ExportNamedDeclaration and dynamic import(). Resolve './' and '../' against the directory of the importing filename and normalize '.' and '..' segments. Done when the components/c.js and '../d.js' cases in the issue compile to the correct module keys, which you can check by reproducing them in the playground.
索引モデルが issue の本文から書いたものです。
説明
When a file is placed in a subfolder (for example components/c.js, which FileSelector, setFiles, and Monaco/Volar all accept), relative imports in that file are resolved from src/ instead of from the importing file's directory, and ../ specifiers are not resolved as local modules.
Reproduction
- Sibling
./d.jsincomponents/c.js:- SFC Playground: https://play.vuejs.org/#eNpdjkEKwjAQRa8yZNONJIh2I7HgPQoiccSKTUIyLdrSuztNQdrsMpn3359RXLyXfYfiJHQ0ofEEEanzVW2b1rtAMMIXJngE10IhlXH8a9FSVEa+YlFbrZYcJ3ggbP37RsgTgH7uqzHlJ634PcMrQOxEpuMr/q3DqvW+VOEn7Yyzkdh6hiGXzCBLNuDAYJFMGchGTl97DLFxlmMHWcpjKaYfq0tfAA==
@vue/replpreview (main): https://repl-vuejs.vercel.app/#eNpdjkEKwjAQRa8yZNONJIh2I7HgPQoiccSKTUIyLdrSuztNQdrsMpn3359RXLyXfYfiJHQ0ofEEEanzVW2b1rtAMMIXJngE10IhlXH8a9FSVEa+YlFbrZYcJ3ggbP37RsgTgH7uqzHlJ634PcMrQOxEpuMr/q3DqvW+VOEn7Yyzkdh6hiGXzCBLNuDAYJFMGchGTl97DLFxlmMHWcpjKaYfq0tfAA==
App.vue
<script setup>
import { y } from './components/c.js'
</script>
<template>
<h1>{{ y }}</h1>
</template>
components/c.js
import { z } from './d.js'
export const y = z
components/d.js
export const z = 'from components/d.js'
-
Same setup when
d.js(export const z = 'from src/d.js') also exists at root: -
Parent
../d.jsincomponents/c.jsimporting rootd.js:
Actual
- Preview fails with
File "./d.js" does not exist.. - When
src/d.jsalso exists,components/c.jscompiles toconst __import_1__ = __modules__["src/d.js"]and silently rendersfrom src/d.jsinstead offrom components/d.js. - With
import { z } from '../d.js', theimportstatement is left untouched insrc/components/c.js,src/d.jsis not compiled, and the preview stays blank (export { z as y } from '../d.js'emits__export__(__module__, "y", () => z), andexport * from '../d.js'throwsFile "../d.js" does not exist.).
Expected
Relative specifiers (./ and ../, including re-exports and dynamic import()) resolve against the directory of the importing filename and normalize . and .., so ./d.js in src/components/c.js resolves to src/components/d.js and ../d.js resolves to src/d.js.
Cause
In src/output/moduleCompiler.ts, processModule rewrites local specifiers with source.replace(/^\.\/+/, 'src/') without using filename's directory, and only checks source.startsWith('./') for ImportDeclaration, ExportNamedDeclaration, and dynamic import().
Versions
@vue/[email protected] and main (59212b9), [email protected] (verified on play.vuejs.org, repl-vuejs.vercel.app in Chromium 156, and Node v26.13.0).
Credit: https://ucsbplse.github.io/
- 主要言語
- TypeScript
- スター
- 1.1k
- フォーク
- 222
- 平均マージ
- 2時間 10分
- マージ済み PR(30日)
- 1
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
vuejs/repl のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
-
Feat request: export injectKeyProps再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 74/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 58/100
-
using Sandbox with clearConsole false,there would be a warning message on the browser's consoleオープン
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
-
Using `setFiles` removes tsconfig.json対応中かも @ifer47 が 121 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 25/100
似ている issue
-
bot:ai-assisted component:platform-js status:untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
midnightntwrk/platform-js#69 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
Picolab/pico-engine#668 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
ai-driven-qa bug claude Cosmetic
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
needs verification
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
メンテナーはふだん 13 日以内に返信