#!/bin/bash # https://docs.sheetjs.com/docs/demos/frontend/bundler/vitejs # NOTE: this only checks whether data or SheetJS code is added to the bundle cd /tmp rm -rf sheetjs-vite-tests mkdir sheetjs-vite-tests cd sheetjs-vite-tests for n in {3..5}; do npm create vite@$n sheetjs-vite$n -- --template vue-ts cd sheetjs-vite$n npm i npm i --save https://cdn.sheetjs.com/xlsx-0.20.2/xlsx-0.20.2.tgz npm ls | grep vite curl -O https://docs.sheetjs.com/vitejs/vite.config.ts mkdir -p data curl -L -o data/pres.xlsx https://sheetjs.com/pres.xlsx cat >src/components/HelloWorld.vue < // @ts-ignore import data from '../../data/pres.xlsx?sheetjs'; EOF npm run build echo "### Results: " $(grep Clinton -R dist | wc -l) $(grep BESSELJ -R dist | wc -l) cat >src/components/HelloWorld.vue < // @ts-ignore import b64 from '../../data/pres.xlsx?b64'; import { read, utils } from "xlsx"; /* parse workbook and convert first sheet to row array */ const wb = read(b64); const ws = wb.Sheets[wb.SheetNames[0]]; interface IPresident { Name: string; Index: number; }; const data = utils.sheet_to_json(ws); EOF npm run build echo "### Results: " $(grep Clinton -R dist | wc -l) $(grep BESSELJ -R dist | wc -l) cd - done