I'm working on a javascript app using the classic node/babel/webpack stack that makes heavy use of lookup tables. The typical code look like this:
const computeLookupTable = () => {
// Expensive computation here
};
export const LookupTable = computeLookupTable();
This work well overall, but there is a major downside: the user's device has to do all the precomputation when the app starts. This seems rather unnecessary as the result of the computation will always be the same. It is worth specding some build time for production build to improve the user's experience.
How can I change this behavior, such as computeLookupTable is run during the build process, and directly get the data in there in the generated blob that is shipped to users?