@rollup/plugin-json
Advanced tools
Comparing version
# @rollup/plugin-json ChangeLog | ||
## v4.1.0 | ||
_2020-06-05_ | ||
### Features | ||
- feat: log the filename when JSON.parse fails (#417) | ||
## v4.0.3 | ||
@@ -4,0 +12,0 @@ |
@@ -16,11 +16,19 @@ import { createFilter, dataToEsm } from '@rollup/pluginutils'; | ||
return { | ||
code: dataToEsm(JSON.parse(json), { | ||
preferConst: options.preferConst, | ||
compact: options.compact, | ||
namedExports: options.namedExports, | ||
indent: indent | ||
}), | ||
map: { mappings: '' } | ||
}; | ||
try { | ||
var parsed = JSON.parse(json); | ||
return { | ||
code: dataToEsm(parsed, { | ||
preferConst: options.preferConst, | ||
compact: options.compact, | ||
namedExports: options.namedExports, | ||
indent: indent | ||
}), | ||
map: { mappings: '' } | ||
}; | ||
} catch (err) { | ||
var message = 'Could not parse JSON file'; | ||
var position = parseInt(/[\d]/.exec(err.message)[0], 10); | ||
this.warn({ message: message, id: id, position: position }); | ||
return null; | ||
} | ||
} | ||
@@ -27,0 +35,0 @@ }; |
@@ -18,11 +18,19 @@ 'use strict'; | ||
return { | ||
code: pluginutils.dataToEsm(JSON.parse(json), { | ||
preferConst: options.preferConst, | ||
compact: options.compact, | ||
namedExports: options.namedExports, | ||
indent: indent | ||
}), | ||
map: { mappings: '' } | ||
}; | ||
try { | ||
var parsed = JSON.parse(json); | ||
return { | ||
code: pluginutils.dataToEsm(parsed, { | ||
preferConst: options.preferConst, | ||
compact: options.compact, | ||
namedExports: options.namedExports, | ||
indent: indent | ||
}), | ||
map: { mappings: '' } | ||
}; | ||
} catch (err) { | ||
var message = 'Could not parse JSON file'; | ||
var position = parseInt(/[\d]/.exec(err.message)[0], 10); | ||
this.warn({ message: message, id: id, position: position }); | ||
return null; | ||
} | ||
} | ||
@@ -29,0 +37,0 @@ }; |
{ | ||
"name": "@rollup/plugin-json", | ||
"version": "4.0.3", | ||
"version": "4.1.0", | ||
"publishConfig": { | ||
@@ -5,0 +5,0 @@ "access": "public" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
15652
14.26%104
18.18%