dimanche 26 avril 2020

Reducing Webpack bundle size with braintree-web and TypeScript

Using braintree-web 3.61.0 with Vue.js 2.6.11 and TypeScript 3.8.3, I export the parts of braintree-web I need as a service like this:

import { client, hostedFields, applePay } from 'braintree-web';
export default { client , hostedFields, applePay };

Using webpack-bundle-analyzer, my builds appear to be pulling in all of 'braintree-web'. The code above produces the same result as:

import braintree from 'braintree-web';
export default braintree;

If I try this approach,

import client from 'braintree-web/client';
import hostedFields from 'braintree-web/hosted-fields';
import applePay from 'braintree-web/apple-pay';
export default { client , hostedFields, applePay };

I get errors saying to install @types/braintree-web - something that's already installed.

Any suggestions?




Aucun commentaire:

Enregistrer un commentaire