Skip to content

Long build times for SPFx projects with many components #3355

@vman

Description

@vman

Category

  • Question
  • Typo
  • Bug
  • Additional article idea

Expected or Desired Behavior

When developing/testing using gulp serve for large SPFx projects (more than 25 webparts and extensions), only the changed files should be built using webpack.

Observed Behavior

For large SPFx projects (including the SharePoint starter kit) where there are a large number of components, with every code change it takes about 25 seconds for webpack to build the new bundle.

image

This means even if we modify a single line of code, we have to wait for webpack to build the entire bundle with all the components.

I have seen this issue is mainly because SPFx adds each component by default as a separate bundle: https://github.com/SharePoint/sp-starter-kit/blob/master/solution/config/config.json

If I move all components to a single bundle, the build time is reduced considerably. But then we have the issue of having all components in a single bundle and code might be loaded on the page even if it's not needed.

Steps to Reproduce

  1. Clone the SP Starter Kit repo
  2. npm install
  3. gulp serve
  4. Observe that it takes about 25 secs for webpack to build the bundle
  5. Change a line of code in any webpart and save
  6. Observe that again it takes about 25 secs for webpack to build the bundle

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:spfxCategory: SharePoint Framework (not extensions related)status:trackedCurrently tracked with Microsoft’s internal issue tracking system. DO NOT ADD/REMOVE (MSFT managed)type:bug-confirmedConfirmed bug, not working as designed / expected.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions