mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-25 19:37:34 -07:00
type errors
This commit is contained in:
parent
74c952170a
commit
badc30d7e7
1 changed files with 11 additions and 3 deletions
|
@ -5,6 +5,11 @@ import { Plugin } from 'rollup';
|
||||||
import { createFilter, dataToEsm } from '@rollup/pluginutils';
|
import { createFilter, dataToEsm } from '@rollup/pluginutils';
|
||||||
import { RollupJsonOptions } from '@rollup/plugin-json';
|
import { RollupJsonOptions } from '@rollup/plugin-json';
|
||||||
|
|
||||||
|
interface Json5SyntaxError extends SyntaxError {
|
||||||
|
lineNumber: number;
|
||||||
|
columnNumber: number;
|
||||||
|
}
|
||||||
|
|
||||||
export default function json5(options: RollupJsonOptions = {}): Plugin {
|
export default function json5(options: RollupJsonOptions = {}): Plugin {
|
||||||
const filter = createFilter(options.include, options.exclude);
|
const filter = createFilter(options.include, options.exclude);
|
||||||
const indent = 'indent' in options ? options.indent : '\t';
|
const indent = 'indent' in options ? options.indent : '\t';
|
||||||
|
@ -27,9 +32,12 @@ export default function json5(options: RollupJsonOptions = {}): Plugin {
|
||||||
map: { mappings: '' },
|
map: { mappings: '' },
|
||||||
};
|
};
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
const message = 'Could not parse JSON file';
|
if (!(err instanceof SyntaxError)) {
|
||||||
const position = parseInt(/[\d]/.exec(err.message)[0], 10);
|
throw err;
|
||||||
this.warn({ message, id, position });
|
}
|
||||||
|
const message = 'Could not parse JSON5 file';
|
||||||
|
const { lineNumber, columnNumber } = err as Json5SyntaxError;
|
||||||
|
this.warn({ message, id, loc: { line: lineNumber, column: columnNumber } });
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue