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

feat(remix-serve): Allow opting out of using source-map-support #9753

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions contributors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@
- levippaul
- LewisArdern
- lfantone
- lforst
- lifeiscontent
- lili21
- lionotm
Expand Down
3 changes: 3 additions & 0 deletions docs/start/v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -1064,6 +1064,9 @@ import sourceMapSupport from "source-map-support";
sourceMapSupport.install();
```

`source-map-support` introduces incompatibilities with certain observability tools, causing the tool not to be able to properly unminify your errors.
If you want to opt out of using `source-map-support` when using `remix-serve`, you can set `REMIX_NO_SOURCE_MAP_SUPPORT=1` as environment variable.

## Netlify adapter

The `@remix-run/netlify` runtime adapter has been deprecated in favor of
Expand Down
32 changes: 17 additions & 15 deletions packages/remix-serve/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,24 @@ import getPort from "get-port";

process.env.NODE_ENV = process.env.NODE_ENV ?? "production";

sourceMapSupport.install({
retrieveSourceMap: function (source) {
let match = source.startsWith("file://");
if (match) {
let filePath = url.fileURLToPath(source);
let sourceMapPath = `${filePath}.map`;
if (fs.existsSync(sourceMapPath)) {
return {
url: source,
map: fs.readFileSync(sourceMapPath, "utf8"),
};
if (!process.env.REMIX_NO_SOURCE_MAP_SUPPORT) {
sourceMapSupport.install({
retrieveSourceMap: function (source) {
let match = source.startsWith("file://");
if (match) {
let filePath = url.fileURLToPath(source);
let sourceMapPath = `${filePath}.map`;
if (fs.existsSync(sourceMapPath)) {
return {
url: source,
map: fs.readFileSync(sourceMapPath, "utf8"),
};
}
}
}
return null;
},
});
return null;
},
});
}

run();

Expand Down