Skip to content

Commit 6e9fa80

Browse files
authoredNov 15, 2021
Fix Webpack compatibility (#29)
1 parent f3689b3 commit 6e9fa80

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed
 

‎index.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
import {createRequire} from 'node:module';
21
import errorEx from 'error-ex';
32
import fallback from 'json-parse-even-better-errors';
43
import {codeFrameColumns} from '@babel/code-frame';
5-
6-
const require = createRequire(import.meta.url);
7-
const {default: LinesAndColumns} = require('lines-and-columns');
4+
import LinesAndColumns from 'lines-and-columns';
85

96
export const JSONError = errorEx('JSONError', {
107
fileName: errorEx.append('in %s'),
@@ -34,7 +31,8 @@ export default function parseJson(string, reviver, filename) {
3431
}
3532

3633
if (indexMatch && indexMatch.length > 0) {
37-
const lines = new LinesAndColumns(string);
34+
// eslint-disable-next-line new-cap
35+
const lines = new LinesAndColumns.default(string);
3836
const index = Number(indexMatch[1]);
3937
const location = lines.locationForIndex(index);
4038

0 commit comments

Comments
 (0)
Please sign in to comment.