Skip to content

Commit

Permalink
Fix Webpack compatibility (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
shoonia committed Nov 15, 2021
1 parent f3689b3 commit 6e9fa80
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions index.js
@@ -1,10 +1,7 @@
import {createRequire} from 'node:module';
import errorEx from 'error-ex';
import fallback from 'json-parse-even-better-errors';
import {codeFrameColumns} from '@babel/code-frame';

const require = createRequire(import.meta.url);
const {default: LinesAndColumns} = require('lines-and-columns');
import LinesAndColumns from 'lines-and-columns';

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

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

Expand Down

0 comments on commit 6e9fa80

Please sign in to comment.