Skip to content

Commit

Permalink
fix production e2e?
Browse files Browse the repository at this point in the history
  • Loading branch information
wardpeet committed Feb 25, 2022
1 parent 3484035 commit 581402b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Expand Up @@ -71,7 +71,7 @@ export async function createGraphqlEngineBundle(
module: {
rules: [
{
test: require.resolve(`lmdb`),
test: /node_modules[/\\]lmdb[/\\]/,
parser: { amd: false },
use: [
{
Expand Down
12 changes: 7 additions & 5 deletions packages/gatsby/src/schema/graphql-engine/lmdb-bundling-patch.ts
@@ -1,4 +1,6 @@
/* eslint-disable @babel/no-invalid-this */
import { createRequireFromPath } from "gatsby-core-utils"
import path from "path"

// This is hacky webpack loader that does string replacements to
// allow lmdb@2 to be bundled by webpack for engines.
Expand All @@ -19,13 +21,13 @@ import { createRequireFromPath } from "gatsby-core-utils"
export default function (source: string): string {
let lmdbBinaryLocation
try {
const lmdbRequire = createRequireFromPath(require.resolve(`lmdb`))
const lmdbRoot =
this?._module.resourceResolveData?.descriptionFileRoot ||
path.dirname(this.resourcePath).replace(`/dist`, ``)
const lmdbRequire = createRequireFromPath(lmdbRoot)
const nodeGypBuild = lmdbRequire(`node-gyp-build`)
const path = require(`path`)

lmdbBinaryLocation = nodeGypBuild.path(
path.dirname(require.resolve(`lmdb`)).replace(`/dist`, ``)
)
lmdbBinaryLocation = nodeGypBuild.path(lmdbRoot)
} catch (e) {
return source
}
Expand Down

0 comments on commit 581402b

Please sign in to comment.