diff --git a/packages/gatsby/src/db/loki/nodes-query.js b/packages/gatsby/src/db/loki/nodes-query.js index 6ca3247cd1334..d0e06e4e63138 100644 --- a/packages/gatsby/src/db/loki/nodes-query.js +++ b/packages/gatsby/src/db/loki/nodes-query.js @@ -5,7 +5,7 @@ const { getNamedType, isCompositeType, } = require(`graphql`) -const prepareRegex = require(`../../utils/prepare-regex`) +const { prepareRegex } = require(`../../utils/prepare-regex`) const { getNodeTypeCollection, ensureFieldIndexes, diff --git a/packages/gatsby/src/redux/run-sift.js b/packages/gatsby/src/redux/run-sift.js index fa48490e58866..9d5d8d9e6323c 100644 --- a/packages/gatsby/src/redux/run-sift.js +++ b/packages/gatsby/src/redux/run-sift.js @@ -1,7 +1,7 @@ // @flow const { default: sift } = require(`sift`) const _ = require(`lodash`) -const prepareRegex = require(`../utils/prepare-regex`) +const { prepareRegex } = require(`../utils/prepare-regex`) const { makeRe } = require(`micromatch`) const { getValueAt } = require(`../utils/get-value-at`) const { diff --git a/packages/gatsby/src/utils/__tests__/prepare-regex.js b/packages/gatsby/src/utils/__tests__/prepare-regex.js index a2327cf82e9a5..b9c2364884271 100644 --- a/packages/gatsby/src/utils/__tests__/prepare-regex.js +++ b/packages/gatsby/src/utils/__tests__/prepare-regex.js @@ -1,4 +1,4 @@ -const prepareRegex = require(`../prepare-regex`) +const { prepareRegex } = require(`../prepare-regex`) describe(`Prepare regex for Sift.js`, () => { it(`handles simple regex`, () => { diff --git a/packages/gatsby/src/utils/prepare-regex.js b/packages/gatsby/src/utils/prepare-regex.ts similarity index 82% rename from packages/gatsby/src/utils/prepare-regex.js rename to packages/gatsby/src/utils/prepare-regex.ts index bf229e9f91b3f..0c0cb2de8bdc9 100644 --- a/packages/gatsby/src/utils/prepare-regex.js +++ b/packages/gatsby/src/utils/prepare-regex.ts @@ -1,6 +1,6 @@ -const _ = require(`lodash`) +import _ from "lodash" -module.exports = str => { +export const prepareRegex = (str: string): RegExp => { const exploded = str.split(`/`) const regex = new RegExp( exploded