I need assistance with utilizing webpack 4's JSON tree-shaking feature as I am encountering a hurdle.
Here is an example of some functional code:
import { accessibility_16 } from '@collab-ui/icons/data/iconsData.json';
console.log("accessibility_16:", accessibility_16);
iconsData.json
contains extensive data, but thanks to webpack
, only the relevant code related to accessibility_16
is included in the final bundle (when using webpack -p
). The challenge arises when there are keys in the JSON file that are not valid JavaScript identifiers, such as arrow-circle-down_16
.
import { arrow-circle-down_16 } from '@collab-ui/icons/data/iconsData.json';
The code snippet above is invalid.
How can I import arrow-circle-down_16
while still taking advantage of JSON tree-shaking?
Thank you!