Skip to content

GlobalDependecies in config.json don't work #7950

@MarioZagreb

Description

@MarioZagreb

Target SharePoint environment

SharePoint Online

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

💥 SharePoint Framework

Developer environment

Windows

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
  • Node.js version
  • etc

Describe the bug / error

I have a custom web part developed in SPfx (no javascript framework) and this is my config.json (part for externals):

"externals": {
"jquery": {
"path": "https://code.jquery.com/jquery-3.6.0.min.js",
"globalName": "jquery"
},
"sppeoplepicker": {
"path": "lib/webparts/aa/scripts/sp.peoplepicker.js",
"globalName": "sppeoplepicker",
"globalDependencies": ["jquery"]
},
"bootstrap": {
"path": "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js",
"globalName": "bootstrap",
"globalDependencies": ["jquery"]
},
"appjs": {
"path": "lib/webparts/aa/scripts/app.js",
"globalName": "appjs",
"globalDependencies": ["jquery"]
},

"jqueryui": {
  "path": "lib/webparts/aa/scripts/jquery-ui.js",
  "globalName": "jqueryui",
  "globalDependencies": ["jquery"]
}

},

And everytime I open page with my webpart i get an error:
p(...).spPeoplePicker is not a function

After page refresh, it works ok.
But, sometimes you have to refresh 2 or 3 times. Sometimes it crashes after 5th refresh.
It does not wait for jQuery to load. Why?

Steps to reproduce

Include sp.peoplepicker.js in config.json file (and jquery)

"externals": {    
    "jquery": {
      "path": "https://code.jquery.com/jquery-3.6.0.min.js",
      "globalName": "jquery"
    },
    "sppeoplepicker": {
      "path": "lib/webparts/aa/scripts/sp.peoplepicker.js",
      "globalName": "sppeoplepicker",
      "globalDependencies": ["jquery"]
    },
    "bootstrap": {
      "path": "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js",
      "globalName": "bootstrap",
      "globalDependencies": ["jquery"]
    },
    "appjs": {
      "path": "lib/webparts/aa/scripts/app.js",
      "globalName": "appjs",
      "globalDependencies": ["jquery"]
    },
    
    "jqueryui": {
      "path": "lib/webparts/aa/scripts/jquery-ui.js",
      "globalName": "jqueryui",
      "globalDependencies": ["jquery"]
    }
  },

define one div:

<div id='ppDefault'>

define that field as people picker:

(<any>$('#ppDefault')).spPeoplePicker({
        minSearchTriggerLength: 2,
        maximumEntitySuggestions: 10,
        principalType: 1,
        principalSource: 15,
        searchPrefix: '',
        searchSuffix: '',
        displayResultCount: 6,
        maxSelectedUsers: 1        
      });

deploy and see the error :)

Expected behavior

I would expect for sp.peoplepicker.js script to load after jquery script.

What am I doing wrong??
I am losing my mind over this for days now

Metadata

Metadata

Assignees

Labels

area:spfxCategory: SharePoint Framework (not extensions related)status:fixed-next-dropIssue planned to be fixed in an upcoming release.type:bug-suspectedSuspected bug (not working as designed/expected). See “type:bug-confirmed” for confirmed bugs.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions