sp-dev-docs icon indicating copy to clipboard operation
sp-dev-docs copied to clipboard

globalName not being loaded after webpart added to modern page

Open ghost opened this issue 10 years ago • 2 comments

Category

Bug

Expected or Desired Behavior

When adding a webpart with an external library with a globalName defined, the module should be loaded from the CDN, and exported as the global

Example below should load angular into the global variables, this should continue to work after the page has been save and reloaded.

"externals": {
    "@microsoft/sp-client-base": "node_modules/@microsoft/sp-client-base/dist/sp-client-base.js",
    "@microsoft/sp-client-preview": "node_modules/@microsoft/sp-client-preview/dist/sp-client-preview.js",
    "@microsoft/sp-lodash-subset": "node_modules/@microsoft/sp-lodash-subset/dist/sp-lodash-subset.js",
    "office-ui-fabric-react": "node_modules/office-ui-fabric-react/dist/office-ui-fabric-react.js",
    "react": "node_modules/react/dist/react.min.js",
    "react-dom": "node_modules/react-dom/dist/react-dom.min.js",
    "react-dom/server": "node_modules/react-dom/dist/react-dom-server.min.js",
    "angular": {
      "path": "https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.8/angular.min.js",
      "globalName": "angular"
    }
  }

Observed Behavior

When adding a webpart to a modern, or classic page - when it is first added, the globalName is loaded fine and the webpart renders as expected. However, once the page is saved and reloaded you get the error below

Unable to load web part script resources due to: Error: Error: https://spoppe-a.akamaihd.net/files/angular did not call System.register or AMD define. If loading a global module configure the global name via the meta exports property for script injection support. Error loading https://spoppe-a.akamaihd.net/files/angular.

I noticed when debugging sp-client-preview.js that the globalName is missing in manifest.loaderConfig.scriptResources on the second load (see video below).

Steps to Reproduce

Video here to demonstrate, but create a new webpart, add an an external module, package it and upload it and follow the same steps in the video

ghost avatar Sep 18 '16 19:09 ghost

housekeeping: As we didn't hear anything on this area, we are going to close this issue. If this problem still persists with the current version of the framework please open an new Issue.

lucaband avatar Mar 19 '18 21:03 lucaband

Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues

msft-github-bot avatar Jan 30 '20 06:01 msft-github-bot