Skip to content

Load @azure/msal-node lazily in SharePointTransport #14

Description

@llbbl

Deferred from #5 (see PR #12).

src/sharepoint.ts imports ConfidentialClientApplication from @azure/msal-node at the top level, so the SDK loads for every consumer of the package — including ones that only convert Markdown to DOCX and never touch SharePoint.

GoogleDriveTransport now loads @googleapis/drive lazily via a memoized await import() inside upload(). This restores parity.

Measured before the Google transport went lazy: importing the barrel cost ~186ms of module init, of which ~86ms was the Drive SDK alone.

Tasks

  • Move the @azure/msal-node import into a memoized lazy loader, mirroring importDriveFilesClient in src/google.ts (including the deliberate no-memoize-on-failure reset).
  • Preserve the current constructor-time config validation — only the SDK load moves, not the option checks.
  • Add coverage for the memoization and the failed-import retry, mirroring the two tests added for the Drive client.

Partly obviated if #13 (subpath exports) lands first — worth sequencing the two.

Metadata

Metadata

Assignees

No one assigned

    Labels

    transportPluggable transports

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions