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

Add -t, --trace CLI option; enable TypeScript source maps #142

Merged
merged 3 commits into from
Jun 17, 2024

Conversation

towerofnix
Copy link
Member

This PR adds a -t / --trace CLI option which enables showing the log for unknown errors. It's not necessarily meant to be used by users, moreso just a convenience for us debugging problems.

It also enables source map generation in tsconfig.json. I believe these would be included in the NPM package, which I think is standard practice. Node.js (when running sb-edit) doesn't actually do anything with source maps without providing the --enable-source-maps option, typically via an environment variable.

sb-edit output with Node.js --enable-source-maps and sb-edit -t. The message reads, An unknown error occurred. The JavaScript details are shown below. This is a bug, please share the project you used on: URL to sb-edit issues. Then there is a blank line and the full error trace, which includes paths to the TypeScript source files. Same as above but no --enable-source-maps. Everything is the same except you get generated lib files in the stack trace, instead of source TypeScript files. Typical sb-edit output without any special options. The message is the same and you still see the JavaScript description of the error, but no stack trace.

@towerofnix towerofnix added the command-line Features or improvements for sb-edit CLI label May 30, 2024
@towerofnix towerofnix requested a review from PullJosh May 30, 2024 11:21
@towerofnix
Copy link
Member Author

Uh, we can't read and we clearly did not get source mapped stack traces working. 😅 One moment!

@towerofnix
Copy link
Member Author

OK, we switched to inline source maps and apparent Node.js likes those more. I'm sure separate-file source maps are supported in some manner but I can't really find documentation on it and am not too worried about it ATM (the codebase is small, I don't think this adds any remotely significant JS parser/memory overhead).

Same output but with real TypeScript traces now

Copy link
Collaborator

@PullJosh PullJosh left a comment

Choose a reason for hiding this comment

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

This looks good! Thank you.

@PullJosh PullJosh merged commit 27ed1dc into leopard-js:master Jun 17, 2024
1 check passed
@towerofnix towerofnix deleted the cli-trace branch June 17, 2024 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
command-line Features or improvements for sb-edit CLI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants