microsoft / microsoft/TypeScript
Support automatically updating URL import references when using `new URL(<file>, import.meta.url)`
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.3k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beschreibung
Bug Report
🔎 Search Terms
import.meta.url
🕗 Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about 4.3.0
⏯ Playground Link
💻 Code
Given the following files:
folder/file1.ts
console.log('file1');
export const foo = 42;
different-folder/file2.ts
new URL('../folder/file1.js', import.meta.url);
import('../folder/file1.js');
export const bar = 5;
- Create a new directory
sub-folder/in root - Move
different-folder/intosub-folder/so that the layout becomessub-folder/different-folder/file2.ts - When prompted for "Update imports for 'different-folder'?" click "Yes"
🙁 Actual behavior
sub-folder/different-folder/file2.ts
new URL('../folder/file1.js', import.meta.url);
import('../../folder/file1.js');
export const bar = 5;
The same is true if folder/file1.js is moved to a different location.
🙂 Expected behavior
Similar to the dynamic import, a file reference based on import.meta.url that points to a different TypeScript file should correctly be renamed accordingly.
sub-folder/different-folder/file2.ts
new URL('../../folder/file1.js', import.meta.url);
import('../../folder/file1.js');
export const bar = 5;
VS Code supports the standard dynamic import to handle file renaming. Since import.meta.url and URL are a standard way of resolving files, I would expect VS Code to natively support it as well. For example, Parcel compatibility is implemented in https://github.com/parcel-bundler/parcel/issues/5473, is implemented in Webpack 5 https://github.com/webpack/webpack/pull/11075 and is scheduled for implementation in ESBuild https://github.com/evanw/esbuild/issues/312#issuecomment-800730525
This issue was originally filed at https://github.com/microsoft/vscode/issues/121391
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit der verknüpften Workbench-Reproduktion unter Verwendung von new URL(<file>, import.meta.url) und vergleiche sie mit dem im Bericht beschriebenen Verhalten bei der Aktualisierung dynamischer Importe. Verfolge den VS Code-Import-Umbenennungspfad, der die Verschiebeoperation verarbeitet. Erledigt bedeutet, dass beim Verschieben einer der referenzierten Dateien die relative URL-Referenz auf dasselbe Ziel aktualisiert wird, entsprechend dynamischen Importen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript, vscode
- Bereich
- developer-experience, tooling
- Issue-Typ
- Feature
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100