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

GlobalDependencies for non-AMD scripts don't work

Open waldekmastykarz opened this issue 10 years ago • 4 comments

Category

  • [ ] Question
  • [ ] Typo
  • [x] Bug
  • [ ] Enhancement / Suggestion
  • [ ] Additional article idea

Expected or Desired Behavior

If you're loading two non-AMD scripts and one depends on another, you should be able to define the order in which they are being loaded using the globalDependencies property in the config.json file.

Observed Behavior

It seems like the globalDependencies property is not taken into account when loading non-AMD scripts defined in the externals section of config.json.

Steps to Reproduce

In config.json add to externals:

"jquery": {
  "path": "https://code.jquery.com/jquery-2.1.1.min.js",
  "globalName": "jQuery"
},
"simpleWeather": {
  "path": "https://cdnjs.cloudflare.com/ajax/libs/jquery.simpleWeather/3.1.0/jquery.simpleWeather.min.js",
  "globalName": "jQuery",
  "globalDependencies": [ "jquery" ]
}

In web part code add:

import * as $ from 'jquery';
require('simpleWeather');

After adding the web part to the page you will get an error:

jquery.simpleWeather.min.js:2  Uncaught ReferenceError: jQuery is not defined(…)

This works as expected in the previous drops but seems to be broken in drop 5. The working code using an older drop can be found at https://github.com/waldekmastykarz/spfx-weather-webpart. If you update it to drop 5 you should see the error described above.

waldekmastykarz avatar Oct 26 '16 10:10 waldekmastykarz

@nickpape-msft might help to understand what is going on.

chakkaradeep avatar Nov 04 '16 18:11 chakkaradeep

This is still broken in drop 6.

StfBauer avatar Dec 16 '16 16:12 StfBauer

This bug was fixed on January 2017 on the runtime code. No need to change the manifests at all. Now the dependencies resolution is working as expected.

mpasarin avatar May 03 '17 20:05 mpasarin

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 00:01 msft-github-bot