AzureAD / microsoft-authentication-library-for-js

Microsoft Authentication Library (MSAL) for JS
http://aka.ms/aadv2
MIT License
3.66k stars 2.65k forks source link

@azure/msal-browser expected bundle size #6702

Closed doepnern closed 11 months ago

doepnern commented 11 months ago

Core Library

MSAL.js (@azure/msal-browser)

Core Library Version

3.5.0

Wrapper Library

Not Applicable

Wrapper Library Version

None

Public or Confidential Client?

Public

Description

After installing msal-browser and only importing import { PublicClientApplication } from '@azure/msal-browser';, the bundle size increases by over 600kb. Is this the expected bundle size or am I missing something.

bundleSize

I am using vite with the following configuration:

export default defineConfig({
  cacheDir: '../../../../node_modules/.vite/shared-ui-login-react',

  plugins: [
    react(),
    nxViteTsPaths(),
    visualizer({ emitFile: true, filename: 'stats.html' }) as PluginOption,
  ],

  // Uncomment this if you are using workers.
  // worker: {
  //  plugins: [ nxViteTsPaths() ],
  // },
  build: {
    lib: {
      // Could also be a dictionary or array of multiple entry points.
      entry: 'src/index.ts',
      name: 'login-react',
      fileName: 'index',
      // Change this to the formats you want to support.
      // Don't forget to update your package.json as well.
      formats: ['es', 'cjs'],
    },
    rollupOptions: {
      // External packages that should not be bundled into your library.
      external: ['react', 'react-dom', 'react/jsx-runtime'],
    },
  },

  test: {
    globals: true,
    cache: {
      dir: '../../../../node_modules/.vitest',
    },
    environment: 'jsdom',
    include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
  },
});

MSAL Configuration

No response

Relevant Code Snippets

No response

Identity Provider

None

Source

External (Customer)

tnorling commented 11 months ago

It doesn't look like you're minifying your bundle. The minified size is around 270kb right now.