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

fix(gatsby): Remove internal Node modules in getNonGatsbyCallSite #19009

Merged
merged 3 commits into from
Oct 25, 2019
Merged
Changes from 1 commit
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
59 changes: 58 additions & 1 deletion packages/gatsby/src/utils/stack-trace-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,62 @@ const fs = require(`fs-extra`)
const path = require(`path`)
const chalk = require(`chalk`)

// copied from https://runpkg.com/?pretty-error@2.1.1/lib/nodePaths.js
// and added `^internal/` test
const nodePaths = [
/^_debugger.js$/,
/^_http_agent.js$/,
/^_http_client.js$/,
/^_http_common.js$/,
/^_http_incoming.js$/,
/^_http_outgoing.js$/,
/^_http_server.js$/,
/^_linklist.js$/,
/^_stream_duplex.js$/,
/^_stream_passthrough.js$/,
/^_stream_readable.js$/,
/^_stream_transform.js$/,
/^_stream_writable.js$/,
/^_tls_legacy.js$/,
/^_tls_wrap.js$/,
/^assert.js$/,
/^buffer.js$/,
/^child_process.js$/,
/^cluster.js$/,
/^console.js$/,
/^constants.js$/,
/^crypto.js$/,
/^dgram.js$/,
/^dns.js$/,
/^domain.js$/,
/^events.js$/,
/^freelist.js$/,
/^fs.js$/,
/^http.js$/,
/^https.js$/,
/^module.js$/,
/^net.js$/,
/^os.js$/,
/^path.js$/,
/^punycode.js$/,
/^querystring.js$/,
/^readline.js$/,
/^repl.js$/,
/^smalloc.js$/,
/^stream.js$/,
/^string_decoder.js$/,
/^sys.js$/,
/^timers.js$/,
/^tls.js$/,
/^tty.js$/,
/^url.js$/,
/^util.js$/,
/^vm.js$/,
/^zlib.js$/,
/^node.js$/,
/^internal[/\\]/,
]

const gatsbyLocation = path.dirname(require.resolve(`gatsby/package.json`))
const reduxThunkLocation = path.dirname(
require.resolve(`redux-thunk/package.json`)
Expand All @@ -19,7 +75,8 @@ const getNonGatsbyCallSite = () =>
callSite.getFileName() &&
!callSite.getFileName().includes(gatsbyLocation) &&
!callSite.getFileName().includes(reduxLocation) &&
!callSite.getFileName().includes(reduxThunkLocation)
!callSite.getFileName().includes(reduxThunkLocation) &&
!nodePaths.some(regTest => regTest.test(callSite.fileName))
sidharthachatterjee marked this conversation as resolved.
Show resolved Hide resolved
)

const getNonGatsbyCodeFrame = ({ highlightCode = true } = {}) => {
Expand Down