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

Loading external script

Open craghavendra21 opened this issue 8 years ago • 2 comments

Category

  • [x] Question
  • [x] Bug
  • [x] Additional article idea
  • [ ] Typo

Expected or Desired Behavior

should be able to load the external script

Observed Behavior

throwing an error when a dependency is mentioned (jquery is required to load this script)

Steps to Reproduce

Create normal SPFX solution and add the jquery filter tree view plugin js file to your solution. which is available in below URL. https://www.jqueryscript.net/layout/Filterable-Tree-View-Plugin-with-jQuery-Tree-Filter.html I have installed jquery npm package and added jquery to ExternalJS folder inside the src folder. Before loading jquery.treefilter.js I want to load jquery so I have mentioned jquery in global dependencies. Below is the code from my config.json.

  "externals": {
    "jquery": {
      "path": "./src/ExternalJS/jquery-3.3.1.min.js",
      "globalName": "jQuery"
    },
    "treefilter" : {
      "path": "./src/ExternalJS/jquery.treefilter.js",
      "globalName": "jQuery",
      "globalDependencies": [
        "jquery"
      ]
    }
  },

below is the error throwing when webpart is loaded.

[SPLoaderError.loadComponentError]:
***Failed to load component "aefbeb91-e077-4384-b259-4a8e015bec57" (NavigationWebPart).
Original error: ***Resource "jquery" not found in loader configuration of manifest for component "aefbeb91-e077-4384-b259-4a8e015bec57" (NavigationWebPart).

***INNERERROR:
***Resource "jquery" not found in loader configuration of manifest for component "aefbeb91-e077-4384-b259-4a8e015bec57" (NavigationWebPart).
***CALLSTACK:
Error
    at t [as constructor] (https://spoprod-a.akamaihd.net/files/sp-client-prod_2018-04-27.034/sp-webpart-workbench-assembly_en-us_a6cbd583ceaefa76b6d197756798282a.js:283:15766)
    at new t (https://spoprod-a.akamaihd.net/files/sp-client-prod_2018-04-27.034/sp-webpart-workbench-assembly_en-us_a6cbd583ceaefa76b6d197756798282a.js:926:22392)
    at Function.e.buildErrorWithVerboseLog (https://spoprod-a.akamaihd.net/files/sp-client-prod_2018-04-27.034/sp-webpart-workbench-assembly_en-us_a6cbd583ceaefa76b6d197756798282a.js:926:14504)
    at Function.e.buildLoadComponentError (https://spoprod-a.akamaihd.net/files/sp-client-prod_2018-04-27.034/sp-webpart-workbench-assembly_en-us_a6cbd583ceaefa76b6d197756798282a.js:926:10703)
    at https://spoprod-a.akamaihd.net/files/sp-client-prod_2018-04-27.034/sp-webpart-workbench-assembly_en-us_a6cbd583ceaefa76b6d197756798282a.js:926:64573

craghavendra21 avatar May 11 '18 07:05 craghavendra21

Seems that you have a casing issue - in the config.json you define jQuery as "jQuery" and exception indicates that you used "jquery" to reference it.

VesaJuvonen avatar Jun 05 '18 17:06 VesaJuvonen

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 27 '20 18:01 msft-github-bot