Skip to content

Conversation

rbuckton
Copy link

@rbuckton rbuckton commented Apr 8, 2025

This wires up source map emit to the emitter and enables source map baselines. After some fixes, the few source map diffs seem to be mostly due to missing transforms.

This also makes a minor change to the ast.SourceFile type to make Text() a method rather than a field. This was partially done to support sourcemap.Source, but also to make it easier to access the source file text while debugging as the Go debugger gets confused by Text being a field on SourceFile but a method on Node, which is observed when adding file.Text as a Watch expression or when referencing it in the Debug console.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 948 out of 948 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (2)

internal/ast/ast.go:9679

  • Consider adding documentation for the new Text() method to clarify its behavior compared to the previous Text field, which will help future maintainers.
func (node *SourceFile) Text() string {

internal/sourcemap/generator.go:23

  • [nitpick] Ensure that the renamed 'Generator' type is clearly documented and consistently referenced across the codebase to reduce potential confusion with other generator patterns.
type Generator struct {

)

var (
sourceMapCommentRegExp = regexp.MustCompile(`^\/\/[@#] sourceMappingURL=(.+)\r?\n?$`)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eventually we'll want to eliminate these since Go's regex perf is pretty bad.

// !!! Source file from node_modules are not emitted. In Strada, this depends on module resolution and uses
// `sourceFilesFoundSearchingNodeModules` in `createProgram`. For now, we will just check for `/node_modules/` in
// the file name.
if strings.Contains(sourceFile.FileName(), "/node_modules/") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest using .Pah() here but I assume this is just temporary?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is temporary.

@rbuckton rbuckton added this pull request to the merge queue Apr 9, 2025
Merged via the queue into microsoft:main with commit 1da2605 Apr 9, 2025
23 checks passed
@rbuckton rbuckton deleted the emit-sourcemaps branch April 9, 2025 20:02
shinichy pushed a commit to shinichy/typescript-go that referenced this pull request Apr 12, 2025
zshannon pushed a commit to zshannon/typescript-go that referenced this pull request Oct 6, 2025
zshannon pushed a commit to zshannon/typescript-go that referenced this pull request Oct 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants