Skip to content

Commit 7528ac2

Browse files
committed
Fix error related to perplex when used from ESM
This fixes an error related to invalid constructor for perplex when the module was used within an ESM project
1 parent 079f698 commit 7528ac2

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

.changeset/popular-bikes-search.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@labdigital/commercetools-mock': patch
3+
---
4+
5+
Fix error related to perplex when used from ESM

src/lib/predicateParser.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* See https://docs.commercetools.com/api/predicates/query
66
*/
7-
import perplex from 'perplex'
7+
import Lexer from 'perplex'
88
import { ITokenPosition, Parser } from 'pratt'
99
import { haversineDistance } from './haversine'
1010

@@ -104,7 +104,7 @@ const resolveValue = (obj: any, val: TypeSymbol): any => {
104104
}
105105

106106
const getLexer = (value: string) =>
107-
new perplex(value)
107+
new Lexer<string>(value)
108108

109109
.token('AND', /and(?![-_a-z0-9]+)/i)
110110
.token('OR', /or(?![-_a-z0-9]+)/i)

src/lib/projectionSearchFilter.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
*/
44

55
import type { ProductProjection, ProductVariant } from '@commercetools/platform-sdk'
6-
import perplex from 'perplex'
6+
import Lexer from 'perplex'
77
import Parser from 'pratt'
8-
import type { Writable } from '../types'
98
import { nestedLookup } from '../helpers'
9+
import type { Writable } from '../types'
1010

1111
type MatchFunc = (target: any) => boolean
1212

@@ -72,7 +72,7 @@ export const parseFilterExpression = (
7272
}
7373

7474
const getLexer = (value: string) =>
75-
new perplex(value)
75+
new Lexer<string>(value)
7676
.token('MISSING', /missing(?![-_a-z0-9]+)/i)
7777
.token('EXISTS', /exists(?![-_a-z0-9]+)/i)
7878
.token('RANGE', /range(?![-_a-z0-9]+)/i)

0 commit comments

Comments
 (0)