Lazy load JSZip

This commit is contained in:
Jordan Eldredge 2018-05-14 17:14:28 -07:00
parent 58f9b8d8b1
commit 0844e9e0c1

View file

@ -1,4 +1,3 @@
import JSZip from "../node_modules/jszip/dist/jszip"; // Hack
import SKIN_SPRITES from "./skinSprites";
import regionParser from "./regionParser";
import {
@ -8,6 +7,14 @@ import {
} from "./constants";
import { parseViscolors, parseIni, getFileExtension } from "./utils";
const getJSZip = () => {
return new Promise(resolve => {
require.ensure("../node_modules/jszip/dist/jszip", require => {
resolve(require("../node_modules/jszip/dist/jszip"));
});
});
};
const shallowMerge = objs =>
objs.reduce((prev, img) => Object.assign(prev, img), {});
@ -240,6 +247,7 @@ async function genGenTextSprites(zip) {
// A promise that, given an array buffer returns a skin style object
async function skinParser(zipFileBuffer) {
const JSZip = await getJSZip();
const zip = await JSZip.loadAsync(zipFileBuffer);
const [
colors,