Skip to content

Commit 8f75ec6

Browse files
committed
fix ssr test
1 parent 6ed1700 commit 8f75ec6

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

packages/gatsby/src/utils/dev-ssr/render-dev-html-child.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const { codeFrameColumns } = require(`@babel/code-frame`)
33
const ansiHTML = require(`ansi-html`)
44
const fs = require(`fs-extra`)
55
const sysPath = require(`path`)
6+
const { slash } = require(`gatsby-core-utils`)
67

78
const getPosition = function (stackObject) {
89
let filename
@@ -33,9 +34,9 @@ const getPosition = function (stackObject) {
3334
row = 0
3435
}
3536
return {
36-
filename: filename,
37-
line: line,
38-
row: row,
37+
filename,
38+
line,
39+
row,
3940
}
4041
}
4142
// Colors taken from Gatsby's design tokens
@@ -61,7 +62,7 @@ const parseError = function ({ err, directory, componentPath }) {
6162
directory,
6263
// Don't need to use path.sep as webpack always uses a single forward slash
6364
// as a path separator.
64-
...position.filename.split(`/`).slice(2)
65+
...position.filename.split(sysPath.sep).slice(2)
6566
)
6667

6768
const splitMessage = err.message ? err.message.split(`\n`) : [``]
@@ -76,7 +77,7 @@ const parseError = function ({ err, directory, componentPath }) {
7677
? componentPath
7778
: filename
7879
const data = {
79-
filename: sysPath.relative(directory, trueFileName),
80+
filename: slash(sysPath.relative(directory, trueFileName)),
8081
message: message,
8182
type: type,
8283
stack: stack,
@@ -153,7 +154,7 @@ exports.renderHTML = ({
153154
// Only generate error pages for webpack errors. If it's not a webpack
154155
// error, it's not a user error so probably a system error so we'll just
155156
// panic and quit.
156-
const regex = /webpack:\/lib\//gm
157+
const regex = /webpack:[/\\]/gm
157158
const moduleBuildFailed = /Module.build.failed/gm
158159
if (stack.match(moduleBuildFailed)) {
159160
reject(`500 page`)

0 commit comments

Comments
 (0)