Skip to content

SPFx 1.21.1 Ignoring externals Configuration — Bundling External Libraries Unexpectedly #10406

@lhdeveloper

Description

@lhdeveloper

Target SharePoint environment

SharePoint Online

What SharePoint development model, framework, SDK or API is this about?

💥 SharePoint Framework

Developer environment

macOS

What browser(s) / client(s) have you tested

  • 💥 Internet Explorer
  • 💥 Microsoft Edge
  • 💥 Google Chrome
  • 💥 FireFox
  • 💥 Safari
  • mobile (iOS/iPadOS)
  • mobile (Android)
  • not applicable
  • other (enter in the "Additional environment details" area below)

Additional environment details

  • browser version
  • SPFx version: 1.21.1
  • Node.js version 20.19.0

Expected Behavior

When defining libraries like moment, lodash, or others in the externals section of config/config.json, the final bundle should not include those libraries — reducing the overall bundle size. This was working correctly in SPFx 1.21.0.

Observed Behavior

After upgrading to SPFx 1.21.1, the same configuration is ignored, and external libraries (e.g., moment, lodash) are being bundled into the main JavaScript files, resulting in a massive increase in bundle size — from ~17MB to ~78MB — without any code changes.

Configuration

I have the following in config/config.json:

"externals": {
    "react": {
      "globalName": "React",
      "path": "https://cdn../libs/react.production.min.js"
    },
    "react-dom": {
      "globalName": "ReactDOM",
      "path": "https://cdn../libs/react-dom.production.min.js"
    },
    "moment": {
      "path": "https://cdn../libs/moment.min.js",
      "globalName": "moment"
    }
  },

Metadata

Metadata

Assignees

Labels

Needs: Author FeedbackAwaiting response from the original poster of the issue. Marked as stale if no activity for 7 days.sharepoint-developer-supportsharepoint-developer-supporttype:bug-suspectedSuspected bug (not working as designed/expected). See “type:bug-confirmed” for confirmed bugs.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions