#!/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-latest/xlsx-latest.tgz npm ls | grep vite ## See https://github.com/vuejs/language-tools/issues/4484#issuecomment-2182469459 if [[ "$n" == "4" ]]; then npm i "vue-tsc@2"; fi 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