-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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 api to detect whether source-maps are enabled #46304
Comments
I read through the linked vite pull request but it wasn't clear to me why you need to know whether source maps are enabled. Can you explain? What's the use case? |
Thanks for the response! Vite exports a function that rewrites Because Vite nor the script using Vite knows whether the stack trace points to the original source file or the transformed file, we cannot make that function no-op. // this is a pseudocode and won't work
import { load, rewriteStacktrace } from 'vite'
const mod = await load('./foo.js')
try {
mod.error()
} catch (e) {
console.log(e.stack) // this stack trace points to the transformed file
rewriteStacktrace(e) // rewrite the stack trace
console.log(e.stack) // this stack trace points to the original source file
} |
Right, that makes sense. |
I know I should avoid using internal things, but is there any way to access the internal |
It's not exposed in any way (I think) but pull request welcome. I wouldn't object to a side-effect-free |
Add `process.getSourceMapsEnabled` to detect whether source-maps are enabled. Fixes: nodejs#46304
There has been no activity on this feature request for 5 months and it is unlikely to be implemented. It will be closed 6 months after the last non-automated comment. For more information on how the project manages feature requests, please consult the feature request management document. |
Add `process.sourceMapsEnabled` to detect whether source-maps are enabled. Fixes: nodejs#46304
Add `process.sourceMapsEnabled` to detect whether source-maps are enabled. Fixes: nodejs/node#46304 PR-URL: nodejs/node#46391 Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Add `process.sourceMapsEnabled` to detect whether source-maps are enabled. Fixes: nodejs/node#46304 PR-URL: nodejs/node#46391 Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
What is the problem this feature will solve?
#39085 added
process.setSourceMapsEnabled
to enable source-maps programmatically. This is helpful for tools like Vite, thank you for implementing. 💚But as this was implemented we now cannot know whether source-maps are enabled. I guess it was possible by
process.execArgv.includes('--enable-source-maps')
previously.What is the feature you are proposing to solve the problem?
Add
process.getSourceMapsEnabled
that returns whether the source-maps are enabled.What alternatives have you considered?
Add a getter + setter named
process.isSourceMapsEnabled
that works likeprocess.getSourceMapsEnabled
andprocess.setSourceMapsEnabled
.The text was updated successfully, but these errors were encountered: