Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scopes: Requiring root scopes and root range #72

Open
szuend opened this issue Mar 6, 2024 · 2 comments
Open

Scopes: Requiring root scopes and root range #72

szuend opened this issue Mar 6, 2024 · 2 comments
Labels

Comments

@szuend
Copy link
Collaborator

szuend commented Mar 6, 2024

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 the global scope does not encompass the whole file.

Thoughts?

@hbenl
Copy link
Collaborator

hbenl commented Mar 8, 2024

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.

@jkup jkup added the Scopes label Mar 13, 2024
@szuend
Copy link
Collaborator Author

szuend commented May 21, 2024

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants