electron / electron/electron

[Feature Request]: support to enable source maps

Open
#38,875 2 comments 11 reactions 0 assignees View on GitHub
enhancement :sparkles:
Dominant language
C++
Stars
123k
Forks
17.5k
Avg merge
14h 22m
Merged PRs (30d)
873

Description

### Preflight Checklist

- [X] I have read the [Contributing Guidelines](https://github.com/electron/electron/blob/main/CONTRIBUTING.md) for this project.
- [X] I agree to follow the [Code of Conduct](https://github.com/electron/electron/blob/main/CODE_OF_CONDUCT.md) that this project adheres to.
- [X] I have searched the [issue tracker](https://www.github.com/electron/electron/issues) for a feature request that matches the one I want to file, without success.

### Problem Description

Many applications are written in typescript, or when written in JavaScript are often bundled for production for improved performance.

Nodejs supports source maps by using `--enable-source-maps` (https://nodejs.org/dist/latest-v20.x/docs/api/cli.html#cli_enable_source_maps)

However I haven't quite found a way to get this option to work in electron.

## Things I tried

### Setting Node Options

```
NODE_OPTIONS="--enable-source-maps" my-electron-app
```

Results in an error:

```
[200886:0621/191332.844414:ERROR:node_bindings.cc(287)] Most NODE_OPTIONs are not supported in packaged apps. See documentation for more details.
```

### Using command line flag

```
my-electron-app --enable-source-maps
```

This doesn't seem to work

### Setting command line flag

```
app.commandLine.appendSwitch('--enable-source-maps')
```

This doesn't seem to work

### Proposed Solution

1. support enabling source maps by using `NODE_OPTIONS`
2. `app.commandLine.appendSwitch`
3. Support source maps through electron fuses

### Alternatives Considered

Using https://www.npmjs.com/package/source-map-support, but native node source map support would be preferred

### Additional Information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.