Open szuend opened 4 months ago
If a javascript source is loaded as a script (rather than a module), no top-level scope for that source is created, it runs in the browser's global scope instead (which is important because this means that scripts can access each other's declarations). We could require encoding a global scope for each source anyway but I think we shouldn't because the encoded scopes should correspond to the "real" scopes. This also means that our assumption that there is one root scope for each source is wrong - scripts can define many top-level scopes.
Should we change the generatedRanges
in
interface SourceMap {
// ...
originalScopes?: OriginalScope[];
generatedRanges?: GeneratedRange;
}
to a GeneratedRange[]
? Or should generators insert a "pseudo" range that doesn't correspond to any authored scope but spans the full file and the various top-level scopes are children of that "pseudo" range?
I was wondering if we should require a single root scope/range of type
global
for each original source file and the generated file. These root scopes/range would start at line 0/column 0 and end at EOF of their respective file.I don't think it's strictly necessary, since consumers can insert them manually, but things could get a bit iffy e.g. if a single original file specifies multiple
global
sibling scopes and/or theglobal
scope does not encompass the whole file.Thoughts?