Source maps mapping looks wrong when using Webpack
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- 説明が足りない
- 活発さ
- 停滞
- 技術スタック
- javascript, typescript, webpack
- 領域
- devtools
調査の方向性
外部の test-source-maps プロジェクトから始め、issue に示されている generatedPositionFor() と originalPositionFor() の呼び出しと併せて dist/bundle.js.map を調査します。返されたマッピングを source-map API の想定および Webpack の設定と比較します。ラウンドトリップが有効かどうかを判断するか、再現可能なマッピング/設定の不具合を特定できれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Hello,
I've been experimenting with this repository. I tried to generate a simple project to use source maps using Webpack: https://github.com/eloparco/test-source-maps, where I produce a js bundle starting from Typescript and I want to use source maps for the mapping between the two.
I tried to play around with the generated source maps:
const SourceMapConsumer = require("source-map").SourceMapConsumer;
const fs = require("fs");
const SOURCEMAP_ABSOUTE_PATH = "/path/to/test-source-maps/dist/bundle.js.map";
const ORIGINAL_ABSOLUTE_PATH = "/path/to/test-source-maps/src/index.ts";
const GENERATED_ABSOLUTE_PATH = "/path/to/test-source-maps/dist/bundle.js";
const ORIGINAL_LINE = 11;
let json = JSON.parse(fs.readFileSync(SOURCEMAP_ABSOUTE_PATH).toString());
SourceMapConsumer.with(json, null, (consumer) => {
console.log(consumer.sources);
const generated = consumer.generatedPositionFor({
source: ORIGINAL_ABSOLUTE_PATH,
line: ORIGINAL_LINE,
column: 0,
});
console.log(generated);
const original = consumer.originalPositionFor({
line: generated.line,
column: generated.column,
});
console.log(original);
assert(original.line === ORIGINAL_LINE); // <------------ This assertion fails!!!
});
Here I use generatedPositionFor() to get the mapping from the original .ts file to the corresponding .js file. Then, I try to do the opposite and feed the line and column previously retrieved to originalPositionFor(), expecting it to return the original line/column that I passed to generatedPositionFor(). But that doesn't happen.
Is my understanding of source maps wrong? Or am I doing something wrong in the Webpack configuration?
Thanks
- 主要言語
- JavaScript
- スター
- 3.7k
- フォーク
- 370
- PR マージ指標
- 30日以内にマージされた PR はありません
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
mozilla/source-map のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
mozilla/source-map#530 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
mozilla/source-map#527 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
mozilla/source-map#524 · コメント 6 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
mozilla/source-map#516 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 30/100
mozilla/source-map#510 · リアクション 1 件 ·
mozilla/source-map の issue をすべて見る
似ている issue
-
Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
Automattic/safe-publish#594 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
dream-num/dsh-univer-office#104 ·
-
comp/dashboard invalid P3
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
NousResearch/hermes-agent#121143 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
avniproject/avni-webapp#1811 ·
-
area/auroraboot area/webui bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100